From 7f9ca6933e23def5f0ae0f07c3169e53aa075443 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 30 Sep 2013 22:42:33 +0200 Subject: [PATCH 1/4] Removes unexpected Restore message from diff with filesystem without persistent inodes. --- HISTORY | 6 ++++-- scan.c | 65 +++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/HISTORY b/HISTORY index fff25da1..9bdc81d9 100644 --- a/HISTORY +++ b/HISTORY @@ -1,12 +1,14 @@ SnapRAID HISTORY ================ -4.2 2013/9 -========== +4.2 2013/10 +=========== * Fixed the wrong warning about physical offsets not supported caused by files not having a real offset because too small. For example, in NTFS it's possible to store such files in the MFT. It's just a cosmetic change, and not a functional one. + * Remove unexpected 'Restore' entries in the diff output when dealing + with filesystem without persistent inodes like NTFS in Linux. 4.1 2013/9 ========== diff --git a/scan.c b/scan.c index 4b1d961d..00f9d5ba 100644 --- a/scan.c +++ b/scan.c @@ -450,37 +450,56 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state, || file->mtime_nsec == STAT_NSEC_INVALID ) ) { - /* here we know that the inode is different and it needs to be updated */ - /* otherwise we would have processed the file when searching by inode */ - state->need_write = 1; - /* mark as present */ file_flag_set(file, FILE_IS_PRESENT); - /* always update the nano seconds mtime */ - /* to manage the above STAT_NSEC_INVALID case */ - file->mtime_nsec = STAT_NSEC(st); + /* update the nano seconds mtime only if different */ + /* to avoid unneeded updates */ + if (file->mtime_nsec == STAT_NSEC_INVALID + && STAT_NSEC(st) != STAT_NSEC_INVALID + ) { + file->mtime_nsec = STAT_NSEC(st); - /* if the inode is different, it means a rewritten file with the same path */ - /* like when restoring a backup that restores also the timestamp */ - ++scan->count_restore; - - if (state->opt.gui) { - fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub); - fflush(stdlog); - } - if (output) { - printf("Restore '%s%s'\n", disk->dir, sub); + /* we have to save the new mtime */ + state->need_write = 1; } - /* remove from the inode set */ - tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + /* if the inode is different same */ + if (file->inode != st->st_ino) { + /* if the inode is different, it means a rewritten file with the same path */ + /* like when restoring a backup that restores also the timestamp */ + ++scan->count_restore; - /* save the new inode */ - file->inode = st->st_ino; + if (state->opt.gui) { + fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub); + fflush(stdlog); + } + if (output) { + printf("Restore '%s%s'\n", disk->dir, sub); + } - /* reinsert in the inode set */ - tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + /* remove from the inode set */ + tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + + /* save the new inode */ + file->inode = st->st_ino; + + /* reinsert in the inode set */ + tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + + /* we have to save the new inode */ + state->need_write = 1; + } else { + /* this is the equal case when persistent inodes are not supported */ + assert(disk->has_not_persistent_inodes); + + ++scan->count_equal; + + if (state->opt.gui) { + fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub); + fflush(stdlog); + } + } /* nothing more to do */ return; From 0e2a2b3f105aa89a3d952eb653178f327dd1b8bd Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 1 Oct 2013 18:22:14 +0200 Subject: [PATCH 2/4] Handles correctly the diff case for filesystem without persistent inodes. --- scan.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scan.c b/scan.c index 00f9d5ba..3d29dd66 100644 --- a/scan.c +++ b/scan.c @@ -464,8 +464,11 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state, state->need_write = 1; } - /* if the inode is different same */ - if (file->inode != st->st_ino) { + /* if the disk support persistent inodes */ + if (!disk->has_not_persistent_inodes) { + /* if persistent inodes are supported, we are sure that the inode number */ + /* is now different, because otherwise the file would have been found */ + /* when searching by inode. */ /* if the inode is different, it means a rewritten file with the same path */ /* like when restoring a backup that restores also the timestamp */ ++scan->count_restore; @@ -490,9 +493,9 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state, /* we have to save the new inode */ state->need_write = 1; } else { - /* this is the equal case when persistent inodes are not supported */ - assert(disk->has_not_persistent_inodes); - + /* otherwise it's the case of not persistent inode, where doesn't */ + /* matter if the inode is different or equal, because they have no */ + /* meaning, and then we don't even save them */ ++scan->count_equal; if (state->opt.gui) { From 3167ec4048c518d0e8832905a4a5d6b195f0c833 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 1 Oct 2013 18:22:41 +0200 Subject: [PATCH 3/4] Adds support for filename containing newlines. --- HISTORY | 1 + scan.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index 9bdc81d9..b110ffc7 100644 --- a/HISTORY +++ b/HISTORY @@ -9,6 +9,7 @@ SnapRAID HISTORY It's just a cosmetic change, and not a functional one. * Remove unexpected 'Restore' entries in the diff output when dealing with filesystem without persistent inodes like NTFS in Linux. + * Added support for filenames containing newlines. This happens in Mac OS X. 4.1 2013/9 ========== diff --git a/scan.c b/scan.c index 3d29dd66..c7a2c141 100644 --- a/scan.c +++ b/scan.c @@ -695,8 +695,8 @@ static int scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, in pathprint(path_next, sizeof(path_next), "%s%s", dir, name); pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); - /* check for not supported file names, limitation derived from the content file format */ - if (name[0] == 0 || strchr(name, '\n') != 0 || name[strlen(name)-1] == '\r') { + /* check for not supported file names */ + if (name[0] == 0) { fprintf(stderr, "Unsupported name '%s' in file '%s'.\n", name, path_next); exit(EXIT_FAILURE); } From 78591a1e654389d5412d98d87d96ee82c87677c3 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 1 Oct 2013 21:32:48 +0200 Subject: [PATCH 4/4] Adds in the doc how to configure SAMBA to share the pool directory. --- snapraid.1 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ snapraid.d | 15 +++++++++++++++ snapraid.txt | 15 +++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/snapraid.1 b/snapraid.1 index 1cf6c8cf..beb0fc9f 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -404,6 +404,52 @@ snapraid pool .PP .PD .RE +.PP +If you are using a Unix platform and you want to configure SAMBA to +share such directory, you should add to your /etc/samba/smb.conf the +following options: +.PP +.RS 4 +# In the global section of smb.conf +.PD 0 +.PP +.PD +unix extensions = no +.PD 0 +.PP +.PD +.RE +.PP +.RS 4 +# In the share section of smb.conf +.PD 0 +.PP +.PD +[pool] +.PD 0 +.PP +.PD +comment = Pool +.PD 0 +.PP +.PD +path = /pool +.PD 0 +.PP +.PD +read only = yes +.PD 0 +.PP +.PD +guest ok = yes +.PD 0 +.PP +.PD +wide links = yes +.PD 0 +.PP +.PD +.RE .SH COMMANDS SnapRAID provides some simple commands that allow to: .PD 0 diff --git a/snapraid.d b/snapraid.d index 1e37c502..4c3c736f 100644 --- a/snapraid.d +++ b/snapraid.d @@ -224,6 +224,21 @@ Getting Started :snapraid pool + If you are using a Unix platform and you want to configure SAMBA to + share such directory, you should add to your /etc/samba/smb.conf the + following options: + + :# In the global section of smb.conf + :unix extensions = no + + :# In the share section of smb.conf + :[pool] + :comment = Pool + :path = /pool + :read only = yes + :guest ok = yes + :wide links = yes + Commands SnapRAID provides some simple commands that allow to: diff --git a/snapraid.txt b/snapraid.txt index 5d5e6263..dad87a57 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -243,6 +243,21 @@ and then run the "pool" command. snapraid pool +If you are using a Unix platform and you want to configure SAMBA to +share such directory, you should add to your /etc/samba/smb.conf the +following options: + + # In the global section of smb.conf + unix extensions = no + + # In the share section of smb.conf + [pool] + comment = Pool + path = /pool + read only = yes + guest ok = yes + wide links = yes + 5 COMMANDS ==========