HAMMER Utility - Fix snapshots migration for non-default directories
authorYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Sun, 21 Feb 2010 22:36:59 +0000 (07:36 +0900)
committerYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Sun, 21 Feb 2010 22:36:59 +0000 (07:36 +0900)
Snapshots migration failed if the snapshots directory contained hyphens
or dots.  Also catch the case when it couldn't parse the name of a snapshot
symlink and give the operator a clue.

sbin/hammer/cmd_cleanup.c

index 4bee7ea..8075324 100644 (file)
@@ -617,7 +617,11 @@ migrate_one_snapshot(int fd, const char *fpath,
                t = (time_t)-1;
                tid = (hammer_tid_t)(int64_t)-1;
 
-               ptr = fpath;
+               /* fpath may contain directory components */
+               if ((ptr = strrchr(fpath, '/')) != NULL)
+                       ++ptr;
+               else
+                       ptr = fpath;
                while (*ptr && *ptr != '-' && *ptr != '.')
                        ++ptr;
                if (*ptr)
@@ -649,6 +653,9 @@ migrate_one_snapshot(int fd, const char *fpath,
                        snprintf(snap->label, sizeof(snap->label),
                                 "migrated");
                        ++snapshot->count;
+               } else {
+                       printf("    non-canonical snapshot softlink: %s->%s\n",
+                              fpath, linkbuf);
                }
        }