From 46835c1dcc9ab3eca8be681d7f43a9575f10d7e5 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Tue, 11 Aug 2015 23:04:27 +0000 Subject: OS-3620 sdev can create bogus zvol directories Reviewed by: Robert Mustacchi --- usr/src/uts/common/fs/dev/sdev_zvolops.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/common/fs/dev/sdev_zvolops.c b/usr/src/uts/common/fs/dev/sdev_zvolops.c index 85d9ab64cb..3fa98b3124 100644 --- a/usr/src/uts/common/fs/dev/sdev_zvolops.c +++ b/usr/src/uts/common/fs/dev/sdev_zvolops.c @@ -197,8 +197,13 @@ devzvol_objset_check(char *dsname, dmu_objset_type_t *type) } /* - * returns what the zfs dataset name should be, given the /dev/zvol - * path and an optional name; otherwise NULL + * Returns what the zfs dataset name should be, given the /dev/zvol + * path and an optional name (can be NULL). + * + * Note that if the name param is NULL, then path must be an + * actual dataset's directory and not one of the top-level + * /dev/zvol/{dsk,rdsk} dirs, as these do not correspond to a + * specific dataset. */ char * devzvol_make_dsname(const char *path, const char *name) @@ -218,8 +223,11 @@ devzvol_make_dsname(const char *path, const char *name) ptr += strlen("/rdsk"); else return (NULL); + if (*ptr == '/') ptr++; + else if (name == NULL) + return (NULL); dslen = strlen(ptr); if (dslen) -- cgit v1.2.3