Hi Jean-Louis, My apologies for being slow with replying.
> Attached patch fix a bug because DIR_IS_NFS return 2 if it is NFS. Thank you, I have applied it. > Instead of trying to detect if the device should be used, why not add > an argument: > --no-check-device That's a nice idea. I have implemented it in CVS (see the attached patch). A complementary option --check-device is provided as well, in case someone needs to override --no-check-device set in the TAR_OPTIONS variable. Thanks for your contributions. Regards, Sergey
* src/common.h (check_device_option): New global. * src/incremen.c (procdir): Use boolean and instead of bitwise one. Patch by Jean-Louis Martineau. Compare device numbers only if check_device_option is set. * src/tar.c: New command line options --no-check-device and --check-device. Proposed by Jean-Louis Martineau. (parse_opt): Hanlde new options. (decode_options): Initialize check_device_option to true. Index: src/common.h =================================================================== RCS file: /cvsroot/tar/tar/src/common.h,v retrieving revision 1.102 diff -p -u -r1.102 common.h --- src/common.h 29 Oct 2007 16:55:58 -0000 1.102 +++ src/common.h 27 Mar 2008 08:44:19 -0000 @@ -188,6 +188,8 @@ GLOBAL enum old_files old_files_option; /* Specified file name for incremental list. */ GLOBAL const char *listed_incremental_option; +/* Check device numbers when doing incremental dumps. */ +GLOBAL bool check_device_option; /* Specified mode change string. */ GLOBAL struct mode_change *mode_option; Index: src/incremen.c =================================================================== RCS file: /cvsroot/tar/tar/src/incremen.c,v retrieving revision 1.61 diff -p -u -r1.61 incremen.c --- src/incremen.c 13 Nov 2007 07:01:26 -0000 1.61 +++ src/incremen.c 27 Mar 2008 08:44:19 -0000 @@ -250,7 +250,8 @@ procdir (char *name_buffer, struct stat directories, consider all NFS devices as equal, relying on the i-node to establish differences. */ - if (! (((DIR_IS_NFS (directory) & nfs) + if (! ((!check_device_option + || (DIR_IS_NFS (directory) && nfs) || directory->device_number == stat_data->st_dev) && directory->inode_number == stat_data->st_ino)) { Index: src/tar.c =================================================================== RCS file: /cvsroot/tar/tar/src/tar.c,v retrieving revision 1.173 diff -p -u -r1.173 tar.c --- src/tar.c 29 Oct 2007 16:56:56 -0000 1.173 +++ src/tar.c 27 Mar 2008 08:44:19 -0000 @@ -249,6 +249,7 @@ enum ANCHORED_OPTION = CHAR_MAX + 1, ATIME_PRESERVE_OPTION, BACKUP_OPTION, + CHECK_DEVICE_OPTION, CHECKPOINT_OPTION, CHECKPOINT_ACTION_OPTION, DELAY_DIRECTORY_RESTORE_OPTION, @@ -275,6 +276,7 @@ enum MTIME_OPTION, NEWER_MTIME_OPTION, NO_ANCHORED_OPTION, + NO_CHECK_DEVICE_OPTION, NO_DELAY_DIRECTORY_RESTORE_OPTION, NO_IGNORE_CASE_OPTION, NO_IGNORE_COMMAND_ERROR_OPTION, @@ -411,6 +413,12 @@ static struct argp_option options[] = { " NUMBER defaults to 1"), GRID+1 }, {"seek", 'n', NULL, 0, N_("archive is seekable"), GRID+1 }, + {"no-check-device", NO_CHECK_DEVICE_OPTION, NULL, 0, + N_("do not check device numbers when creating incremental archives"), + GRID+1 }, + {"check-device", CHECK_DEVICE_OPTION, NULL, 0, + N_("check device numbers when creating incremental archives (default)"), + GRID+1 }, #undef GRID #define GRID 30 @@ -1545,6 +1553,14 @@ parse_opt (int key, char *arg, struct ar " on this platform"))); break; + case CHECK_DEVICE_OPTION: + check_device_option = true; + break; + + case NO_CHECK_DEVICE_OPTION: + check_device_option = false; + break; + case CHECKPOINT_OPTION: if (arg) { @@ -2053,6 +2069,8 @@ decode_options (int argc, char **argv) owner_option = -1; group_option = -1; + check_device_option = true; + /* Convert old-style tar call by exploding option element and rearranging options accordingly. */