]> granicus.if.org Git - zfs/commitdiff
Improve zvol symlink handling.
authorDan Swartzendruber <dswartz@druber.com>
Wed, 29 Oct 2014 01:29:53 +0000 (21:29 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 6 Nov 2014 19:13:18 +0000 (11:13 -0800)
Change the zvol helper program to replace any embedded spaces
in the pool or dataset names with '+' to ensure we have valid
symlinks.

The '+' character was choosen because it is not a valid character
for a dataset name but it is allowed by udev.  This ensures that
all dataset names with an embedded space will be translated to
a unique /dev/zvol/ symlink.

Signed-off-by: Dan Swartzendruber <dswartz@druber.com>
Signed-off-by: Darik Horn <dajhorn@vanadac.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2834

cmd/zvol_id/zvol_id_main.c

index d9c80b3f90f7549b9d605347a1d57a1f2c492d90..8f0504ae999240e16479c5ee532d12d1ae5a7a06 100644 (file)
@@ -23,6 +23,8 @@
  * Use is subject to license terms.
  */
 
+#include <ctype.h>
+#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
@@ -56,6 +58,7 @@ main(int argc, char **argv)
        char *dev_name;
        struct stat64 statbuf;
        int dev_minor, dev_part;
+       int i;
 
        if (argc < 2) {
                printf("Usage: %s /dev/zvol_device_node\n", argv[0]);
@@ -89,6 +92,11 @@ main(int argc, char **argv)
        else
                snprintf(zvol_name_part, ZFS_MAXNAMELEN, "%s", zvol_name);
 
+       for (i = 0; i < strlen(zvol_name_part); i++) {
+               if (isblank(zvol_name_part[i]))
+                       zvol_name_part[i] = '+';
+       }
+
        printf("%s\n", zvol_name_part);
        close(fd);
        return (error);