Tim Waugh <[EMAIL PROTECTED]> wrote: > A Netapp NFS server containing a file (xxx) and a snapshot of the file > (.snapshot/xxx) will give them the same inode number. > > Unfortunately, 'cp .snapshot/xxx xxx' (in order to recover the > snapshot version) fails with '... are identical' due to the inode > check. > > Is there some way of bypassing this check?
Yes. Use cp's --backup (-b) option. Then, cp can be sure that opening the destination file (for writing) will not destroy the source file. Using --backup has the added advantage that the destination file is replaced atomically (via rename), rather than being rewritten in place. > More importantly, is there something in POSIX which says that this > check is allowed in the first place? Yes. NetApp's doing that (letting two different files have the same dev/inode numbers) is not POSIX compliant. Quoting from http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html: The st_ino and st_dev fields taken together uniquely identify the file within the system. That said, it might be worthwhile to change the SAME_INODE checks in copy.c to also check same_file_attributes, where that macro is defined like this (from diffutils/src/system.c): /* Do struct stat *S, *T have the same file attributes? POSIX says that two files are identical if st_ino and st_dev are the same, but many filesystems incorrectly assign the same (device, inode) pair to two distinct files, including: - GNU/Linux NFS servers that export all local filesystems as a single NFS filesystem, if a local device number (st_dev) exceeds 255, or if a local inode number (st_ino) exceeds 16777215. - Network Appliance NFS servers in snapshot directories; see Network Appliance bug #195. - ClearCase MVFS; see bug id ATRia04618. Check whether two files that purport to be the same have the same attributes, to work around instances of this common bug. Do not inspect all attributes, only attributes useful in checking for this bug. It's possible for two distinct files on a buggy filesystem to have the same attributes, but it's not worth slowing down all implementations (or complicating the configuration) to cater to these rare cases in buggy implementations. */ #ifndef same_file_attributes # define same_file_attributes(s, t) \ ((s)->st_mode == (t)->st_mode \ && (s)->st_nlink == (t)->st_nlink \ && (s)->st_uid == (t)->st_uid \ && (s)->st_gid == (t)->st_gid \ && (s)->st_size == (t)->st_size \ && (s)->st_mtime == (t)->st_mtime \ && (s)->st_ctime == (t)->st_ctime) #endif _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
