DevFS support for /dev/cpu/X/(cpuid|msr)
PATCH 1/1 DevFS support for /dev/cpu/X/(cpuid|msr)
Hi,
Please find attached a patch to add support for devfs to the i386 cpuid and msr drivers. Not only that, but it fixes a problem with loading these drivers as modules in that the exit hooks on the module never run, (simply changing the function prototypes to include 'static' seems to fix this).
Patch is against 2.4.17. SMP environment isn't tested, but I can't see any reason why it wouldn't work...
Cheers
Matt
Signature · 2 lines
"Phased plasma rifle in a forty-watt range?" "Hey, just what you see, pal"
arch/i386/kernel/cpuid.c +35 -5
@@ -23,6 +23,11 @@* * This driver uses /dev/cpu/%d/cpuid where %d is the minor number, and on * an SMP box will direct the access to CPU %d. +* +* ChangeLog +* +* 2002-01-06 Matt Dainty <[email protected]> +* Added support for devfs */ #include <linux/module.h>
@@ -35,12 +40,16 @@#include <linux/poll.h> #include <linux/smp.h> #include <linux/major.h> +#include <linux/threads.h> +#include <linux/devfs_fs_kernel.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/uaccess.h> #include <asm/system.h> +static devfs_handle_t devfs_handle[NR_CPUS ]; +#ifdef CONFIG_SMP struct cpuid_command {
@@ -140,24 +149,45 @@ open: cpuid_open, }; -int __init cpuid_init (void ) +static int __init cpuid_init (void ) { -if (register_chrdev (CPUID_MAJOR ,"cpu/cpuid" , &cpuid_fops)) { +int i; +char name[16 ]; + +if (devfs_register_chrdev (CPUID_MAJOR ,"cpu/%d/cpuid" , &cpuid_fops)) {printk (KERN_ERR "cpuid: unable to get major %d for cpuid\n" ,CPUID_MAJOR );return -EBUSY ; } +for (i =0 ; i <NR_CPUS ; i++) { +sprintf (name,"cpu/%d/cpuid" , i); +if ((devfs_handle[i] =devfs_register (NULL , name,DEVFS_FL_DEFAULT , +CPUID_MAJOR , i, +S_IFCHR |S_IRUSR |S_IRGRP , + &cpuid_fops,NULL )) ==NULL ) { +printk (KERN_ERR "cpuid: failed to devfs_register()\n" ); + } + }return 0 ; } -void __exit cpuid_exit(void) +static void __exit cpuid_exit(void) { -unregister_chrdev (CPUID_MAJOR ,"cpu/cpuid" ); +int i; +devfs_handle_t parent; + +for (i =0 ; i <NR_CPUS ; i++) { + parent =devfs_get_parent (devfs_handle[i]); +devfs_unregister (devfs_handle[i]); +if (devfs_get_first_child (parent) ==NULL ) +devfs_unregister (parent); + } +devfs_unregister_chrdev (CPUID_MAJOR ,"cpu/%d/cpuid" ); }module_init (cpuid_init); -module_exit (cpuid_exit) +module_exit (cpuid_exit);EXPORT_NO_SYMBOLS ;
arch/i386/kernel/msr.c +35 -5
@@ -22,6 +22,11 @@* * This driver uses /dev/cpu/%d/msr where %d is the minor number, and on * an SMP box will direct the access to CPU %d. +* +* ChangeLog +* +* 2002-01-06 Matt Dainty <[email protected]> +* Added support for devfs */ #include <linux/module.h>
@@ -34,12 +39,16 @@#include <linux/poll.h> #include <linux/smp.h> #include <linux/major.h> +#include <linux/threads.h> +#include <linux/devfs_fs_kernel.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/uaccess.h> #include <asm/system.h> +static devfs_handle_t devfs_handle[NR_CPUS ]; +/* Note: "err" is handled in a funny way below. Otherwise one version of gcc or another breaks. */
@@ -248,24 +257,45 @@ open: msr_open, }; -int __init msr_init (void ) +static int __init msr_init (void ) { -if (register_chrdev (MSR_MAJOR ,"cpu/msr" , &msr_fops)) { +int i; +char name[16 ]; + +if (devfs_register_chrdev (MSR_MAJOR ,"cpu/%d/msr" , &msr_fops)) {printk (KERN_ERR "msr: unable to get major %d for msr\n" ,MSR_MAJOR );return -EBUSY ; } +for (i =0 ; i <NR_CPUS ; i++) { +sprintf (name,"cpu/%d/msr" , i); +if ((devfs_handle[i] =devfs_register (NULL , name,DEVFS_FL_DEFAULT , +MSR_MAJOR , i, +S_IFCHR |S_IRUSR |S_IRGRP |S_IWUSR , + &msr_fops,NULL )) ==NULL ) { +printk (KERN_ERR "msr: failed to devfs_register()\n" ); + } + }return 0 ; } -void __exit msr_exit(void) +static void __exit msr_exit(void) { -unregister_chrdev (MSR_MAJOR ,"cpu/msr" ); +int i; +devfs_handle_t parent; + +for (i =0 ; i <NR_CPUS ; i++) { + parent =devfs_get_parent (devfs_handle[i]); +devfs_unregister (devfs_handle[i]); +if (devfs_get_first_child (parent) ==NULL ) +devfs_unregister (parent); + } +devfs_unregister_chrdev (MSR_MAJOR ,"cpu/%d/msr" ); }module_init (msr_init); -module_exit (msr_exit) +module_exit (msr_exit);EXPORT_NO_SYMBOLS ;
Quoted 7 lines · Matt Dainty
Please find attached a patch to add support for devfs to the i386 cpuid and msr drivers. Not only that, but it fixes a problem with loading these drivers as modules in that the exit hooks on the module never run, (simply changing the function prototypes to include 'static' seems to fix this).
Patch is against 2.4.17. SMP environment isn't tested, but I can't see any reason why it wouldn't work...
Looks mostly reasonable, except for:
Quoted 5 lines
arch/i386/kernel/cpuid.c +2
-2-void __exit cpuid_exit(void) +static void __exit cpuid_exit(void) { -unregister_chrdev (CPUID_MAJOR ,"cpu/cpuid" ); +int i;
arch/i386/kernel/cpuid.c line 187
Quoted 10 lines
arch/i386/kernel/cpuid.c +9
-0+devfs_handle_t parent; + +for (i =0 ; i <NR_CPUS ; i++) { + parent =devfs_get_parent (devfs_handle[i]); +devfs_unregister (devfs_handle[i]); +if (devfs_get_first_child (parent) ==NULL ) +devfs_unregister (parent); + } +devfs_unregister_chrdev (CPUID_MAJOR ,"cpu/%d/cpuid" ); }
There is no need to remove the parent /dev/cpu/%d directory, and in fact it's better not to. All you need is this simpler loop:
for(i = 0; i < NR_CPUS; i++) devfs_unregister(devfs_handle[i]);
You do something similar in the MSR driver.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Okey dokey,
Please find attached a second, better patch to add devfs support to the i386 cpuid and msr drivers. Now it doesn't nuke the cpu/X directories on unloading and only enumerates CPUs based on smp_num_cpus instead of NR_CPUS.
Cheers
Matt
Signature · 2 lines
"Phased plasma rifle in a forty-watt range?" "Hey, just what you see, pal"
arch/i386/kernel/cpuid.c +30 -5
@@ -23,6 +23,11 @@* * This driver uses /dev/cpu/%d/cpuid where %d is the minor number, and on * an SMP box will direct the access to CPU %d. +* +* ChangeLog +* +* 2002-01-06 Matt Dainty <[email protected]> +* Added support for devfs */ #include <linux/module.h>
@@ -35,12 +40,16 @@#include <linux/poll.h> #include <linux/smp.h> #include <linux/major.h> +#include <linux/threads.h> +#include <linux/devfs_fs_kernel.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/uaccess.h> #include <asm/system.h> +static devfs_handle_t devfs_handle[NR_CPUS ]; +#ifdef CONFIG_SMP struct cpuid_command {
@@ -140,24 +149,40 @@ open: cpuid_open, }; -int __init cpuid_init (void ) +static int __init cpuid_init (void ) { -if (register_chrdev (CPUID_MAJOR ,"cpu/cpuid" , &cpuid_fops)) { +int i; +char name[16 ]; + +if (devfs_register_chrdev (CPUID_MAJOR ,"cpu/%d/cpuid" , &cpuid_fops)) {printk (KERN_ERR "cpuid: unable to get major %d for cpuid\n" ,CPUID_MAJOR );return -EBUSY ; } +for (i =0 ; i < smp_num_cpus; i++) { +sprintf (name,"cpu/%d/cpuid" , i); +if ((devfs_handle[i] =devfs_register (NULL , name,DEVFS_FL_DEFAULT , +CPUID_MAJOR , i, +S_IFCHR |S_IRUSR |S_IRGRP , + &cpuid_fops,NULL )) ==NULL ) { +printk (KERN_ERR "cpuid: failed to devfs_register()\n" ); + } + }return 0 ; } -void __exit cpuid_exit(void) +static void __exit cpuid_exit(void) { -unregister_chrdev (CPUID_MAJOR ,"cpu/cpuid" ); +int i; + +for (i =0 ; i < smp_num_cpus; i++) +devfs_unregister (devfs_handle[i]); +devfs_unregister_chrdev (CPUID_MAJOR ,"cpu/%d/cpuid" ); }module_init (cpuid_init); -module_exit (cpuid_exit) +module_exit (cpuid_exit);EXPORT_NO_SYMBOLS ;
arch/i386/kernel/msr.c +30 -5
@@ -22,6 +22,11 @@* * This driver uses /dev/cpu/%d/msr where %d is the minor number, and on * an SMP box will direct the access to CPU %d. +* +* ChangeLog +* +* 2002-01-06 Matt Dainty <[email protected]> +* Added support for devfs */ #include <linux/module.h>
@@ -34,12 +39,16 @@#include <linux/poll.h> #include <linux/smp.h> #include <linux/major.h> +#include <linux/threads.h> +#include <linux/devfs_fs_kernel.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/uaccess.h> #include <asm/system.h> +static devfs_handle_t devfs_handle[NR_CPUS ]; +/* Note: "err" is handled in a funny way below. Otherwise one version of gcc or another breaks. */
@@ -248,24 +257,40 @@ open: msr_open, }; -int __init msr_init (void ) +static int __init msr_init (void ) { -if (register_chrdev (MSR_MAJOR ,"cpu/msr" , &msr_fops)) { +int i; +char name[16 ]; + +if (devfs_register_chrdev (MSR_MAJOR ,"cpu/%d/msr" , &msr_fops)) {printk (KERN_ERR "msr: unable to get major %d for msr\n" ,MSR_MAJOR );return -EBUSY ; } +for (i =0 ; i < smp_num_cpus; i++) { +sprintf (name,"cpu/%d/msr" , i); +if ((devfs_handle[i] =devfs_register (NULL , name,DEVFS_FL_DEFAULT , +MSR_MAJOR , i, +S_IFCHR |S_IRUSR |S_IRGRP |S_IWUSR , + &msr_fops,NULL )) ==NULL ) { +printk (KERN_ERR "msr: failed to devfs_register()\n" ); + } + }return 0 ; } -void __exit msr_exit(void) +static void __exit msr_exit(void) { -unregister_chrdev (MSR_MAJOR ,"cpu/msr" ); +int i; + +for (i =0 ; i < smp_num_cpus; i++) +devfs_unregister (devfs_handle[i]); +devfs_unregister_chrdev (MSR_MAJOR ,"cpu/%d/msr" ); }module_init (msr_init); -module_exit (msr_exit) +module_exit (msr_exit);EXPORT_NO_SYMBOLS ;
Once again, this shit does not belong in N drivers; it is core code.
-hpa
Quoted 44 lines · Richard Gooch
Quoted 8 lines · Matt Dainty
Please find attached a patch to add support for devfs to the i386 cpuid and msr drivers. Not only that, but it fixes a problem with loading these drivers as modules in that the exit hooks on the module never run, (simply changing the function prototypes to include 'static' seems to fix this).
Patch is against 2.4.17. SMP environment isn't tested, but I can't see any reason why it wouldn't work...
Looks mostly reasonable, except for:
Quoted 14 lines
arch/i386/kernel/cpuid.c +1
-1-void __exit cpuid_exit(void) +static void __exit cpuid_exit(void){
arch/i386/kernel/cpuid.c +10
-1-unregister_chrdev (CPUID_MAJOR ,"cpu/cpuid" ); +int i; +devfs_handle_t parent; + +for (i =0 ; i <NR_CPUS ; i++) { + parent =devfs_get_parent (devfs_handle[i]); +devfs_unregister (devfs_handle[i]); +if (devfs_get_first_child (parent) ==NULL ) +devfs_unregister (parent); + } +devfs_unregister_chrdev (CPUID_MAJOR ,"cpu/%d/cpuid" );Quoted 2 lines
}
There is no need to remove the parent /dev/cpu/%d directory, and in fact it's better not to. All you need is this simpler loop:
for(i = 0; i < NR_CPUS; i++) devfs_unregister(devfs_handle[i]);You do something similar in the MSR driver.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 1 line · H. Peter Anvin
Once again, this shit does not belong in N drivers; it is core code.
Drivers have to register their own device nodes. What kind of API do you propose?
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 6 lines · Matt Dainty
Okey dokey,
Please find attached a second, better patch to add devfs support to the i386 cpuid and msr drivers. Now it doesn't nuke the cpu/X directories on unloading and only enumerates CPUs based on
smp_num_cpusinstead ofNR_CPUS.
If you don't understand why this is idiotic, then let me enlighten you: there is no sensible reason why /dev/cpu/%d should only be populated after having run a CPU-dependent device driver. /dev/cpu/%d should be always populated; heck, that's the only way you can sensibly handle hotswapping CPUs.
I WILL NOT accept a patch as long as devfs is as fucked in the head as it currently is. Unfortunately, that seems like it will be a long long time.
-hpa
Quoted 8 lines · H. Peter Anvin
Quoted 5 lines · Matt Dainty
Okey dokey,
Please find attached a second, better patch to add devfs support to the i386 cpuid and msr drivers. Now it doesn't nuke the cpu/X directories on unloading and only enumerates CPUs based on
smp_num_cpusinstead ofNR_CPUS.
Quoted 5 lines
If you don't understand why this is idiotic, then let me enlighten you:
there is no sensible reason why /dev/cpu/%d should only be populated after having run a CPU-dependent device driver. /dev/cpu/%d should be always populated; heck, that's the only way you can sensibly handle hotswapping CPUs.
I've already privately told Matt that it would be nice if creation of /dev/cpu/%d was handled by generic boot code, and not a driver. However, I don't see that as essential for the CPUID and MSR drivers.
Quoted 3 lines
I WILL NOT accept a patch as long as devfs is as fucked in the head as it currently is. Unfortunately, that seems like it will be a long long time.
No need to get rude.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 8 lines · Richard Gooch
Quoted 2 lines · H. Peter Anvin
Once again, this shit does not belong in N drivers; it is core code.
Drivers have to register their own device nodes. What kind of API do you propose?
The existence of a CPU creates /dev/cpu/# and registering a node replicates across the /dev/cpu directories.
-hpa
Quoted 4 lines · H. Peter Anvin
Quoted 2 lines · Richard Gooch
H. Peter Anvin writes:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Once again, this shit does not belong in N drivers; it is core code.
Drivers have to register their own device nodes. What kind of API do you propose?
The existence of a CPU creates /dev/cpu/# and registering a node replicates across the
/dev/cpudirectories.
So you mean something like this:
void devfs_per_cpu_register (const char *leafname, unsigned int flags,
unsigned int major, unsigned int minor_start, umode_t mode, void *ops);
void devfs_per_cpu_unregister (const char *leafname);
with code in the per-cpu boot code to create the /dev/cpu/%d directories.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 7 lines · Richard Gooch
Quoted 2 lines
Quoted 1 line
If you don't understand why this is idiotic, then let me enlighten you: there is no sensible reason why /dev/cpu/%d should only be populated after having run a CPU-dependent device driver. /dev/cpu/%d should be always populated; heck, that's the only way you can sensibly handle hotswapping CPUs.
I've already privately told Matt that it would be nice if creation of /dev/cpu/%d was handled by generic boot code, and not a driver. However, I don't see that as essential for the CPUID and MSR drivers.
I don't see putting a lot of devfs shit into the CPUID and MSR drivers as essential in any shape, way or form. Do it right or don't do it at all.
-hpa
Quoted 2 lines · H. Peter Anvin
The existence of a CPU creates /dev/cpu/# and registering a node replicates across the
/dev/cpudirectories.
And, thus, we decend into more /proc crappyness.
After *lots* of discussion and months of waiting, it was decided between Alan, David Jones, Jeff Garzik, and other affected parties that /proc/sys/cpu/#/whatever would be a reasonable. It has even appeared on lkml a couple of times in the past.
Currently, there is an allocated sysctl number in include/linux/sysctl.h for /proc/sys/cpu, and it is used by the cpufreq code to provide:
/proc/sys/cpu/#/speed
/proc/sys/cpu/#/speed-max
/proc/sys/cpu/#/speed-min
However, it's true that some of that needs to be pulled out so anything can use /proc/sys/cpu/#. Just takes the necessary parties to get together to do the hard work, and with the right hardware to test it out.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Quoted 5 lines · Russell King
Quoted 2 lines · H. Peter Anvin
The existence of a CPU creates /dev/cpu/# and registering a node replicates across the
/dev/cpudirectories.
Quoted 7 lines
And, thus, we decend into more /proc crappyness.
After *lots* of discussion and months of waiting, it was decided between Alan, David Jones, Jeff Garzik, and other affected parties that /proc/sys/cpu/#/whatever would be a reasonable. It has even appeared on lkml a couple of times in the past.
Ummm... this isn't about /proc.
-hpa
Quoted 12 lines · Richard Gooch
So you mean something like this:
void
devfs_per_cpu_register(const char *leafname, unsigned int flags,unsigned int major, unsigned int minor_start, umode_t mode, void *ops);void
devfs_per_cpu_unregister(const char *leafname);with code in the per-cpu boot code to create the /dev/cpu/%d directories.
Yes, that sounds like a good way to do it.
-hpa
Quoted 9 lines · H. Peter Anvin
Quoted 7 lines · Richard Gooch
So you mean something like this:
void
devfs_per_cpu_register(const char *leafname, unsigned int flags,unsigned int major, unsigned int minor_start, umode_t mode, void *ops);
Quoted 6 lines
Quoted 4 lines
void
devfs_per_cpu_unregister(const char *leafname);with code in the per-cpu boot code to create the /dev/cpu/%d directories.
Yes, that sounds like a good way to do it.
Unfortunately, there doesn't seem to be a really nice place to put generic SMP startup code. Each arch defines it's own per-cpu startup code. As Matt asked in a private email, it would require hacks to each arch to support this (Matt: this is my reply:-). While it would be fairly simple to add a call to a devfs_cpu_register() function to each arch, this does seem a bit hackish.
So I'd like to propose a new file (say kernel/smp.c) which has generic startup code for each CPU. To start with, it can have a generic_cpu_init() function, which is called by each arch. Note that this function would be called for the boot CPU too.
Comments?
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 8 lines · Richard Gooch
Unfortunately, there doesn't seem to be a really nice place to put generic SMP startup code. Each arch defines it's own per-cpu startup code. As Matt asked in a private email, it would require hacks to each arch to support this (Matt: this is my reply:-). While it would be fairly simple to add a call to a
devfs_cpu_register()function to each arch, this does seem a bit hackish.
Quoted 5 lines
So I'd like to propose a new file (say
kernel/smp.c) which has generic startup code for each CPU. To start with, it can have ageneric_cpu_init()function, which is called by each arch. Note that this function would be called for the boot CPU too.
Makes sense.
-hpa
Quoted 5 lines · Richard Gooch
So I'd like to propose a new file (say
kernel/smp.c) which has generic startup code for each CPU. To start with, it can have ageneric_cpu_init()function, which is called by each arch. Note that this function would be called for the boot CPU too.
Would this also be hacked into whatever Hotswap CPU support exists? Such that plugging in a new CPU spawns a new cpu/%d directory, (and removing one deletes the directory), or do we just scan for the total number of possible slots on boot and rely on any nodes to return -ENODEV or whatever when there's no CPU physically present? (Probably easier)
(Maybe not smp.c, as this is for Uniprocessor boxen as well, cpu.c? :-)
Matt
Signature · 2 lines
"Phased plasma rifle in a forty-watt range?" "Hey, just what you see, pal"
Quoted 8 lines · On Tue, 8 Jan 2002 11:13:02 +0000 Matt Dainty <[email protected]> wrote:
Quoted 5 lines · Richard Gooch
So I'd like to propose a new file (say
kernel/smp.c) which has generic startup code for each CPU. To start with, it can have ageneric_cpu_init()function, which is called by each arch. Note that this function would be called for the boot CPU too.Would this also be hacked into whatever Hotswap CPU support exists? Such
We use /proc/sys/cpu/#/. I don't understand what /dev/cpu/xxx is supposed to do.
It's unfortunate that /proc/sys and /proc suck so hard that good coders go to great lengths to do anything else [see previous /proc/sys patches].
Rusty.
Signature · 1 line
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 10 lines · Rusty Russell
Quoted 7 lines · On Tue, 8 Jan 2002 11:13:02 +0000 Matt Dainty <[email protected]> wrote:
Quoted 5 lines · Richard Gooch
So I'd like to propose a new file (say
kernel/smp.c) which has generic startup code for each CPU. To start with, it can have ageneric_cpu_init()function, which is called by each arch. Note that this function would be called for the boot CPU too.
Quoted 4 lines
Quoted 1 line
Would this also be hacked into whatever Hotswap CPU support exists? Such
We use /proc/sys/cpu/#/. I don't understand what
/dev/cpu/xxxis supposed to do.
/dev/cpu/[0...]/... contains (on i386 at least), the cpuid and msr character devices, except on devfs-enabled boxen, these don't appear automatically.
Matt
Signature · 2 lines
"Phased plasma rifle in a forty-watt range?" "Hey, just what you see, pal"
Quoted 4 lines · Matt Dainty
Quoted 3 lines · Rusty Russell
On Tue, 8 Jan 2002 11:13:02 +0000
Matt Dainty <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Richard Gooch
Quoted 5 lines
So I'd like to propose a new file (say
kernel/smp.c) which has generic startup code for each CPU. To start with, it can have ageneric_cpu_init()function, which is called by each arch. Note that this function would be called for the boot CPU too.Would this also be hacked into whatever Hotswap CPU support exists? Such
Hm, that would be nice.
Quoted 6 lines
Quoted 2 lines
We use /proc/sys/cpu/#/. I don't understand what
/dev/cpu/xxxis supposed to do./dev/cpu/[0...]/... contains (on i386 at least), the cpuid and msr character devices, except on devfs-enabled boxen, these don't appear automatically.
Indeed.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Followup to: <[email protected]> By author: Rusty Russell <[email protected]> In newsgroup: linux.dev.kernel
Quoted 4 lines
It's unfortunate that
/proc/sysand /proc suck so hard that good coders go to great lengths to do anything else [see previous/proc/syspatches].
/proc/sys is pretty cool. However, procfs has no permission control system set up, unlike /dev. This is inherent; adjusting sysctls is a root-only function and cannot be made otherwise.
-hpa
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." http://www.zytor.com/~hpa/puzzle.txt <[email protected]>
Quoted 3 lines · On 8 Jan 2002 09:17:29 -0800 "H. Peter Anvin" <[email protected]> wrote:
/proc/sysis pretty cool. However, procfs has no permission control system set up, unlike /dev. This is inherent; adjusting sysctls is a root-only function and cannot be made otherwise.
Incorrect. See my new /proc/sys implementation patch. It's hidden in the flames somewhere...
Cheers,
Rusty.
Signature · 1 line
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Followup to: <[email protected]> By author: Rusty Russell <[email protected]> In newsgroup: linux.dev.kernel
Quoted 4 lines
Incorrect. See my new
/proc/sysimplementation patch. It's hidden in the flames somewhere...
So you chown an entry, then a module is unloaded and reloaded, now what happens?
It's the old "virtual filesystem which really wants persistence" issue again...
-hpa
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." http://www.zytor.com/~hpa/puzzle.txt <[email protected]>
Quoted 10 lines · H. Peter Anvin
By author: Rusty Russell <[email protected]>
Quoted 3 lines
Incorrect. See my new
/proc/sysimplementation patch. It's hidden in the flames somewhere...So you chown an entry, then a module is unloaded and reloaded, now what happens?
It's the old "virtual filesystem which really wants persistence" issue again...
Works beautifully with devfs+devfsd :-)
Permissions get saved elsewhere in the namespace (perhaps even to the underlying /dev) as you chown(2)/chmod(2)/mknod(2), and are restored when entries are (re)created and/or at startup.
My /dev has persistence behaviour which looks like a FS with backing store.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 2 lines · On 8 Jan 2002 19:16:30 -0800 "H. Peter Anvin" <[email protected]> wrote:
So you chown an entry, then a module is unloaded and reloaded, now what happens?
Sorry, was responding to the second sentence, not the first:
Quoted 3 lines
However, procfs has no permission control
system set up, unlike /dev. This is inherent; adjusting sysctls is a root-only function and cannot be made otherwise.
In practice, my /proc/sys perms are four bits: ALL READ, ALL WRITE, ROOT READ, ROOT WRITE.
Hope that helps,
Rusty.
Signature · 1 line
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 8 lines · Richard Gooch
Quoted 7 lines
Quoted 1 line
So you chown an entry, then a module is unloaded and reloaded, now what happens?
It's the old "virtual filesystem which really wants persistence" issue again...
Quoted 9 lines
Works beautifully with devfs+devfsd :-)
Permissions get saved elsewhere in the namespace (perhaps even to the underlying /dev) as you chown(2)/chmod(2)/mknod(2), and are restored when entries are (re)created and/or at startup.
My /dev has persistence behaviour which looks like a FS with backing store.
Yes, after quite a few years it finally got in there. This is a Good Thing[TM]. Now apply the same problem to /proc.
-hpa
Quoted 16 lines · H. Peter Anvin
Quoted 14 lines · Richard Gooch
Quoted 7 lines
Quoted 1 line
So you chown an entry, then a module is unloaded and reloaded, now what happens?
It's the old "virtual filesystem which really wants persistence" issue again...
Works beautifully with devfs+devfsd :-)
Permissions get saved elsewhere in the namespace (perhaps even to the underlying /dev) as you chown(2)/chmod(2)/mknod(2), and are restored when entries are (re)created and/or at startup.
Quoted 5 lines
Quoted 2 lines
My /dev has persistence behaviour which looks like a FS with backing store.
Yes, after quite a few years it finally got in there. This is a Good Thing[TM]. Now apply the same problem to /proc.
Actually, the COPY action has been available since APR-2000 :-)
But as for applying this to /proc, that's a good point. My current plans are to write v2.0 of the devfs core, which will use the dcache to maintain the devfs tree structure, rather than having my own code to do it. That should result in a significant reduction in code side, and maybe finally people won't hate the idea so much.
So then, one approach would be to have control files where you want to have permissions persistence placed in devfs. Of course, for consistency, you'd want all control files under devfs. A /dev/sys hierarchy perhaps.
Another idea is to turn devfs into some kind of "kernfs", and have one instance for /dev, another for /proc/sys (or /system if you like), and run an instance of devfsd (renamed to "kernfsd" perhaps) for each of these instances.
Of course, it depends on whether people *want* permissions persistence for /proc/sys. Is there much call for this?
Regards, Richard.... Permanent: [email protected] Current: [email protected]