summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorMike Gerdts <mike.gerdts@joyent.com>2017-12-30 00:11:14 +0000
committerMike Gerdts <mike.gerdts@joyent.com>2018-02-15 17:30:48 +0000
commitde818a9daccca7db99174202eb0e91352a54720e (patch)
tree3137d378f9db92595f26e4d34449882ea34c9e45 /usr/src
parent9b5f494dc07544fd40038466910d2c20c16406ea (diff)
downloadillumos-joyent-de818a9daccca7db99174202eb0e91352a54720e.tar.gz
OS-6545 need sdev_ctx_minor()
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/fs/dev/sdev_plugin.c38
-rw-r--r--usr/src/uts/common/io/vnd/vnd.c10
-rw-r--r--usr/src/uts/common/sys/fs/sdev_plugin.h4
3 files changed, 23 insertions, 29 deletions
diff --git a/usr/src/uts/common/fs/dev/sdev_plugin.c b/usr/src/uts/common/fs/dev/sdev_plugin.c
index 885191175f..bca7325bfb 100644
--- a/usr/src/uts/common/fs/dev/sdev_plugin.c
+++ b/usr/src/uts/common/fs/dev/sdev_plugin.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2018, Joyent, Inc.
*/
/*
@@ -145,40 +145,32 @@ sdev_ctx_name(sdev_ctx_t ctx)
return (sdp->sdev_name);
}
-/*
- * Currently we only support psasing through a single flag -- SDEV_IS_GLOBAL.
- */
-sdev_ctx_flags_t
-sdev_ctx_flags(sdev_ctx_t ctx)
+int
+sdev_ctx_minor(sdev_ctx_t ctx, minor_t *minorp)
{
sdev_node_t *sdp = (sdev_node_t *)ctx;
ASSERT(RW_LOCK_HELD(&sdp->sdev_contents));
- return (sdp->sdev_flags & SDEV_GLOBAL);
+ ASSERT(minorp != NULL);
+ if (sdp->sdev_vnode->v_type == VCHR ||
+ sdp->sdev_vnode->v_type == VBLK) {
+ *minorp = getminor(sdp->sdev_vnode->v_rdev);
+ return (0);
+ }
+
+ return (ENODEV);
}
/*
- * Return some amount of private data specific to the vtype. In the case of a
- * character or block device this is the device number.
+ * Currently we only support psasing through a single flag -- SDEV_IS_GLOBAL.
*/
-const void *
-sdev_ctx_vtype_data(sdev_ctx_t ctx)
+sdev_ctx_flags_t
+sdev_ctx_flags(sdev_ctx_t ctx)
{
sdev_node_t *sdp = (sdev_node_t *)ctx;
- void *ret;
ASSERT(RW_LOCK_HELD(&sdp->sdev_contents));
- switch (sdp->sdev_vnode->v_type) {
- case VCHR:
- case VBLK:
- ret = (void *)(uintptr_t)(sdp->sdev_vnode->v_rdev);
- break;
- default:
- ret = NULL;
- break;
- }
-
- return (ret);
+ return (sdp->sdev_flags & SDEV_GLOBAL);
}
/*
diff --git a/usr/src/uts/common/io/vnd/vnd.c b/usr/src/uts/common/io/vnd/vnd.c
index 27fdba6f91..5766b39692 100644
--- a/usr/src/uts/common/io/vnd/vnd.c
+++ b/usr/src/uts/common/io/vnd/vnd.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright 2017 Joyent, Inc.
+ * Copyright (c) 2018, Joyent, Inc.
*/
/*
@@ -5361,8 +5361,8 @@ static sdev_plugin_validate_t
vnd_sdev_validate(sdev_ctx_t ctx)
{
enum vtype vt;
- dev_t dev;
vnd_dev_t *vdp;
+ minor_t minor;
vt = sdev_ctx_vtype(ctx);
if (vt == VDIR)
@@ -5372,8 +5372,10 @@ vnd_sdev_validate(sdev_ctx_t ctx)
if (strcmp("ctl", sdev_ctx_name(ctx)) == 0)
return (SDEV_VTOR_VALID);
- dev = (uintptr_t)sdev_ctx_vtype_data(ctx);
- vdp = vnd_dev_lookup(getminor(dev));
+ if (sdev_ctx_minor(ctx, &minor) != 0)
+ return (SDEV_VTOR_STALE);
+
+ vdp = vnd_dev_lookup(minor);
if (vdp == NULL)
return (SDEV_VTOR_STALE);
diff --git a/usr/src/uts/common/sys/fs/sdev_plugin.h b/usr/src/uts/common/sys/fs/sdev_plugin.h
index 8783df58e6..f4ed813c1e 100644
--- a/usr/src/uts/common/sys/fs/sdev_plugin.h
+++ b/usr/src/uts/common/sys/fs/sdev_plugin.h
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (c) 2014 Joyent, Inc. All rights reserved.
+ * Copyright (c) 2018, Joyent, Inc.
*/
#ifndef _SYS_SDEV_PLUGIN_H
@@ -88,8 +88,8 @@ typedef enum sdev_ctx_flags {
extern sdev_ctx_flags_t sdev_ctx_flags(sdev_ctx_t);
extern const char *sdev_ctx_name(sdev_ctx_t);
extern const char *sdev_ctx_path(sdev_ctx_t);
+extern int sdev_ctx_minor(sdev_ctx_t, minor_t *);
extern enum vtype sdev_ctx_vtype(sdev_ctx_t);
-extern const void *sdev_ctx_vtype_data(sdev_ctx_t);
/*
* Callbacks to manipulate nodes