From 16ddf36121c336111eba74939fcd0c133d463b48 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 3 Apr 2014 23:02:43 +0200 Subject: [PATCH] Uses a more specific message if UUID are not supported. --- cmdline/elem.c | 1 + cmdline/elem.h | 1 + cmdline/scan.c | 92 +++++++++++++++++++++++++++++-------------------- cmdline/state.c | 4 +-- 4 files changed, 58 insertions(+), 40 deletions(-) diff --git a/cmdline/elem.c b/cmdline/elem.c index 9c5bec48..52a455ec 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -611,6 +611,7 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev disk->has_volatile_inodes = 0; disk->has_unreliable_physical = 0; disk->has_different_uuid = 0; + disk->has_unsupported_uuid = 0; disk->had_empty_uuid = 0; disk->mapping = -1; tommy_list_init(&disk->filelist); diff --git a/cmdline/elem.h b/cmdline/elem.h index 39149fc0..8827bcbd 100644 --- a/cmdline/elem.h +++ b/cmdline/elem.h @@ -297,6 +297,7 @@ struct snapraid_disk { int has_volatile_inodes; /**< If the underline filesystem has not persistent inodes. */ int has_unreliable_physical; /**< If the physical offset of files has duplicates. */ int has_different_uuid; /**< If the disk has a different UUID, meaning that it is not the same filesystem. */ + int has_unsupported_uuid; /**< If the disk doesn't report UUID, meaning it's not supported. */ int had_empty_uuid; /**< If the disk had an empty UUID, meaning that it's a new disk. */ int mapping; /**< Index in the mapping vector. Used only as buffer when writing the content file. */ diff --git a/cmdline/scan.c b/cmdline/scan.c index 5e3e3fb0..56e3d2a0 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -483,7 +483,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c * This ensures that no file is found with a past inode, but at the same time, * it allows to find new files with the same inode, to identify them as hardlinks. */ - int has_past_inodes = !disk->has_volatile_inodes && !disk->has_different_uuid; + int has_past_inodes = !disk->has_volatile_inodes && !disk->has_different_uuid && !disk->has_unsupported_uuid; /* always search with the new inode, in the all new inodes found until now, */ /* with the eventual presence of also the past inodes */ @@ -1199,6 +1199,7 @@ void state_scan(struct snapraid_state* state, int output) tommy_node* i; tommy_node* j; tommy_list scanlist; + int done; tommy_list_init(&scanlist); @@ -1244,8 +1245,8 @@ void state_scan(struct snapraid_state* state, int output) disk->has_volatile_inodes = 1; } - /* if inodes or UUID are not persistent */ - if (disk->has_volatile_inodes || disk->has_different_uuid) { + /* if inodes or UUID are not persistent/changed/unsupported */ + if (disk->has_volatile_inodes || disk->has_different_uuid || disk->has_unsupported_uuid) { /* removes all the inodes from the inode collection */ /* if they are not persistent, all of them could be changed now */ /* and we don't want to find false matching ones */ @@ -1422,7 +1423,7 @@ void state_scan(struct snapraid_state* state, int output) /* checks for disks where all the previously existing files where removed */ if (!state->opt.force_empty) { - int done = 0; + done = 0; for(i=state->disklist,j=scanlist;i!=0;i=i->next,j=j->next) { struct snapraid_disk* disk = i->data; struct snapraid_scan* scan = j->data; @@ -1449,7 +1450,7 @@ void state_scan(struct snapraid_state* state, int output) /* checks for disks without the physical offset support */ if (state->opt.force_order == SORT_PHYSICAL) { - int done = 0; + done = 0; for(i=state->disklist;i!=0;i=i->next) { struct snapraid_disk* disk = i->data; @@ -1467,49 +1468,64 @@ void state_scan(struct snapraid_state* state, int output) } } - /* Check for disks without persistent inodes */ - { - int done = 0; - for(i=state->disklist;i!=0;i=i->next) { - struct snapraid_disk* disk = i->data; + /* checks for disks without persistent inodes */ + done = 0; + for(i=state->disklist;i!=0;i=i->next) { + struct snapraid_disk* disk = i->data; - if (disk->has_volatile_inodes) { - if (!done) { - done = 1; - fprintf(stderr, "WARNING! Inodes are not persistent for disks: '%s'", disk->name); - } else { - fprintf(stderr, ", '%s", disk->name); - } + if (disk->has_volatile_inodes) { + if (!done) { + done = 1; + fprintf(stderr, "WARNING! Inodes are not persistent for disks: '%s'", disk->name); + } else { + fprintf(stderr, ", '%s", disk->name); } } - if (done) { - fprintf(stderr, ". Move operations won't be optimal (but you can live with that).\n"); - } + } + if (done) { + fprintf(stderr, ". Move operations won't be optimal (but you can live with that).\n"); } - /* Check for disks with changed UUID */ - { - int done = 0; - for(i=state->disklist;i!=0;i=i->next) { - struct snapraid_disk* disk = i->data; + /* checks for disks with changed UUID */ + done = 0; + for(i=state->disklist;i!=0;i=i->next) { + struct snapraid_disk* disk = i->data; - /* don't print the message if the UUID changed because before */ - /* it was no set. */ - /* this is the normal condition for an empty disk because it */ - /* isn't stored */ - if (disk->has_different_uuid && !disk->had_empty_uuid) { - if (!done) { - done = 1; - fprintf(stderr, "WARNING! UUID is changed for disks: '%s'", disk->name); - } else { - fprintf(stderr, ", '%s", disk->name); - } + /* don't print the message if the UUID changed because before */ + /* it was no set. */ + /* this is the normal condition for an empty disk because it */ + /* isn't stored */ + if (disk->has_different_uuid && !disk->had_empty_uuid) { + if (!done) { + done = 1; + fprintf(stderr, "WARNING! UUID is changed for disks: '%s'", disk->name); + } else { + fprintf(stderr, ", '%s", disk->name); } } - if (done) { - fprintf(stderr, ". Move operations won't be optimal (but you can live with that).\n"); + } + if (done) { + fprintf(stderr, ". Move operations won't be optimal (but you can live with that).\n"); + } + + /* checks for disks with unsupported UUID */ + done = 0; + for(i=state->disklist;i!=0;i=i->next) { + struct snapraid_disk* disk = i->data; + + if (disk->has_unsupported_uuid) { + if (!done) { + done = 1; + fprintf(stderr, "WARNING! UUID is unsupported for disks: '%s'", disk->name); + } else { + fprintf(stderr, ", '%s", disk->name); + } } } + if (done) { + fprintf(stderr, ". Move operations won't be optimal (but you can live with that).\n"); + } + if (state->opt.verbose || output) { struct snapraid_scan total; diff --git a/cmdline/state.c b/cmdline/state.c index 280af8a8..3a176fbd 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -994,8 +994,8 @@ static void state_map(struct snapraid_state* state) ret = devuuid(disk->device, uuid, sizeof(uuid)); if (ret != 0) { - /* uuid not available, just ignore but marks the disk with not persistent UUID */ - disk->has_different_uuid = 1; + /* uuid not available, just ignore but marks the disk with unsupported UUID */ + disk->has_unsupported_uuid = 1; continue; }