From dc3b03c4c40b265367072c80a4d652f019e212e2 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 12 Nov 2012 23:01:07 +0100 Subject: [PATCH] Ignore nanoseconds if -N is specified. --- HISTORY | 2 ++ snapraid.1 | 7 +++++-- snapraid.c | 4 +++- snapraid.d | 7 +++++-- snapraid.txt | 7 +++++-- state.c | 4 ++++ 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/HISTORY b/HISTORY index aa38329f..9b865a01 100644 --- a/HISTORY +++ b/HISTORY @@ -32,6 +32,8 @@ SnapRAID HISTORY This allows to excludes some file/directory without the need to call the stat() function on them. * Removed MD5 support. + * The -N, --find-by-name option also ignores the nanosecond part of + timestamps to work with copy programs not supporting nanoseconds. 1.13 2012/11 ============ diff --git a/snapraid.1 b/snapraid.1 index d22636d3..757e17dc 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -18,7 +18,7 @@ snapraid [\(hyc, \(hy\(hyconf CONFIG] .PD 0 .PP .PD - [\(hyZ, \(hy\(hyforce\(hyzero] [\(hyE, \(hy\(hyforce\(hyempty] + [\(hyZ, \(hy\(hyforce\(hyzero] [\(hyE, \(hy\(hyforce\(hyempty] [\(hyS, \(hy\(hyforce\(hysecond] .PD 0 .PP .PD @@ -387,7 +387,8 @@ doing any kind of check on the redundancy data. This option can be used only with the \(a"check\(a" command. .TP .B \(hyN, \(hy\(hyfind\(hyby\(hyname -When syncing finds the files by path instead than by inode. +When syncing finds the files by path instead than by inode, +and ignores the nanosecond part of timestamp. This option allows a fast sync command after having replaced one physical disk with another, copying manually the files. Without this option the \(a"sync\(a" command recognizes that @@ -395,6 +396,8 @@ the files were copied to a different disk, and it will resync them all. With this option, a file with the correct path, size and time is assumed identical at the previous one, and not resynched. +The nanosecond part of timestamps is ignored because most of +copy programs are not able to correctly restore them. Note that if you use this option, all the hard\(hylinks will be stored independently wasting space. So, if you use hard\(hylinks, it\(cqs better to don\(cqt use it. diff --git a/snapraid.c b/snapraid.c index 8d354d19..2df40977 100644 --- a/snapraid.c +++ b/snapraid.c @@ -62,6 +62,7 @@ void usage(void) printf(" " SWITCH_GETOPT_LONG("-N, --find-by-name ", "-N") " Find the files by name instead than by inode\n"); printf(" " SWITCH_GETOPT_LONG("-Z, --force-zero ", "-Z") " Force synching of files that get zero size\n"); printf(" " SWITCH_GETOPT_LONG("-E, --force-empty ", "-E") " Force synching of disks that get empty\n"); + printf(" " SWITCH_GETOPT_LONG("-S, --force-second ", "-S") " Force second precision in timestamps\n"); printf(" " SWITCH_GETOPT_LONG("-s, --start BLKSTART ", "-s") " Start from the specified block number\n"); printf(" " SWITCH_GETOPT_LONG("-t, --count BLKCOUNT ", "-t") " Count of block to process\n"); printf(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n"); @@ -84,6 +85,7 @@ struct option long_options[] = { { "count", 1, 0, 't' }, { "force-zero", 0, 0, 'Z' }, { "force-empty", 0, 0, 'E' }, + { "force-second", 0, 0, 'S' }, { "find-by-name", 0, 0, 'N' }, { "audit-only", 0, 0, 'a' }, { "speed-test", 0, 0, 'T' }, @@ -101,7 +103,7 @@ struct option long_options[] = { }; #endif -#define OPTIONS "c:f:d:s:t:ZENaTvhVG" +#define OPTIONS "c:f:d:s:t:ZESNaTvhVG" volatile int global_interrupt = 0; diff --git a/snapraid.d b/snapraid.d index dad1ea4a..0c59b028 100644 --- a/snapraid.d +++ b/snapraid.d @@ -6,7 +6,7 @@ Synopsis : [-f, --filter PATTERN] [-d, --filter-disk NAME] : [-a, --audit-only] : [-N, --find-by-name] - : [-Z, --force-zero] [-E, --force-empty] + : [-Z, --force-zero] [-E, --force-empty] [-S, --force-second] : [-s, --start BLKSTART] [-t, --count BLKCOUNT] : [-v, --verbose] : sync|diff|dup|check|fix @@ -261,7 +261,8 @@ Options This option can be used only with the "check" command. -N, --find-by-name - When syncing finds the files by path instead than by inode. + When syncing finds the files by path instead than by inode, + and ignores the nanosecond part of timestamp. This option allows a fast sync command after having replaced one physical disk with another, copying manually the files. Without this option the "sync" command recognizes that @@ -269,6 +270,8 @@ Options them all. With this option, a file with the correct path, size and time is assumed identical at the previous one, and not resynched. + The nanosecond part of timestamps is ignored because most of + copy programs are not able to correctly restore them. Note that if you use this option, all the hard-links will be stored independently wasting space. So, if you use hard-links, it's better to don't use it. diff --git a/snapraid.txt b/snapraid.txt index 8ad86729..223c261b 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -10,7 +10,7 @@ snapraid [-c, --conf CONFIG] [-f, --filter PATTERN] [-d, --filter-disk NAME] [-a, --audit-only] [-N, --find-by-name] - [-Z, --force-zero] [-E, --force-empty] + [-Z, --force-zero] [-E, --force-empty] [-S, --force-second] [-s, --start BLKSTART] [-t, --count BLKCOUNT] [-v, --verbose] sync|diff|dup|check|fix @@ -290,7 +290,8 @@ SnapRAID provides the following options: This option can be used only with the "check" command. -N, --find-by-name - When syncing finds the files by path instead than by inode. + When syncing finds the files by path instead than by inode, + and ignores the nanosecond part of timestamp. This option allows a fast sync command after having replaced one physical disk with another, copying manually the files. Without this option the "sync" command recognizes that @@ -298,6 +299,8 @@ SnapRAID provides the following options: them all. With this option, a file with the correct path, size and time is assumed identical at the previous one, and not resynched. + The nanosecond part of timestamps is ignored because most of + copy programs are not able to correctly restore them. Note that if you use this option, all the hard-links will be stored independently wasting space. So, if you use hard-links, it's better to don't use it. diff --git a/state.c b/state.c index f8d0db55..2af763a9 100644 --- a/state.c +++ b/state.c @@ -902,6 +902,10 @@ void state_read(struct snapraid_state* state) } hash = oathash32(hash, v_mtime_nsec); + /* ignore nanoseconds if asked to find by name */ + if (state->find_by_name) + v_mtime_nsec = FILE_MTIME_NSEC_INVALID; + c = sgetc(f); } else { /* use a special value, meaning that we don't have this information */