Messages in this thread Patch in this message | | | From | Seth Forshee <> | Subject | [RFC PATCH 06/11] drivers/char/mem.c: Make null/zero/full/random/urandom available to user namespaces | Date | Wed, 14 May 2014 16:34:54 -0500 |
| |
Signed-off-by: Seth Forshee <seth.forshee@canonical.com> --- drivers/char/mem.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 917403fe10da..edd71ebf5025 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -811,21 +811,22 @@ static const struct memdev { umode_t mode; const struct file_operations *fops; struct backing_dev_info *dev_info; + bool global; } devlist[] = { - [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi }, + [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi, false }, #ifdef CONFIG_DEVKMEM - [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi }, + [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi, false }, #endif - [3] = { "null", 0666, &null_fops, NULL }, + [3] = { "null", 0666, &null_fops, NULL, true }, #ifdef CONFIG_DEVPORT - [4] = { "port", 0, &port_fops, NULL }, + [4] = { "port", 0, &port_fops, NULL, false }, #endif - [5] = { "zero", 0666, &zero_fops, &zero_bdi }, - [7] = { "full", 0666, &full_fops, NULL }, - [8] = { "random", 0666, &random_fops, NULL }, - [9] = { "urandom", 0666, &urandom_fops, NULL }, + [5] = { "zero", 0666, &zero_fops, &zero_bdi, true }, + [7] = { "full", 0666, &full_fops, NULL, true }, + [8] = { "random", 0666, &random_fops, NULL, true }, + [9] = { "urandom", 0666, &urandom_fops, NULL, true }, #ifdef CONFIG_PRINTK - [11] = { "kmsg", 0644, &kmsg_fops, NULL }, + [11] = { "kmsg", 0644, &kmsg_fops, NULL, false }, #endif }; @@ -897,8 +898,13 @@ static int __init chr_dev_init(void) if ((minor == DEVPORT_MINOR) && !arch_has_dev_port()) continue; - device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor), - NULL, devlist[minor].name); + if (devlist[minor].global) + device_create_global(mem_class, NULL, + MKDEV(MEM_MAJOR, minor), NULL, + devlist[minor].name); + else + device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor), + NULL, devlist[minor].name); } return tty_init(); -- 1.9.1
| |