From 628fd0e6838b4f09356359f929ae28b245f84647 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 27 Jul 2011 18:51:07 +0200 Subject: [PATCH] Fixed the recognition of reuse of inodes in diff. --- HISTORY | 4 ++++ configure.ac | 2 +- scan.c | 32 +++++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/HISTORY b/HISTORY index 2c9f9941..6a53e3ec 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,10 @@ SnapRAID HISTORY ================ +1.6 2011/8 +========== +* In "diff" now recognizes the reuse of inodes. + 1.5 2011/7 ========== * Ignores extra spaces in the configuration file. diff --git a/configure.ac b/configure.ac index 95b0d944..05d59ee1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([snapraid], [1.5], [], [], [http://snapraid.sourceforge.net]) +AC_INIT([snapraid], [1.6], [], [], [http://snapraid.sourceforge.net]) AM_INIT_AUTOMAKE([foreign no-dependencies -Wall]) AC_CONFIG_SRCDIR([snapraid.c]) AC_CONFIG_HEADER([config.h]) diff --git a/scan.c b/scan.c index 27825f3d..69f03b27 100644 --- a/scan.c +++ b/scan.c @@ -187,16 +187,34 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state, } } - if (state->gui) { - fprintf(stderr, "scan:update:%s:%s\n", disk->name, file->sub); - fflush(stderr); - } - if (output) { - printf("Update '%s%s'\n", disk->dir, file->sub); + if (strcmp(file->sub, sub) == 0) { + /* if the name is the same, it's an update */ + if (state->gui) { + fprintf(stderr, "scan:update:%s:%s\n", disk->name, file->sub); + fflush(stderr); + } + if (output) { + printf("Update '%s%s'\n", disk->dir, file->sub); + } + + ++scan->count_change; + } else { + /* if the name is different, it's an inode reuse */ + if (state->gui) { + fprintf(stderr, "scan:remove:%s:%s\n", disk->name, file->sub); + fprintf(stderr, "scan:add:%s:%s\n", disk->name, sub); + fflush(stderr); + } + if (output) { + printf("Remove '%s%s'\n", disk->dir, file->sub); + printf("Add '%s%s'\n", disk->dir, sub); + } + + ++scan->count_remove; + ++scan->count_insert; } /* remove it */ - ++scan->count_change; scan_file_remove(state, disk, file); /* and continue to reinsert it */