Fix a string parsing bug when trying to run hammer pfs-master on a
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 30 Jan 2009 16:46:38 +0000 (08:46 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 30 Jan 2009 16:46:38 +0000 (08:46 -0800)
subdirectory of the root directory, e.g. "hammer pfs-master /fubar".

Reported-by: "Simon 'corecode' Schubert" <corecode@fs.ei.tum.de>
sbin/hammer/cmd_pseudofs.c

index eb58454..67933ec 100644 (file)
@@ -207,9 +207,17 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave)
                exit(1);
        }
 
+       /*
+        * Figure out the directory prefix, taking care of degenerate
+        * cases.
+        */
        dirpath = strdup(path);
        if (strrchr(dirpath, '/') != NULL) {
                *strrchr(dirpath, '/') = 0;
+               if (dirpath[0] == 0) {
+                       free(dirpath);
+                       dirpath = strdup("/");
+               }
        } else {
                free(dirpath);
                dirpath = strdup(".");