From f510bf3e4208e7537bae856115d1aa610a2a1ac6 Mon Sep 17 00:00:00 2001 From: YONETANI Tomokazu Date: Mon, 22 Feb 2010 07:36:59 +0900 Subject: [PATCH] HAMMER Utility - Fix snapshots migration for non-default directories 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sbin/hammer/cmd_cleanup.c b/sbin/hammer/cmd_cleanup.c index 4bee7ea134..8075324d95 100644 --- a/sbin/hammer/cmd_cleanup.c +++ b/sbin/hammer/cmd_cleanup.c @@ -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); } } -- 2.41.0