lkml.org 
[lkml]   [2014]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 09/11] misc: Make loop-control available to all user namespaces
Date
Add a ns_global field to struct miscdevice to allow indicating
that the created struct device should be global to all user
namespaces, and set this flag for loop-control.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
drivers/block/loop.c | 1 +
drivers/char/misc.c | 11 +++++++++--
include/linux/miscdevice.h | 1 +
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index f70a230a2945..f0e41a372c24 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1813,6 +1813,7 @@ static struct miscdevice loop_misc = {
.minor = LOOP_CTRL_MINOR,
.name = "loop-control",
.fops = &loop_ctl_fops,
+ .ns_global = true,
};

MODULE_ALIAS_MISCDEV(LOOP_CTRL_MINOR);
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index ffa97d261cf3..5940ebd98023 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -205,8 +205,15 @@ int misc_register(struct miscdevice * misc)

dev = MKDEV(MISC_MAJOR, misc->minor);

- misc->this_device = device_create(misc_class, misc->parent, dev,
- misc, "%s", misc->name);
+ if (misc->ns_global)
+ misc->this_device = device_create_global(misc_class,
+ misc->parent, dev,
+ misc, "%s",
+ misc->name);
+ else
+ misc->this_device = device_create(misc_class, misc->parent, dev,
+ misc, "%s", misc->name);
+
if (IS_ERR(misc->this_device)) {
int i = DYNAMIC_MINORS - misc->minor - 1;
if (i < DYNAMIC_MINORS && i >= 0)
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 51e26f3cd3b3..a85782339fe2 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -62,6 +62,7 @@ struct miscdevice {
struct device *this_device;
const char *nodename;
umode_t mode;
+ bool ns_global;
};

extern int misc_register(struct miscdevice * misc);
--
1.9.1


\
 
 \ /
  Last update: 2014-05-15 00:21    [W:0.179 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site