Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: Driver-Core: extend devnode callbacks to provide permissions
This commit is contained in:
@@ -153,7 +153,7 @@ static const struct file_operations rng_chrdev_ops = {
|
||||
static struct miscdevice rng_miscdev = {
|
||||
.minor = RNG_MISCDEV_MINOR,
|
||||
.name = RNG_MODULE_NAME,
|
||||
.devnode = "hwrng",
|
||||
.nodename = "hwrng",
|
||||
.fops = &rng_chrdev_ops,
|
||||
};
|
||||
|
||||
|
@@ -866,24 +866,25 @@ static const struct file_operations kmsg_fops = {
|
||||
|
||||
static const struct memdev {
|
||||
const char *name;
|
||||
mode_t mode;
|
||||
const struct file_operations *fops;
|
||||
struct backing_dev_info *dev_info;
|
||||
} devlist[] = {
|
||||
[ 1] = { "mem", &mem_fops, &directly_mappable_cdev_bdi },
|
||||
[1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi },
|
||||
#ifdef CONFIG_DEVKMEM
|
||||
[ 2] = { "kmem", &kmem_fops, &directly_mappable_cdev_bdi },
|
||||
[2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi },
|
||||
#endif
|
||||
[ 3] = {"null", &null_fops, NULL },
|
||||
[3] = { "null", 0666, &null_fops, NULL },
|
||||
#ifdef CONFIG_DEVPORT
|
||||
[ 4] = { "port", &port_fops, NULL },
|
||||
[4] = { "port", 0, &port_fops, NULL },
|
||||
#endif
|
||||
[ 5] = { "zero", &zero_fops, &zero_bdi },
|
||||
[ 7] = { "full", &full_fops, NULL },
|
||||
[ 8] = { "random", &random_fops, NULL },
|
||||
[ 9] = { "urandom", &urandom_fops, NULL },
|
||||
[11] = { "kmsg", &kmsg_fops, NULL },
|
||||
[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 },
|
||||
[11] = { "kmsg", 0, &kmsg_fops, NULL },
|
||||
#ifdef CONFIG_CRASH_DUMP
|
||||
[12] = { "oldmem", &oldmem_fops, NULL },
|
||||
[12] = { "oldmem", 0, &oldmem_fops, NULL },
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -920,6 +921,13 @@ static const struct file_operations memory_fops = {
|
||||
.open = memory_open,
|
||||
};
|
||||
|
||||
static char *mem_devnode(struct device *dev, mode_t *mode)
|
||||
{
|
||||
if (mode && devlist[MINOR(dev->devt)].mode)
|
||||
*mode = devlist[MINOR(dev->devt)].mode;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct class *mem_class;
|
||||
|
||||
static int __init chr_dev_init(void)
|
||||
@@ -935,6 +943,7 @@ static int __init chr_dev_init(void)
|
||||
printk("unable to get major %d for memory devs\n", MEM_MAJOR);
|
||||
|
||||
mem_class = class_create(THIS_MODULE, "mem");
|
||||
mem_class->devnode = mem_devnode;
|
||||
for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) {
|
||||
if (!devlist[minor].name)
|
||||
continue;
|
||||
|
@@ -263,12 +263,14 @@ int misc_deregister(struct miscdevice *misc)
|
||||
EXPORT_SYMBOL(misc_register);
|
||||
EXPORT_SYMBOL(misc_deregister);
|
||||
|
||||
static char *misc_nodename(struct device *dev)
|
||||
static char *misc_devnode(struct device *dev, mode_t *mode)
|
||||
{
|
||||
struct miscdevice *c = dev_get_drvdata(dev);
|
||||
|
||||
if (c->devnode)
|
||||
return kstrdup(c->devnode, GFP_KERNEL);
|
||||
if (mode && c->mode)
|
||||
*mode = c->mode;
|
||||
if (c->nodename)
|
||||
return kstrdup(c->nodename, GFP_KERNEL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -287,7 +289,7 @@ static int __init misc_init(void)
|
||||
err = -EIO;
|
||||
if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
|
||||
goto fail_printk;
|
||||
misc_class->nodename = misc_nodename;
|
||||
misc_class->devnode = misc_devnode;
|
||||
return 0;
|
||||
|
||||
fail_printk:
|
||||
|
@@ -261,7 +261,7 @@ static const struct file_operations raw_ctl_fops = {
|
||||
|
||||
static struct cdev raw_cdev;
|
||||
|
||||
static char *raw_nodename(struct device *dev)
|
||||
static char *raw_devnode(struct device *dev, mode_t *mode)
|
||||
{
|
||||
return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev));
|
||||
}
|
||||
@@ -289,7 +289,7 @@ static int __init raw_init(void)
|
||||
ret = PTR_ERR(raw_class);
|
||||
goto error_region;
|
||||
}
|
||||
raw_class->nodename = raw_nodename;
|
||||
raw_class->devnode = raw_devnode;
|
||||
device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
|
||||
|
||||
return 0;
|
||||
|
@@ -3070,11 +3070,22 @@ void __init console_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static char *tty_devnode(struct device *dev, mode_t *mode)
|
||||
{
|
||||
if (!mode)
|
||||
return NULL;
|
||||
if (dev->devt == MKDEV(TTYAUX_MAJOR, 0) ||
|
||||
dev->devt == MKDEV(TTYAUX_MAJOR, 2))
|
||||
*mode = 0666;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int __init tty_class_init(void)
|
||||
{
|
||||
tty_class = class_create(THIS_MODULE, "tty");
|
||||
if (IS_ERR(tty_class))
|
||||
return PTR_ERR(tty_class);
|
||||
tty_class->devnode = tty_devnode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user