summaryrefslogtreecommitdiffstats
path: root/cmd/zvol_id
diff options
context:
space:
mode:
authorDan Swartzendruber <[email protected]>2014-10-28 21:29:53 -0400
committerBrian Behlendorf <[email protected]>2014-11-06 11:13:18 -0800
commit5f91bd3dea49a529e87e0aa39595f074fd09736a (patch)
treef303ca549a14c998e55024070a0b5237ae6fb8b9 /cmd/zvol_id
parent11662bf969b3503b66d5ccd81d024c0f4473100c (diff)
Improve zvol symlink handling.
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 <[email protected]> Signed-off-by: Darik Horn <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2834
Diffstat (limited to 'cmd/zvol_id')
-rw-r--r--cmd/zvol_id/zvol_id_main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/zvol_id/zvol_id_main.c b/cmd/zvol_id/zvol_id_main.c
index d9c80b3f9..8f0504ae9 100644
--- a/cmd/zvol_id/zvol_id_main.c
+++ b/cmd/zvol_id/zvol_id_main.c
@@ -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);