Skip to contentSkip to conversation

i386 cpuid.c devfs support 2/2

PATCH In review Andrey Borzenkov 2 participants 3 messages Aug 10, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386 cpuid.c devfs support 2/2

the same question about default permissions as for msr.c; the same problem with module unload.

-andrey

arch/i386/kernel/cpuid.c renamed from arch/i386/kernel/cpuid.c.devfs +12 -0
@@ -39,6 +39,8 @@
 #include <linux/smp_lock.h>
 #include <linux/fs.h>
 
+#include <linux/devfs_fs_kernel.h>
+
 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/uaccess.h>
@@ -156,17 +158,27 @@ static struct file_operations cpuid_fops
 
 int __init cpuid_init(void)
 {
+  int i;
+
   if (register_chrdev(CPUID_MAJOR, "cpu/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++)
+    devfs_mk_cdev(MKDEV(CPUID_MAJOR, i), S_IFCHR | S_IRUGO, "cpu/%d/cpuid", i);
+
   return 0;
 }
 
 void __exit cpuid_exit(void)
 {
+  int i;
+
+  for (i = 0; i < NR_CPUS; i++)
+    devfs_remove("cpu/%d/cpuid", i);
+
   unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
 }
 
#1 lore raw
Quoted 2 lines · Andrey Borzenkov

the same question about default permissions as for msr.c; the same problem with module unload.

cpuid is less harmful than msr, but it's possible some admins may not want their users being able to read things like CPU serial numbers (if enabled).

Dave

Signature · 1 line
 Dave Jones     http://www.codemonkey.org.uk
#2 lore raw
Quoted 8 lines · Dave Jones
Quoted 2 lines · Andrey Borzenkov

the same question about default permissions as for msr.c; the same problem with module unload.

cpuid is less harmful than msr, but it's possible some admins may not want their users being able to read things like CPU serial numbers (if enabled).

should it be 400 or 440 by default? Microcode sets permissions to 640.

-andrey