Skip to content

stat.inode is not reliable as a check for samefile() if using network files on Windows #50596

@sunito

Description

@sunito

I was baffled for quite a while, when I found that samefile("N:\\A", "N:\\B") can return true for (different) network files on Windows 10 running in VirtualBox.
I then found, that stat(file_name) does not yield consistent .inode values.

Steps to reproduce:

  1. Start Windows 10 in a VirtualBox with a (writable) shared folder.
    Let's assume that this folder is mounted to drive "N:".

  2. Check, that they are not constant:

julia> [stat("N:\\").inode for i in 1:9]
  9-element Vector{UInt64}:
   0x00000000a6a14aa0
   0x00000000ac184aa0
   0x00000000a6973aa0
   0x00000000a1596010
   0x00000000a69caaa0
   0x00000000a276a840
   0x000000009dc7a5e0
   0x00000000a6974aa0
   0x00000000a69dbaa0
  1. Check that some inode values repeat:
    julia> length(unique([stat("I:\\").inode for i in 1:99]))
    74
  2. After a while the inode values will stay the same (at least on my machine):
    julia> length(unique([stat("I:\\").inode for i in 1:99]))
    1

The shared file system is ext4 on a linux machine.

julia> versioninfo()
Julia Version 1.9.2
Commit e4ee485e90 (2023-07-05 09:39 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 2 × AMD Ryzen 7 4700U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver2)
  Threads: 1 on 2 virtual cores

Metadata

Metadata

Assignees

No one assigned

    Labels

    filesystemUnderlying file system and functions that use itsystem:windowsAffects only Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions