Issue #14177 has been updated by usa (Usaku NAKAMURA).

Target version set to next minor

at least, not in 2.5

----------------------------------------
Feature #14177: PATCH: File::Stat#dev on Windows
https://bugs.ruby-lang.org/issues/14177#change-68379

* Author: kubo (Takehiro Kubo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: next minor
----------------------------------------
Two files are identical when pairs of File::Stat#dev and File::Stat#ino
are same on unix. However when a volume (disk partition) is mounted on
a directory they may not identical even when the pairs are same on Windows
because File::Stat#dev is based on drive letters.

I did the following on Windows on vmware.

1. attach a new virtual disk to the VM.
2. create two NTFS volumes in the disk and mount them to c:\volume1 and c:\volume2 respectively.
3. create two files in c:\volume1 and c:\volume2 respectively.
4. File.stat(filename).dev returns 2 ('C' - 'A') for both files.
5. File.stat(filename).ino returns 281474976710691 for both files.
   The inode number of firstly created file in NTFS seems same.
6. The pairs of #dev and #ino are same even though the files aren't identical.

The attached patch do the followging:

1. change _dev_t to 64-bit rb_dev_t in struct stati128.
2. use FILE_ID_INFO.VolumeSerialNumber (64-bit)
   or BY_HANDLE_FILE_INFORMATION.dwVolumeSerialNumber (32-bit)
   as File::Stat#dev.
3. use path_drive() only when open_special() fails.
4. delete code which become unnecessary by above changes.

However, I think, there are pros and cons of the patch.

Pros.

* Two files are identical when pairs of File::Stat#dev and File::Stat#ino
  are same as on unix

Cons.

* File::Stat#dev returns too large number (32-bit or 64-bit integer).
* In manual File::Stat#dev returns an integer representing the device.
  However this patch makes it return volume serial number, whose
  concept is a bit difference from device.


---Files--------------------------------
file_stat_dev.patch (2.86 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>