diff options
Diffstat (limited to 'drivers/char/mem.c')
| -rw-r--r-- | drivers/char/mem.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 0491cdf63f2a..0aede1d6a9ea 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
| @@ -866,24 +866,25 @@ static const struct file_operations kmsg_fops = { | |||
| 866 | 866 | ||
| 867 | static const struct memdev { | 867 | static const struct memdev { |
| 868 | const char *name; | 868 | const char *name; |
| 869 | mode_t mode; | ||
| 869 | const struct file_operations *fops; | 870 | const struct file_operations *fops; |
| 870 | struct backing_dev_info *dev_info; | 871 | struct backing_dev_info *dev_info; |
| 871 | } devlist[] = { | 872 | } devlist[] = { |
| 872 | [ 1] = { "mem", &mem_fops, &directly_mappable_cdev_bdi }, | 873 | [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi }, |
| 873 | #ifdef CONFIG_DEVKMEM | 874 | #ifdef CONFIG_DEVKMEM |
| 874 | [ 2] = { "kmem", &kmem_fops, &directly_mappable_cdev_bdi }, | 875 | [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi }, |
| 875 | #endif | 876 | #endif |
| 876 | [ 3] = {"null", &null_fops, NULL }, | 877 | [3] = { "null", 0666, &null_fops, NULL }, |
| 877 | #ifdef CONFIG_DEVPORT | 878 | #ifdef CONFIG_DEVPORT |
| 878 | [ 4] = { "port", &port_fops, NULL }, | 879 | [4] = { "port", 0, &port_fops, NULL }, |
| 879 | #endif | 880 | #endif |
| 880 | [ 5] = { "zero", &zero_fops, &zero_bdi }, | 881 | [5] = { "zero", 0666, &zero_fops, &zero_bdi }, |
| 881 | [ 7] = { "full", &full_fops, NULL }, | 882 | [7] = { "full", 0666, &full_fops, NULL }, |
| 882 | [ 8] = { "random", &random_fops, NULL }, | 883 | [8] = { "random", 0666, &random_fops, NULL }, |
| 883 | [ 9] = { "urandom", &urandom_fops, NULL }, | 884 | [9] = { "urandom", 0666, &urandom_fops, NULL }, |
| 884 | [11] = { "kmsg", &kmsg_fops, NULL }, | 885 | [11] = { "kmsg", 0, &kmsg_fops, NULL }, |
| 885 | #ifdef CONFIG_CRASH_DUMP | 886 | #ifdef CONFIG_CRASH_DUMP |
| 886 | [12] = { "oldmem", &oldmem_fops, NULL }, | 887 | [12] = { "oldmem", 0, &oldmem_fops, NULL }, |
| 887 | #endif | 888 | #endif |
| 888 | }; | 889 | }; |
| 889 | 890 | ||
| @@ -920,6 +921,13 @@ static const struct file_operations memory_fops = { | |||
| 920 | .open = memory_open, | 921 | .open = memory_open, |
| 921 | }; | 922 | }; |
| 922 | 923 | ||
| 924 | static char *mem_devnode(struct device *dev, mode_t *mode) | ||
| 925 | { | ||
| 926 | if (mode && devlist[MINOR(dev->devt)].mode) | ||
| 927 | *mode = devlist[MINOR(dev->devt)].mode; | ||
| 928 | return NULL; | ||
| 929 | } | ||
| 930 | |||
| 923 | static struct class *mem_class; | 931 | static struct class *mem_class; |
| 924 | 932 | ||
| 925 | static int __init chr_dev_init(void) | 933 | static int __init chr_dev_init(void) |
| @@ -935,6 +943,7 @@ static int __init chr_dev_init(void) | |||
| 935 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); | 943 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); |
| 936 | 944 | ||
| 937 | mem_class = class_create(THIS_MODULE, "mem"); | 945 | mem_class = class_create(THIS_MODULE, "mem"); |
| 946 | mem_class->devnode = mem_devnode; | ||
| 938 | for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { | 947 | for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { |
| 939 | if (!devlist[minor].name) | 948 | if (!devlist[minor].name) |
| 940 | continue; | 949 | continue; |
