diff --git a/HISTORY b/HISTORY index 5244d6fa..e4c194a1 100644 --- a/HISTORY +++ b/HISTORY @@ -22,6 +22,9 @@ SnapRAID HISTORY 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. + * 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 ef240e64..541bba12 100644 --- a/scan.c +++ b/scan.c @@ -467,37 +467,59 @@ 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 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; - /* 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 { + /* 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) { + fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub); + fflush(stdlog); + } + } /* nothing more to do */ return; @@ -690,8 +712,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); } diff --git a/snapraid.1 b/snapraid.1 index 21fc1008..bc34cc69 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -415,6 +415,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 adb6aa41..a2d6a96e 100644 --- a/snapraid.d +++ b/snapraid.d @@ -231,6 +231,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 c960e4cc..8f060dbe 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -252,6 +252,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 ==========