From f8a108fb1b0a6a6f4cd533e9fa0b110ef124160d Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 19 Aug 2017 12:06:48 -0700 Subject: [PATCH] hammer2 - Refactor snapshot frontend * We can no longer snapshot a subdirectory (due to inodes being indexed under the root and no longer embedded in directories), so simply snapshot naming. * Name snapshots only after their PFS label plus the date and time. * Flesh out command help --- sbin/hammer2/cmd_snapshot.c | 11 +---------- sbin/hammer2/main.c | 4 ++++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/sbin/hammer2/cmd_snapshot.c b/sbin/hammer2/cmd_snapshot.c index 37fdc50f94..4b13f1b146 100644 --- a/sbin/hammer2/cmd_snapshot.c +++ b/sbin/hammer2/cmd_snapshot.c @@ -58,23 +58,15 @@ cmd_pfs_snapshot(const char *sel_path, const char *path, const char *label) int ecode = 0; int fd; char filename[HAMMER2_INODE_MAXNAME]; - char *xname; time_t t; struct tm *tp; if (path == NULL) { fd = hammer2_ioctl_handle(sel_path); - xname = strdup(""); } else { fd = open(path, O_RDONLY); if (fd < 0) fprintf(stderr, "Unable to open %s\n", path); - if (strrchr(path, '/')) - asprintf(&xname, ".%s", strrchr(path, '/') + 1); - else if (*path) - asprintf(&xname, ".%s", path); - else - xname = strdup(""); } if (fd < 0) return 1; @@ -88,9 +80,8 @@ cmd_pfs_snapshot(const char *sel_path, const char *path, const char *label) perror("ioctl"); } snprintf(filename, sizeof(filename), - "%s%s.%04d%02d%02d.%02d%02d%02d", + "%s.%04d%02d%02d.%02d%02d%02d", pfs.name, - xname, tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday, diff --git a/sbin/hammer2/main.c b/sbin/hammer2/main.c index 520ed55f64..ad6b1b6277 100644 --- a/sbin/hammer2/main.c +++ b/sbin/hammer2/main.c @@ -460,6 +460,10 @@ usage(int code) "\n" " connect " "Add cluster link\n" + " debugspan " + "Debug spanning tree\n" + " chaindump " + "Dump in-memory chain topo at\n" " disconnect " "Del cluster link\n" " hash filename* " -- 2.11.4.GIT