sbin/hammer: Change assertion on invalid cleanup path to printf
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 5 Dec 2015 17:43:45 +0000 (02:43 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 6 Dec 2015 16:41:50 +0000 (01:41 +0900)
This shouldn't be assertion.
Users could just type . for no reason and result in core dump.
It should end like other errors as shown below.

  # hammer cleanup . . . . .
  cleanup .                    - path must start with '/'
  cleanup .                    - PFS #0 already handled
  cleanup .                    - PFS #0 already handled
  cleanup .                    - PFS #0 already handled
  cleanup .                    - PFS #0 already handled

sbin/hammer/cmd_cleanup.c

index 0844ede..1ebf134 100644 (file)
@@ -340,7 +340,10 @@ do_cleanup(const char *path)
        if (new_config && snapshots_from_pfs == 0) {
                char *npath;
 
-               assert(path[0] == '/');
+               if (path[0] != '/') {
+                       printf(" path must start with '/'\n");
+                       return;
+               }
                if (strcmp(path, "/") == 0)
                        asprintf(&npath, "%s/root", SNAPSHOTS_BASE);
                else