Ignore nanoseconds if -N is specified.

This commit is contained in:
Andrea Mazzoleni 2012-11-12 23:01:07 +01:00
parent d6678db702
commit dc3b03c4c4
6 changed files with 24 additions and 7 deletions

View file

@ -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
============

View file

@ -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.

View file

@ -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;

View file

@ -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.

View file

@ -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.

View file

@ -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 */