in reply to stat to identify files?
A given device/inode tuple should be unique for a given configuration, but keep in mind that if you're dealing with transient filesystems (e.g. sshfs) that the tuples may not stay consistent across remounts (both device and inode could change for the same path).
## Stat something on an sshfs-mounted volume $ stat -s /Volumes/foo/Makefile.am st_dev=754974730 st_ino=4 st_mode=0100664 st_nlink=1 st_uid=501 st_gid +=501 st_rdev=0 st_size=41056 st_atime=1206379971 st_mtime=1206379971 +st_ctime=0 st_birthtime=0 st_blksize=65536 st_blocks=88 st_flags=0 $ umount /Volumes/foo ## convenience wrapper to call sshfs with some extra options $ sshfsmount somehost:foo foo ICON: foo => /Users/fletch/lib/icons/icns/gir.icns $ stat -s /Volumes/foo/Makefile.am st_dev=754974731 st_ino=3 st_mode=0100664 st_nlink=1 st_uid=501 st_gid +=501 st_rdev=0 st_size=41056 st_atime=1206379971 st_mtime=1206379971 +st_ctime=0 st_birthtime=0 st_blksize=65536 st_blocks=88 st_flags=0
So long as you're only comparing them inside a run and your filesystem's not dropping out from underneath you should be OK, but don't depend on it across remounts / reboots. In that case I'd move to something more intrinsic to the file (say Digest::SHA1) that could be recalculated (but that's going to entail more work and IO than just using the paths and stat metainfo).
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: stat to identify files?
by Skeeve (Parson) on Jun 11, 2008 at 17:13 UTC |