diff options
56 files changed, 1263 insertions, 1141 deletions
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index 0a3f9e8ebde0..ab9862c3a136 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
18 | #include <linux/seq_file.h> | ||
18 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
19 | #include <linux/console.h> | 20 | #include <linux/console.h> |
20 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
@@ -93,7 +94,7 @@ static char amiga_model_name[13] = "Amiga "; | |||
93 | 94 | ||
94 | static void amiga_sched_init(irq_handler_t handler); | 95 | static void amiga_sched_init(irq_handler_t handler); |
95 | static void amiga_get_model(char *model); | 96 | static void amiga_get_model(char *model); |
96 | static int amiga_get_hardware_list(char *buffer); | 97 | static void amiga_get_hardware_list(struct seq_file *m); |
97 | /* amiga specific timer functions */ | 98 | /* amiga specific timer functions */ |
98 | static unsigned long amiga_gettimeoffset(void); | 99 | static unsigned long amiga_gettimeoffset(void); |
99 | static int a3000_hwclk(int, struct rtc_time *); | 100 | static int a3000_hwclk(int, struct rtc_time *); |
@@ -911,13 +912,11 @@ static void amiga_get_model(char *model) | |||
911 | } | 912 | } |
912 | 913 | ||
913 | 914 | ||
914 | static int amiga_get_hardware_list(char *buffer) | 915 | static void amiga_get_hardware_list(struct seq_file *m) |
915 | { | 916 | { |
916 | int len = 0; | ||
917 | |||
918 | if (AMIGAHW_PRESENT(CHIP_RAM)) | 917 | if (AMIGAHW_PRESENT(CHIP_RAM)) |
919 | len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); | 918 | seq_printf(m, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); |
920 | len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", | 919 | seq_printf(m, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", |
921 | amiga_psfreq, amiga_eclock); | 920 | amiga_psfreq, amiga_eclock); |
922 | if (AMIGAHW_PRESENT(AMI_VIDEO)) { | 921 | if (AMIGAHW_PRESENT(AMI_VIDEO)) { |
923 | char *type; | 922 | char *type; |
@@ -935,14 +934,14 @@ static int amiga_get_hardware_list(char *buffer) | |||
935 | type = "Old or Unknown"; | 934 | type = "Old or Unknown"; |
936 | break; | 935 | break; |
937 | } | 936 | } |
938 | len += sprintf(buffer+len, "Graphics:\t%s\n", type); | 937 | seq_printf(m, "Graphics:\t%s\n", type); |
939 | } | 938 | } |
940 | 939 | ||
941 | #define AMIGAHW_ANNOUNCE(name, str) \ | 940 | #define AMIGAHW_ANNOUNCE(name, str) \ |
942 | if (AMIGAHW_PRESENT(name)) \ | 941 | if (AMIGAHW_PRESENT(name)) \ |
943 | len += sprintf (buffer+len, "\t%s\n", str) | 942 | seq_printf (m, "\t%s\n", str) |
944 | 943 | ||
945 | len += sprintf (buffer + len, "Detected hardware:\n"); | 944 | seq_printf (m, "Detected hardware:\n"); |
946 | 945 | ||
947 | AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video"); | 946 | AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video"); |
948 | AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter"); | 947 | AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter"); |
@@ -975,15 +974,13 @@ static int amiga_get_hardware_list(char *buffer) | |||
975 | AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot"); | 974 | AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot"); |
976 | #ifdef CONFIG_ZORRO | 975 | #ifdef CONFIG_ZORRO |
977 | if (AMIGAHW_PRESENT(ZORRO)) | 976 | if (AMIGAHW_PRESENT(ZORRO)) |
978 | len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion " | 977 | seq_printf(m, "\tZorro II%s AutoConfig: %d Expansion " |
979 | "Device%s\n", | 978 | "Device%s\n", |
980 | AMIGAHW_PRESENT(ZORRO3) ? "I" : "", | 979 | AMIGAHW_PRESENT(ZORRO3) ? "I" : "", |
981 | zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s"); | 980 | zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s"); |
982 | #endif /* CONFIG_ZORRO */ | 981 | #endif /* CONFIG_ZORRO */ |
983 | 982 | ||
984 | #undef AMIGAHW_ANNOUNCE | 983 | #undef AMIGAHW_ANNOUNCE |
985 | |||
986 | return len; | ||
987 | } | 984 | } |
988 | 985 | ||
989 | /* | 986 | /* |
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c index af031855f796..49c28cdbea5c 100644 --- a/arch/m68k/atari/config.c +++ b/arch/m68k/atari/config.c | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/seq_file.h> | ||
29 | #include <linux/console.h> | 30 | #include <linux/console.h> |
30 | #include <linux/init.h> | 31 | #include <linux/init.h> |
31 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
@@ -63,7 +64,7 @@ int atari_rtc_year_offset; | |||
63 | /* local function prototypes */ | 64 | /* local function prototypes */ |
64 | static void atari_reset(void); | 65 | static void atari_reset(void); |
65 | static void atari_get_model(char *model); | 66 | static void atari_get_model(char *model); |
66 | static int atari_get_hardware_list(char *buffer); | 67 | static void atari_get_hardware_list(struct seq_file *m); |
67 | 68 | ||
68 | /* atari specific irq functions */ | 69 | /* atari specific irq functions */ |
69 | extern void atari_init_IRQ (void); | 70 | extern void atari_init_IRQ (void); |
@@ -611,21 +612,21 @@ static void atari_get_model(char *model) | |||
611 | } | 612 | } |
612 | 613 | ||
613 | 614 | ||
614 | static int atari_get_hardware_list(char *buffer) | 615 | static void atari_get_hardware_list(struct seq_file *m) |
615 | { | 616 | { |
616 | int len = 0, i; | 617 | int i; |
617 | 618 | ||
618 | for (i = 0; i < m68k_num_memory; i++) | 619 | for (i = 0; i < m68k_num_memory; i++) |
619 | len += sprintf(buffer+len, "\t%3ld MB at 0x%08lx (%s)\n", | 620 | seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n", |
620 | m68k_memory[i].size >> 20, m68k_memory[i].addr, | 621 | m68k_memory[i].size >> 20, m68k_memory[i].addr, |
621 | (m68k_memory[i].addr & 0xff000000 ? | 622 | (m68k_memory[i].addr & 0xff000000 ? |
622 | "alternate RAM" : "ST-RAM")); | 623 | "alternate RAM" : "ST-RAM")); |
623 | 624 | ||
624 | #define ATARIHW_ANNOUNCE(name, str) \ | 625 | #define ATARIHW_ANNOUNCE(name, str) \ |
625 | if (ATARIHW_PRESENT(name)) \ | 626 | if (ATARIHW_PRESENT(name)) \ |
626 | len += sprintf(buffer + len, "\t%s\n", str) | 627 | seq_printf(m, "\t%s\n", str) |
627 | 628 | ||
628 | len += sprintf(buffer + len, "Detected hardware:\n"); | 629 | seq_printf(m, "Detected hardware:\n"); |
629 | ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter"); | 630 | ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter"); |
630 | ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter"); | 631 | ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter"); |
631 | ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter"); | 632 | ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter"); |
@@ -654,6 +655,4 @@ static int atari_get_hardware_list(char *buffer) | |||
654 | ATARIHW_ANNOUNCE(BLITTER, "Blitter"); | 655 | ATARIHW_ANNOUNCE(BLITTER, "Blitter"); |
655 | ATARIHW_ANNOUNCE(VME, "VME Bus"); | 656 | ATARIHW_ANNOUNCE(VME, "VME Bus"); |
656 | ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor"); | 657 | ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor"); |
657 | |||
658 | return len; | ||
659 | } | 658 | } |
diff --git a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c index 04c69ffbea71..6ec3b7f33779 100644 --- a/arch/m68k/atari/stram.c +++ b/arch/m68k/atari/stram.c | |||
@@ -42,6 +42,7 @@ | |||
42 | /* abbrev for the && above... */ | 42 | /* abbrev for the && above... */ |
43 | #define DO_PROC | 43 | #define DO_PROC |
44 | #include <linux/proc_fs.h> | 44 | #include <linux/proc_fs.h> |
45 | #include <linux/seq_file.h> | ||
45 | #endif | 46 | #endif |
46 | 47 | ||
47 | /* | 48 | /* |
@@ -323,19 +324,16 @@ static int remove_region( BLOCK *block ) | |||
323 | 324 | ||
324 | #ifdef DO_PROC | 325 | #ifdef DO_PROC |
325 | 326 | ||
326 | #define PRINT_PROC(fmt,args...) len += sprintf( buf+len, fmt, ##args ) | 327 | #define PRINT_PROC(fmt,args...) seq_printf( m, fmt, ##args ) |
327 | 328 | ||
328 | int get_stram_list( char *buf ) | 329 | static int stram_proc_show(struct seq_file *m, void *v) |
329 | { | 330 | { |
330 | int len = 0; | ||
331 | BLOCK *p; | 331 | BLOCK *p; |
332 | 332 | ||
333 | PRINT_PROC("Total ST-RAM: %8u kB\n", | 333 | PRINT_PROC("Total ST-RAM: %8u kB\n", |
334 | (stram_end - stram_start) >> 10); | 334 | (stram_end - stram_start) >> 10); |
335 | PRINT_PROC( "Allocated regions:\n" ); | 335 | PRINT_PROC( "Allocated regions:\n" ); |
336 | for( p = alloc_list; p; p = p->next ) { | 336 | for( p = alloc_list; p; p = p->next ) { |
337 | if (len + 50 >= PAGE_SIZE) | ||
338 | break; | ||
339 | PRINT_PROC("0x%08lx-0x%08lx: %s (", | 337 | PRINT_PROC("0x%08lx-0x%08lx: %s (", |
340 | virt_to_phys(p->start), | 338 | virt_to_phys(p->start), |
341 | virt_to_phys(p->start+p->size-1), | 339 | virt_to_phys(p->start+p->size-1), |
@@ -346,9 +344,27 @@ int get_stram_list( char *buf ) | |||
346 | PRINT_PROC( "??)\n" ); | 344 | PRINT_PROC( "??)\n" ); |
347 | } | 345 | } |
348 | 346 | ||
349 | return( len ); | 347 | return 0; |
348 | } | ||
349 | |||
350 | static int stram_proc_open(struct inode *inode, struct file *file) | ||
351 | { | ||
352 | return single_open(file, stram_proc_show, NULL); | ||
350 | } | 353 | } |
351 | 354 | ||
355 | static const struct file_operations stram_proc_fops = { | ||
356 | .open = stram_proc_open, | ||
357 | .read = seq_read, | ||
358 | .llseek = seq_lseek, | ||
359 | .release = single_release, | ||
360 | }; | ||
361 | |||
362 | static int __init proc_stram_init(void) | ||
363 | { | ||
364 | proc_create("stram", 0, NULL, &stram_proc_fops); | ||
365 | return 0; | ||
366 | } | ||
367 | module_init(proc_stram_init); | ||
352 | #endif | 368 | #endif |
353 | 369 | ||
354 | 370 | ||
diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c index 65c9204ab9ac..c072595928c0 100644 --- a/arch/m68k/bvme6000/config.c +++ b/arch/m68k/bvme6000/config.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <asm/bvme6000hw.h> | 38 | #include <asm/bvme6000hw.h> |
39 | 39 | ||
40 | static void bvme6000_get_model(char *model); | 40 | static void bvme6000_get_model(char *model); |
41 | static int bvme6000_get_hardware_list(char *buffer); | ||
42 | extern void bvme6000_sched_init(irq_handler_t handler); | 41 | extern void bvme6000_sched_init(irq_handler_t handler); |
43 | extern unsigned long bvme6000_gettimeoffset (void); | 42 | extern unsigned long bvme6000_gettimeoffset (void); |
44 | extern int bvme6000_hwclk (int, struct rtc_time *); | 43 | extern int bvme6000_hwclk (int, struct rtc_time *); |
@@ -82,15 +81,6 @@ static void bvme6000_get_model(char *model) | |||
82 | sprintf(model, "BVME%d000", m68k_cputype == CPU_68060 ? 6 : 4); | 81 | sprintf(model, "BVME%d000", m68k_cputype == CPU_68060 ? 6 : 4); |
83 | } | 82 | } |
84 | 83 | ||
85 | |||
86 | /* No hardware options on BVME6000? */ | ||
87 | |||
88 | static int bvme6000_get_hardware_list(char *buffer) | ||
89 | { | ||
90 | *buffer = '\0'; | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | /* | 84 | /* |
95 | * This function is called during kernel startup to initialize | 85 | * This function is called during kernel startup to initialize |
96 | * the bvme6000 IRQ handling routines. | 86 | * the bvme6000 IRQ handling routines. |
@@ -127,7 +117,6 @@ void __init config_bvme6000(void) | |||
127 | mach_set_clock_mmss = bvme6000_set_clock_mmss; | 117 | mach_set_clock_mmss = bvme6000_set_clock_mmss; |
128 | mach_reset = bvme6000_reset; | 118 | mach_reset = bvme6000_reset; |
129 | mach_get_model = bvme6000_get_model; | 119 | mach_get_model = bvme6000_get_model; |
130 | mach_get_hardware_list = bvme6000_get_hardware_list; | ||
131 | 120 | ||
132 | printk ("Board is %sconfigured as a System Controller\n", | 121 | printk ("Board is %sconfigured as a System Controller\n", |
133 | *config_reg_ptr & BVME_CONFIG_SW1 ? "" : "not "); | 122 | *config_reg_ptr & BVME_CONFIG_SW1 ? "" : "not "); |
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c index ea1e44da19b9..4d97bd2bd573 100644 --- a/arch/m68k/kernel/setup.c +++ b/arch/m68k/kernel/setup.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/bootmem.h> |
23 | #include <linux/proc_fs.h> | ||
23 | #include <linux/seq_file.h> | 24 | #include <linux/seq_file.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/initrd.h> | 26 | #include <linux/initrd.h> |
@@ -80,7 +81,7 @@ void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL; | |||
80 | /* machine dependent irq functions */ | 81 | /* machine dependent irq functions */ |
81 | void (*mach_init_IRQ) (void) __initdata = NULL; | 82 | void (*mach_init_IRQ) (void) __initdata = NULL; |
82 | void (*mach_get_model) (char *model); | 83 | void (*mach_get_model) (char *model); |
83 | int (*mach_get_hardware_list) (char *buffer); | 84 | void (*mach_get_hardware_list) (struct seq_file *m); |
84 | /* machine dependent timer functions */ | 85 | /* machine dependent timer functions */ |
85 | unsigned long (*mach_gettimeoffset) (void); | 86 | unsigned long (*mach_gettimeoffset) (void); |
86 | int (*mach_hwclk) (int, struct rtc_time*); | 87 | int (*mach_hwclk) (int, struct rtc_time*); |
@@ -467,9 +468,9 @@ const struct seq_operations cpuinfo_op = { | |||
467 | .show = show_cpuinfo, | 468 | .show = show_cpuinfo, |
468 | }; | 469 | }; |
469 | 470 | ||
470 | int get_hardware_list(char *buffer) | 471 | #ifdef CONFIG_PROC_HARDWARE |
472 | static int hardware_proc_show(struct seq_file *m, void *v) | ||
471 | { | 473 | { |
472 | int len = 0; | ||
473 | char model[80]; | 474 | char model[80]; |
474 | unsigned long mem; | 475 | unsigned long mem; |
475 | int i; | 476 | int i; |
@@ -479,17 +480,37 @@ int get_hardware_list(char *buffer) | |||
479 | else | 480 | else |
480 | strcpy(model, "Unknown m68k"); | 481 | strcpy(model, "Unknown m68k"); |
481 | 482 | ||
482 | len += sprintf(buffer + len, "Model:\t\t%s\n", model); | 483 | seq_printf(m, "Model:\t\t%s\n", model); |
483 | for (mem = 0, i = 0; i < m68k_num_memory; i++) | 484 | for (mem = 0, i = 0; i < m68k_num_memory; i++) |
484 | mem += m68k_memory[i].size; | 485 | mem += m68k_memory[i].size; |
485 | len += sprintf(buffer + len, "System Memory:\t%ldK\n", mem >> 10); | 486 | seq_printf(m, "System Memory:\t%ldK\n", mem >> 10); |
486 | 487 | ||
487 | if (mach_get_hardware_list) | 488 | if (mach_get_hardware_list) |
488 | len += mach_get_hardware_list(buffer + len); | 489 | mach_get_hardware_list(m); |
489 | 490 | ||
490 | return len; | 491 | return 0; |
492 | } | ||
493 | |||
494 | static int hardware_proc_open(struct inode *inode, struct file *file) | ||
495 | { | ||
496 | return single_open(file, hardware_proc_show, NULL); | ||
491 | } | 497 | } |
492 | 498 | ||
499 | static const struct file_operations hardware_proc_fops = { | ||
500 | .open = hardware_proc_open, | ||
501 | .read = seq_read, | ||
502 | .llseek = seq_lseek, | ||
503 | .release = single_release, | ||
504 | }; | ||
505 | |||
506 | static int __init proc_hardware_init(void) | ||
507 | { | ||
508 | proc_create("hardware", 0, NULL, &hardware_proc_fops); | ||
509 | return 0; | ||
510 | } | ||
511 | module_init(proc_hardware_init); | ||
512 | #endif | ||
513 | |||
493 | void check_bugs(void) | 514 | void check_bugs(void) |
494 | { | 515 | { |
495 | #ifndef CONFIG_M68KFPU_EMU | 516 | #ifndef CONFIG_M68KFPU_EMU |
diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c index 92fe50714112..43cdf476ffab 100644 --- a/arch/m68k/mvme147/config.c +++ b/arch/m68k/mvme147/config.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | 38 | ||
39 | static void mvme147_get_model(char *model); | 39 | static void mvme147_get_model(char *model); |
40 | static int mvme147_get_hardware_list(char *buffer); | ||
41 | extern void mvme147_sched_init(irq_handler_t handler); | 40 | extern void mvme147_sched_init(irq_handler_t handler); |
42 | extern unsigned long mvme147_gettimeoffset (void); | 41 | extern unsigned long mvme147_gettimeoffset (void); |
43 | extern int mvme147_hwclk (int, struct rtc_time *); | 42 | extern int mvme147_hwclk (int, struct rtc_time *); |
@@ -76,14 +75,6 @@ static void mvme147_get_model(char *model) | |||
76 | sprintf(model, "Motorola MVME147"); | 75 | sprintf(model, "Motorola MVME147"); |
77 | } | 76 | } |
78 | 77 | ||
79 | |||
80 | static int mvme147_get_hardware_list(char *buffer) | ||
81 | { | ||
82 | *buffer = '\0'; | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | /* | 78 | /* |
88 | * This function is called during kernel startup to initialize | 79 | * This function is called during kernel startup to initialize |
89 | * the mvme147 IRQ handling routines. | 80 | * the mvme147 IRQ handling routines. |
@@ -104,7 +95,6 @@ void __init config_mvme147(void) | |||
104 | mach_set_clock_mmss = mvme147_set_clock_mmss; | 95 | mach_set_clock_mmss = mvme147_set_clock_mmss; |
105 | mach_reset = mvme147_reset; | 96 | mach_reset = mvme147_reset; |
106 | mach_get_model = mvme147_get_model; | 97 | mach_get_model = mvme147_get_model; |
107 | mach_get_hardware_list = mvme147_get_hardware_list; | ||
108 | 98 | ||
109 | /* Board type is only set by newer versions of vmelilo/tftplilo */ | 99 | /* Board type is only set by newer versions of vmelilo/tftplilo */ |
110 | if (!vme_brdtype) | 100 | if (!vme_brdtype) |
diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index 24cbc3030454..1521826fc3c7 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/seq_file.h> | ||
20 | #include <linux/tty.h> | 21 | #include <linux/tty.h> |
21 | #include <linux/console.h> | 22 | #include <linux/console.h> |
22 | #include <linux/linkage.h> | 23 | #include <linux/linkage.h> |
@@ -42,7 +43,6 @@ extern t_bdid mvme_bdid; | |||
42 | static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE; | 43 | static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE; |
43 | 44 | ||
44 | static void mvme16x_get_model(char *model); | 45 | static void mvme16x_get_model(char *model); |
45 | static int mvme16x_get_hardware_list(char *buffer); | ||
46 | extern void mvme16x_sched_init(irq_handler_t handler); | 46 | extern void mvme16x_sched_init(irq_handler_t handler); |
47 | extern unsigned long mvme16x_gettimeoffset (void); | 47 | extern unsigned long mvme16x_gettimeoffset (void); |
48 | extern int mvme16x_hwclk (int, struct rtc_time *); | 48 | extern int mvme16x_hwclk (int, struct rtc_time *); |
@@ -93,26 +93,21 @@ static void mvme16x_get_model(char *model) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | static int mvme16x_get_hardware_list(char *buffer) | 96 | static void mvme16x_get_hardware_list(struct seq_file *m) |
97 | { | 97 | { |
98 | p_bdid p = &mvme_bdid; | 98 | p_bdid p = &mvme_bdid; |
99 | int len = 0; | ||
100 | 99 | ||
101 | if (p->brdno == 0x0162 || p->brdno == 0x0172) | 100 | if (p->brdno == 0x0162 || p->brdno == 0x0172) |
102 | { | 101 | { |
103 | unsigned char rev = *(unsigned char *)MVME162_VERSION_REG; | 102 | unsigned char rev = *(unsigned char *)MVME162_VERSION_REG; |
104 | 103 | ||
105 | len += sprintf (buffer+len, "VMEchip2 %spresent\n", | 104 | seq_printf (m, "VMEchip2 %spresent\n", |
106 | rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : ""); | 105 | rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : ""); |
107 | len += sprintf (buffer+len, "SCSI interface %spresent\n", | 106 | seq_printf (m, "SCSI interface %spresent\n", |
108 | rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : ""); | 107 | rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : ""); |
109 | len += sprintf (buffer+len, "Ethernet i/f %spresent\n", | 108 | seq_printf (m, "Ethernet i/f %spresent\n", |
110 | rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : ""); | 109 | rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : ""); |
111 | } | 110 | } |
112 | else | ||
113 | *buffer = '\0'; | ||
114 | |||
115 | return (len); | ||
116 | } | 111 | } |
117 | 112 | ||
118 | /* | 113 | /* |
diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c index 9c7eefa3f98a..7110546e3c00 100644 --- a/arch/m68k/q40/config.c +++ b/arch/m68k/q40/config.c | |||
@@ -39,7 +39,6 @@ | |||
39 | extern irqreturn_t q40_process_int(int level, struct pt_regs *regs); | 39 | extern irqreturn_t q40_process_int(int level, struct pt_regs *regs); |
40 | extern void q40_init_IRQ(void); | 40 | extern void q40_init_IRQ(void); |
41 | static void q40_get_model(char *model); | 41 | static void q40_get_model(char *model); |
42 | static int q40_get_hardware_list(char *buffer); | ||
43 | extern void q40_sched_init(irq_handler_t handler); | 42 | extern void q40_sched_init(irq_handler_t handler); |
44 | 43 | ||
45 | static unsigned long q40_gettimeoffset(void); | 44 | static unsigned long q40_gettimeoffset(void); |
@@ -153,14 +152,6 @@ static void q40_get_model(char *model) | |||
153 | sprintf(model, "Q40"); | 152 | sprintf(model, "Q40"); |
154 | } | 153 | } |
155 | 154 | ||
156 | /* No hardware options on Q40? */ | ||
157 | |||
158 | static int q40_get_hardware_list(char *buffer) | ||
159 | { | ||
160 | *buffer = '\0'; | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static unsigned int serports[] = | 155 | static unsigned int serports[] = |
165 | { | 156 | { |
166 | 0x3f8,0x2f8,0x3e8,0x2e8,0 | 157 | 0x3f8,0x2f8,0x3e8,0x2e8,0 |
@@ -191,7 +182,6 @@ void __init config_q40(void) | |||
191 | 182 | ||
192 | mach_reset = q40_reset; | 183 | mach_reset = q40_reset; |
193 | mach_get_model = q40_get_model; | 184 | mach_get_model = q40_get_model; |
194 | mach_get_hardware_list = q40_get_hardware_list; | ||
195 | 185 | ||
196 | #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) | 186 | #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) |
197 | mach_beep = q40_mksound; | 187 | mach_beep = q40_mksound; |
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c index 732087d0735c..8dfaa201342e 100644 --- a/arch/m68k/sun3/config.c +++ b/arch/m68k/sun3/config.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/seq_file.h> | ||
14 | #include <linux/tty.h> | 15 | #include <linux/tty.h> |
15 | #include <linux/console.h> | 16 | #include <linux/console.h> |
16 | #include <linux/init.h> | 17 | #include <linux/init.h> |
@@ -46,16 +47,9 @@ extern volatile unsigned char* sun3_intreg; | |||
46 | extern unsigned long availmem; | 47 | extern unsigned long availmem; |
47 | unsigned long num_pages; | 48 | unsigned long num_pages; |
48 | 49 | ||
49 | static int sun3_get_hardware_list(char *buffer) | 50 | static void sun3_get_hardware_list(struct seq_file *m) |
50 | { | 51 | { |
51 | 52 | seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid); | |
52 | int len = 0; | ||
53 | |||
54 | len += sprintf(buffer + len, "PROM Revision:\t%s\n", | ||
55 | romvec->pv_monid); | ||
56 | |||
57 | return len; | ||
58 | |||
59 | } | 53 | } |
60 | 54 | ||
61 | void __init sun3_init(void) | 55 | void __init sun3_init(void) |
diff --git a/arch/m68k/sun3x/config.c b/arch/m68k/sun3x/config.c index 987891783a47..2b1ca2db070f 100644 --- a/arch/m68k/sun3x/config.c +++ b/arch/m68k/sun3x/config.c | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/seq_file.h> | ||
11 | #include <linux/console.h> | 12 | #include <linux/console.h> |
12 | #include <linux/init.h> | 13 | #include <linux/init.h> |
13 | 14 | ||
@@ -31,16 +32,9 @@ void sun3_leds(unsigned int i) | |||
31 | 32 | ||
32 | } | 33 | } |
33 | 34 | ||
34 | static int sun3x_get_hardware_list(char *buffer) | 35 | static void sun3x_get_hardware_list(struct seq_file *m) |
35 | { | 36 | { |
36 | 37 | seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid); | |
37 | int len = 0; | ||
38 | |||
39 | len += sprintf(buffer + len, "PROM Revision:\t%s\n", | ||
40 | romvec->pv_monid); | ||
41 | |||
42 | return len; | ||
43 | |||
44 | } | 38 | } |
45 | 39 | ||
46 | /* | 40 | /* |
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index fb7d1e9985b5..c012f3b11671 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -348,7 +348,8 @@ static inline void native_pagetable_setup_start(pgd_t *base) {} | |||
348 | static inline void native_pagetable_setup_done(pgd_t *base) {} | 348 | static inline void native_pagetable_setup_done(pgd_t *base) {} |
349 | #endif | 349 | #endif |
350 | 350 | ||
351 | extern int arch_report_meminfo(char *page); | 351 | struct seq_file; |
352 | extern void arch_report_meminfo(struct seq_file *m); | ||
352 | 353 | ||
353 | #ifdef CONFIG_PARAVIRT | 354 | #ifdef CONFIG_PARAVIRT |
354 | #include <asm/paravirt.h> | 355 | #include <asm/paravirt.h> |
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 407d8784f669..f1dc1b75d166 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -65,23 +65,22 @@ static void split_page_count(int level) | |||
65 | direct_pages_count[level - 1] += PTRS_PER_PTE; | 65 | direct_pages_count[level - 1] += PTRS_PER_PTE; |
66 | } | 66 | } |
67 | 67 | ||
68 | int arch_report_meminfo(char *page) | 68 | void arch_report_meminfo(struct seq_file *m) |
69 | { | 69 | { |
70 | int n = sprintf(page, "DirectMap4k: %8lu kB\n", | 70 | seq_printf(m, "DirectMap4k: %8lu kB\n", |
71 | direct_pages_count[PG_LEVEL_4K] << 2); | 71 | direct_pages_count[PG_LEVEL_4K] << 2); |
72 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) | 72 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) |
73 | n += sprintf(page + n, "DirectMap2M: %8lu kB\n", | 73 | seq_printf(m, "DirectMap2M: %8lu kB\n", |
74 | direct_pages_count[PG_LEVEL_2M] << 11); | 74 | direct_pages_count[PG_LEVEL_2M] << 11); |
75 | #else | 75 | #else |
76 | n += sprintf(page + n, "DirectMap4M: %8lu kB\n", | 76 | seq_printf(m, "DirectMap4M: %8lu kB\n", |
77 | direct_pages_count[PG_LEVEL_2M] << 12); | 77 | direct_pages_count[PG_LEVEL_2M] << 12); |
78 | #endif | 78 | #endif |
79 | #ifdef CONFIG_X86_64 | 79 | #ifdef CONFIG_X86_64 |
80 | if (direct_gbpages) | 80 | if (direct_gbpages) |
81 | n += sprintf(page + n, "DirectMap1G: %8lu kB\n", | 81 | seq_printf(m, "DirectMap1G: %8lu kB\n", |
82 | direct_pages_count[PG_LEVEL_1G] << 20); | 82 | direct_pages_count[PG_LEVEL_1G] << 20); |
83 | #endif | 83 | #endif |
84 | return n; | ||
85 | } | 84 | } |
86 | #else | 85 | #else |
87 | static inline void split_page_count(int level) { } | 86 | static inline void split_page_count(int level) { } |
diff --git a/block/genhd.c b/block/genhd.c index 646e1d2507c7..4e5e7493f676 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/blkdev.h> | 10 | #include <linux/blkdev.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
13 | #include <linux/proc_fs.h> | ||
13 | #include <linux/seq_file.h> | 14 | #include <linux/seq_file.h> |
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
15 | #include <linux/kmod.h> | 16 | #include <linux/kmod.h> |
@@ -727,12 +728,24 @@ static int show_partition(struct seq_file *seqf, void *v) | |||
727 | return 0; | 728 | return 0; |
728 | } | 729 | } |
729 | 730 | ||
730 | const struct seq_operations partitions_op = { | 731 | static const struct seq_operations partitions_op = { |
731 | .start = show_partition_start, | 732 | .start = show_partition_start, |
732 | .next = disk_seqf_next, | 733 | .next = disk_seqf_next, |
733 | .stop = disk_seqf_stop, | 734 | .stop = disk_seqf_stop, |
734 | .show = show_partition | 735 | .show = show_partition |
735 | }; | 736 | }; |
737 | |||
738 | static int partitions_open(struct inode *inode, struct file *file) | ||
739 | { | ||
740 | return seq_open(file, &partitions_op); | ||
741 | } | ||
742 | |||
743 | static const struct file_operations proc_partitions_operations = { | ||
744 | .open = partitions_open, | ||
745 | .read = seq_read, | ||
746 | .llseek = seq_lseek, | ||
747 | .release = seq_release, | ||
748 | }; | ||
736 | #endif | 749 | #endif |
737 | 750 | ||
738 | 751 | ||
@@ -992,12 +1005,32 @@ static int diskstats_show(struct seq_file *seqf, void *v) | |||
992 | return 0; | 1005 | return 0; |
993 | } | 1006 | } |
994 | 1007 | ||
995 | const struct seq_operations diskstats_op = { | 1008 | static const struct seq_operations diskstats_op = { |
996 | .start = disk_seqf_start, | 1009 | .start = disk_seqf_start, |
997 | .next = disk_seqf_next, | 1010 | .next = disk_seqf_next, |
998 | .stop = disk_seqf_stop, | 1011 | .stop = disk_seqf_stop, |
999 | .show = diskstats_show | 1012 | .show = diskstats_show |
1000 | }; | 1013 | }; |
1014 | |||
1015 | static int diskstats_open(struct inode *inode, struct file *file) | ||
1016 | { | ||
1017 | return seq_open(file, &diskstats_op); | ||
1018 | } | ||
1019 | |||
1020 | static const struct file_operations proc_diskstats_operations = { | ||
1021 | .open = diskstats_open, | ||
1022 | .read = seq_read, | ||
1023 | .llseek = seq_lseek, | ||
1024 | .release = seq_release, | ||
1025 | }; | ||
1026 | |||
1027 | static int __init proc_genhd_init(void) | ||
1028 | { | ||
1029 | proc_create("diskstats", 0, NULL, &proc_diskstats_operations); | ||
1030 | proc_create("partitions", 0, NULL, &proc_partitions_operations); | ||
1031 | return 0; | ||
1032 | } | ||
1033 | module_init(proc_genhd_init); | ||
1001 | #endif /* CONFIG_PROC_FS */ | 1034 | #endif /* CONFIG_PROC_FS */ |
1002 | 1035 | ||
1003 | static void media_change_notify_thread(struct work_struct *work) | 1036 | static void media_change_notify_thread(struct work_struct *work) |
diff --git a/fs/filesystems.c b/fs/filesystems.c index f37f87262837..d0e20ced62dd 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c | |||
@@ -8,6 +8,8 @@ | |||
8 | 8 | ||
9 | #include <linux/syscalls.h> | 9 | #include <linux/syscalls.h> |
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/proc_fs.h> | ||
12 | #include <linux/seq_file.h> | ||
11 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
12 | #include <linux/kmod.h> | 14 | #include <linux/kmod.h> |
13 | #include <linux/init.h> | 15 | #include <linux/init.h> |
@@ -214,6 +216,43 @@ int get_filesystem_list(char * buf) | |||
214 | return len; | 216 | return len; |
215 | } | 217 | } |
216 | 218 | ||
219 | #ifdef CONFIG_PROC_FS | ||
220 | static int filesystems_proc_show(struct seq_file *m, void *v) | ||
221 | { | ||
222 | struct file_system_type * tmp; | ||
223 | |||
224 | read_lock(&file_systems_lock); | ||
225 | tmp = file_systems; | ||
226 | while (tmp) { | ||
227 | seq_printf(m, "%s\t%s\n", | ||
228 | (tmp->fs_flags & FS_REQUIRES_DEV) ? "" : "nodev", | ||
229 | tmp->name); | ||
230 | tmp = tmp->next; | ||
231 | } | ||
232 | read_unlock(&file_systems_lock); | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int filesystems_proc_open(struct inode *inode, struct file *file) | ||
237 | { | ||
238 | return single_open(file, filesystems_proc_show, NULL); | ||
239 | } | ||
240 | |||
241 | static const struct file_operations filesystems_proc_fops = { | ||
242 | .open = filesystems_proc_open, | ||
243 | .read = seq_read, | ||
244 | .llseek = seq_lseek, | ||
245 | .release = single_release, | ||
246 | }; | ||
247 | |||
248 | static int __init proc_filesystems_init(void) | ||
249 | { | ||
250 | proc_create("filesystems", 0, NULL, &filesystems_proc_fops); | ||
251 | return 0; | ||
252 | } | ||
253 | module_init(proc_filesystems_init); | ||
254 | #endif | ||
255 | |||
217 | struct file_system_type *get_fs_type(const char *name) | 256 | struct file_system_type *get_fs_type(const char *name) |
218 | { | 257 | { |
219 | struct file_system_type *fs; | 258 | struct file_system_type *fs; |
diff --git a/fs/locks.c b/fs/locks.c index 20457486d6b2..09062e3ff104 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -2079,6 +2079,7 @@ int vfs_cancel_lock(struct file *filp, struct file_lock *fl) | |||
2079 | EXPORT_SYMBOL_GPL(vfs_cancel_lock); | 2079 | EXPORT_SYMBOL_GPL(vfs_cancel_lock); |
2080 | 2080 | ||
2081 | #ifdef CONFIG_PROC_FS | 2081 | #ifdef CONFIG_PROC_FS |
2082 | #include <linux/proc_fs.h> | ||
2082 | #include <linux/seq_file.h> | 2083 | #include <linux/seq_file.h> |
2083 | 2084 | ||
2084 | static void lock_get_status(struct seq_file *f, struct file_lock *fl, | 2085 | static void lock_get_status(struct seq_file *f, struct file_lock *fl, |
@@ -2184,12 +2185,31 @@ static void locks_stop(struct seq_file *f, void *v) | |||
2184 | unlock_kernel(); | 2185 | unlock_kernel(); |
2185 | } | 2186 | } |
2186 | 2187 | ||
2187 | struct seq_operations locks_seq_operations = { | 2188 | static const struct seq_operations locks_seq_operations = { |
2188 | .start = locks_start, | 2189 | .start = locks_start, |
2189 | .next = locks_next, | 2190 | .next = locks_next, |
2190 | .stop = locks_stop, | 2191 | .stop = locks_stop, |
2191 | .show = locks_show, | 2192 | .show = locks_show, |
2192 | }; | 2193 | }; |
2194 | |||
2195 | static int locks_open(struct inode *inode, struct file *filp) | ||
2196 | { | ||
2197 | return seq_open(filp, &locks_seq_operations); | ||
2198 | } | ||
2199 | |||
2200 | static const struct file_operations proc_locks_operations = { | ||
2201 | .open = locks_open, | ||
2202 | .read = seq_read, | ||
2203 | .llseek = seq_lseek, | ||
2204 | .release = seq_release, | ||
2205 | }; | ||
2206 | |||
2207 | static int __init proc_locks_init(void) | ||
2208 | { | ||
2209 | proc_create("locks", 0, NULL, &proc_locks_operations); | ||
2210 | return 0; | ||
2211 | } | ||
2212 | module_init(proc_locks_init); | ||
2193 | #endif | 2213 | #endif |
2194 | 2214 | ||
2195 | /** | 2215 | /** |
diff --git a/fs/proc/Makefile b/fs/proc/Makefile index ebaba0213546..63d965193b22 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile | |||
@@ -8,11 +8,20 @@ proc-y := nommu.o task_nommu.o | |||
8 | proc-$(CONFIG_MMU) := mmu.o task_mmu.o | 8 | proc-$(CONFIG_MMU) := mmu.o task_mmu.o |
9 | 9 | ||
10 | proc-y += inode.o root.o base.o generic.o array.o \ | 10 | proc-y += inode.o root.o base.o generic.o array.o \ |
11 | proc_tty.o proc_misc.o | 11 | proc_tty.o |
12 | 12 | proc-y += cmdline.o | |
13 | proc-y += cpuinfo.o | ||
14 | proc-y += devices.o | ||
15 | proc-y += interrupts.o | ||
16 | proc-y += loadavg.o | ||
17 | proc-y += meminfo.o | ||
18 | proc-y += stat.o | ||
19 | proc-y += uptime.o | ||
20 | proc-y += version.o | ||
13 | proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o | 21 | proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o |
14 | proc-$(CONFIG_NET) += proc_net.o | 22 | proc-$(CONFIG_NET) += proc_net.o |
15 | proc-$(CONFIG_PROC_KCORE) += kcore.o | 23 | proc-$(CONFIG_PROC_KCORE) += kcore.o |
16 | proc-$(CONFIG_PROC_VMCORE) += vmcore.o | 24 | proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
17 | proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o | 25 | proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
18 | proc-$(CONFIG_PRINTK) += kmsg.o | 26 | proc-$(CONFIG_PRINTK) += kmsg.o |
27 | proc-$(CONFIG_PROC_PAGE_MONITOR) += page.o | ||
diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c new file mode 100644 index 000000000000..82676e3fcd1d --- /dev/null +++ b/fs/proc/cmdline.c | |||
@@ -0,0 +1,29 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/proc_fs.h> | ||
4 | #include <linux/seq_file.h> | ||
5 | |||
6 | static int cmdline_proc_show(struct seq_file *m, void *v) | ||
7 | { | ||
8 | seq_printf(m, "%s\n", saved_command_line); | ||
9 | return 0; | ||
10 | } | ||
11 | |||
12 | static int cmdline_proc_open(struct inode *inode, struct file *file) | ||
13 | { | ||
14 | return single_open(file, cmdline_proc_show, NULL); | ||
15 | } | ||
16 | |||
17 | static const struct file_operations cmdline_proc_fops = { | ||
18 | .open = cmdline_proc_open, | ||
19 | .read = seq_read, | ||
20 | .llseek = seq_lseek, | ||
21 | .release = single_release, | ||
22 | }; | ||
23 | |||
24 | static int __init proc_cmdline_init(void) | ||
25 | { | ||
26 | proc_create("cmdline", 0, NULL, &cmdline_proc_fops); | ||
27 | return 0; | ||
28 | } | ||
29 | module_init(proc_cmdline_init); | ||
diff --git a/fs/proc/cpuinfo.c b/fs/proc/cpuinfo.c new file mode 100644 index 000000000000..5a1e539a234b --- /dev/null +++ b/fs/proc/cpuinfo.c | |||
@@ -0,0 +1,24 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/proc_fs.h> | ||
4 | #include <linux/seq_file.h> | ||
5 | |||
6 | extern const struct seq_operations cpuinfo_op; | ||
7 | static int cpuinfo_open(struct inode *inode, struct file *file) | ||
8 | { | ||
9 | return seq_open(file, &cpuinfo_op); | ||
10 | } | ||
11 | |||
12 | static const struct file_operations proc_cpuinfo_operations = { | ||
13 | .open = cpuinfo_open, | ||
14 | .read = seq_read, | ||
15 | .llseek = seq_lseek, | ||
16 | .release = seq_release, | ||
17 | }; | ||
18 | |||
19 | static int __init proc_cpuinfo_init(void) | ||
20 | { | ||
21 | proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); | ||
22 | return 0; | ||
23 | } | ||
24 | module_init(proc_cpuinfo_init); | ||
diff --git a/fs/proc/devices.c b/fs/proc/devices.c new file mode 100644 index 000000000000..59ee7da959c9 --- /dev/null +++ b/fs/proc/devices.c | |||
@@ -0,0 +1,70 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/proc_fs.h> | ||
4 | #include <linux/seq_file.h> | ||
5 | |||
6 | static int devinfo_show(struct seq_file *f, void *v) | ||
7 | { | ||
8 | int i = *(loff_t *) v; | ||
9 | |||
10 | if (i < CHRDEV_MAJOR_HASH_SIZE) { | ||
11 | if (i == 0) | ||
12 | seq_printf(f, "Character devices:\n"); | ||
13 | chrdev_show(f, i); | ||
14 | } | ||
15 | #ifdef CONFIG_BLOCK | ||
16 | else { | ||
17 | i -= CHRDEV_MAJOR_HASH_SIZE; | ||
18 | if (i == 0) | ||
19 | seq_printf(f, "\nBlock devices:\n"); | ||
20 | blkdev_show(f, i); | ||
21 | } | ||
22 | #endif | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | static void *devinfo_start(struct seq_file *f, loff_t *pos) | ||
27 | { | ||
28 | if (*pos < (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE)) | ||
29 | return pos; | ||
30 | return NULL; | ||
31 | } | ||
32 | |||
33 | static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos) | ||
34 | { | ||
35 | (*pos)++; | ||
36 | if (*pos >= (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE)) | ||
37 | return NULL; | ||
38 | return pos; | ||
39 | } | ||
40 | |||
41 | static void devinfo_stop(struct seq_file *f, void *v) | ||
42 | { | ||
43 | /* Nothing to do */ | ||
44 | } | ||
45 | |||
46 | static const struct seq_operations devinfo_ops = { | ||
47 | .start = devinfo_start, | ||
48 | .next = devinfo_next, | ||
49 | .stop = devinfo_stop, | ||
50 | .show = devinfo_show | ||
51 | }; | ||
52 | |||
53 | static int devinfo_open(struct inode *inode, struct file *filp) | ||
54 | { | ||
55 | return seq_open(filp, &devinfo_ops); | ||
56 | } | ||
57 | |||
58 | static const struct file_operations proc_devinfo_operations = { | ||
59 | .open = devinfo_open, | ||
60 | .read = seq_read, | ||
61 | .llseek = seq_lseek, | ||
62 | .release = seq_release, | ||
63 | }; | ||
64 | |||
65 | static int __init proc_devices_init(void) | ||
66 | { | ||
67 | proc_create("devices", 0, NULL, &proc_devinfo_operations); | ||
68 | return 0; | ||
69 | } | ||
70 | module_init(proc_devices_init); | ||
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 7821589a17d5..60a359b35582 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -547,9 +547,8 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp | |||
547 | 547 | ||
548 | for (tmp = dir->subdir; tmp; tmp = tmp->next) | 548 | for (tmp = dir->subdir; tmp; tmp = tmp->next) |
549 | if (strcmp(tmp->name, dp->name) == 0) { | 549 | if (strcmp(tmp->name, dp->name) == 0) { |
550 | printk(KERN_WARNING "proc_dir_entry '%s/%s' already registered\n", | 550 | WARN(1, KERN_WARNING "proc_dir_entry '%s/%s' already registered\n", |
551 | dir->name, dp->name); | 551 | dir->name, dp->name); |
552 | dump_stack(); | ||
553 | break; | 552 | break; |
554 | } | 553 | } |
555 | 554 | ||
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index c6b4fa7e3b49..2543fd00c658 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -106,14 +106,13 @@ static void init_once(void *foo) | |||
106 | inode_init_once(&ei->vfs_inode); | 106 | inode_init_once(&ei->vfs_inode); |
107 | } | 107 | } |
108 | 108 | ||
109 | int __init proc_init_inodecache(void) | 109 | void __init proc_init_inodecache(void) |
110 | { | 110 | { |
111 | proc_inode_cachep = kmem_cache_create("proc_inode_cache", | 111 | proc_inode_cachep = kmem_cache_create("proc_inode_cache", |
112 | sizeof(struct proc_inode), | 112 | sizeof(struct proc_inode), |
113 | 0, (SLAB_RECLAIM_ACCOUNT| | 113 | 0, (SLAB_RECLAIM_ACCOUNT| |
114 | SLAB_MEM_SPREAD|SLAB_PANIC), | 114 | SLAB_MEM_SPREAD|SLAB_PANIC), |
115 | init_once); | 115 | init_once); |
116 | return 0; | ||
117 | } | 116 | } |
118 | 117 | ||
119 | static const struct super_operations proc_sops = { | 118 | static const struct super_operations proc_sops = { |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 3bfb7b8747b3..3e8aeb8b61ce 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -61,12 +61,11 @@ extern const struct file_operations proc_smaps_operations; | |||
61 | extern const struct file_operations proc_clear_refs_operations; | 61 | extern const struct file_operations proc_clear_refs_operations; |
62 | extern const struct file_operations proc_pagemap_operations; | 62 | extern const struct file_operations proc_pagemap_operations; |
63 | extern const struct file_operations proc_net_operations; | 63 | extern const struct file_operations proc_net_operations; |
64 | extern const struct file_operations proc_kmsg_operations; | ||
65 | extern const struct inode_operations proc_net_inode_operations; | 64 | extern const struct inode_operations proc_net_inode_operations; |
66 | 65 | ||
67 | void free_proc_entry(struct proc_dir_entry *de); | 66 | void free_proc_entry(struct proc_dir_entry *de); |
68 | 67 | ||
69 | int proc_init_inodecache(void); | 68 | void proc_init_inodecache(void); |
70 | 69 | ||
71 | static inline struct pid *proc_pid(struct inode *inode) | 70 | static inline struct pid *proc_pid(struct inode *inode) |
72 | { | 71 | { |
diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c new file mode 100644 index 000000000000..05029c0e2f24 --- /dev/null +++ b/fs/proc/interrupts.c | |||
@@ -0,0 +1,53 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/interrupt.h> | ||
4 | #include <linux/irqnr.h> | ||
5 | #include <linux/proc_fs.h> | ||
6 | #include <linux/seq_file.h> | ||
7 | |||
8 | /* | ||
9 | * /proc/interrupts | ||
10 | */ | ||
11 | static void *int_seq_start(struct seq_file *f, loff_t *pos) | ||
12 | { | ||
13 | return (*pos <= nr_irqs) ? pos : NULL; | ||
14 | } | ||
15 | |||
16 | static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) | ||
17 | { | ||
18 | (*pos)++; | ||
19 | if (*pos > nr_irqs) | ||
20 | return NULL; | ||
21 | return pos; | ||
22 | } | ||
23 | |||
24 | static void int_seq_stop(struct seq_file *f, void *v) | ||
25 | { | ||
26 | /* Nothing to do */ | ||
27 | } | ||
28 | |||
29 | static const struct seq_operations int_seq_ops = { | ||
30 | .start = int_seq_start, | ||
31 | .next = int_seq_next, | ||
32 | .stop = int_seq_stop, | ||
33 | .show = show_interrupts | ||
34 | }; | ||
35 | |||
36 | static int interrupts_open(struct inode *inode, struct file *filp) | ||
37 | { | ||
38 | return seq_open(filp, &int_seq_ops); | ||
39 | } | ||
40 | |||
41 | static const struct file_operations proc_interrupts_operations = { | ||
42 | .open = interrupts_open, | ||
43 | .read = seq_read, | ||
44 | .llseek = seq_lseek, | ||
45 | .release = seq_release, | ||
46 | }; | ||
47 | |||
48 | static int __init proc_interrupts_init(void) | ||
49 | { | ||
50 | proc_create("interrupts", 0, NULL, &proc_interrupts_operations); | ||
51 | return 0; | ||
52 | } | ||
53 | module_init(proc_interrupts_init); | ||
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index c2370c76fb71..59b43a068872 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #define ELF_CORE_EFLAGS 0 | 27 | #define ELF_CORE_EFLAGS 0 |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | static struct proc_dir_entry *proc_root_kcore; | ||
31 | |||
30 | static int open_kcore(struct inode * inode, struct file * filp) | 32 | static int open_kcore(struct inode * inode, struct file * filp) |
31 | { | 33 | { |
32 | return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; | 34 | return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; |
@@ -34,7 +36,7 @@ static int open_kcore(struct inode * inode, struct file * filp) | |||
34 | 36 | ||
35 | static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *); | 37 | static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *); |
36 | 38 | ||
37 | const struct file_operations proc_kcore_operations = { | 39 | static const struct file_operations proc_kcore_operations = { |
38 | .read = read_kcore, | 40 | .read = read_kcore, |
39 | .open = open_kcore, | 41 | .open = open_kcore, |
40 | }; | 42 | }; |
@@ -399,3 +401,13 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) | |||
399 | 401 | ||
400 | return acc; | 402 | return acc; |
401 | } | 403 | } |
404 | |||
405 | static int __init proc_kcore_init(void) | ||
406 | { | ||
407 | proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations); | ||
408 | if (proc_root_kcore) | ||
409 | proc_root_kcore->size = | ||
410 | (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE; | ||
411 | return 0; | ||
412 | } | ||
413 | module_init(proc_kcore_init); | ||
diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c index 9fd5df3f40ce..7ca78346d3f0 100644 --- a/fs/proc/kmsg.c +++ b/fs/proc/kmsg.c | |||
@@ -10,13 +10,12 @@ | |||
10 | #include <linux/time.h> | 10 | #include <linux/time.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/poll.h> | 12 | #include <linux/poll.h> |
13 | #include <linux/proc_fs.h> | ||
13 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
14 | 15 | ||
15 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
17 | 18 | ||
18 | #include "internal.h" | ||
19 | |||
20 | extern wait_queue_head_t log_wait; | 19 | extern wait_queue_head_t log_wait; |
21 | 20 | ||
22 | extern int do_syslog(int type, char __user *bug, int count); | 21 | extern int do_syslog(int type, char __user *bug, int count); |
@@ -49,9 +48,16 @@ static unsigned int kmsg_poll(struct file *file, poll_table *wait) | |||
49 | } | 48 | } |
50 | 49 | ||
51 | 50 | ||
52 | const struct file_operations proc_kmsg_operations = { | 51 | static const struct file_operations proc_kmsg_operations = { |
53 | .read = kmsg_read, | 52 | .read = kmsg_read, |
54 | .poll = kmsg_poll, | 53 | .poll = kmsg_poll, |
55 | .open = kmsg_open, | 54 | .open = kmsg_open, |
56 | .release = kmsg_release, | 55 | .release = kmsg_release, |
57 | }; | 56 | }; |
57 | |||
58 | static int __init proc_kmsg_init(void) | ||
59 | { | ||
60 | proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); | ||
61 | return 0; | ||
62 | } | ||
63 | module_init(proc_kmsg_init); | ||
diff --git a/fs/proc/loadavg.c b/fs/proc/loadavg.c new file mode 100644 index 000000000000..9bca39cf99ee --- /dev/null +++ b/fs/proc/loadavg.c | |||
@@ -0,0 +1,51 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/pid_namespace.h> | ||
4 | #include <linux/proc_fs.h> | ||
5 | #include <linux/sched.h> | ||
6 | #include <linux/seq_file.h> | ||
7 | #include <linux/seqlock.h> | ||
8 | #include <linux/time.h> | ||
9 | |||
10 | #define LOAD_INT(x) ((x) >> FSHIFT) | ||
11 | #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) | ||
12 | |||
13 | static int loadavg_proc_show(struct seq_file *m, void *v) | ||
14 | { | ||
15 | int a, b, c; | ||
16 | unsigned long seq; | ||
17 | |||
18 | do { | ||
19 | seq = read_seqbegin(&xtime_lock); | ||
20 | a = avenrun[0] + (FIXED_1/200); | ||
21 | b = avenrun[1] + (FIXED_1/200); | ||
22 | c = avenrun[2] + (FIXED_1/200); | ||
23 | } while (read_seqretry(&xtime_lock, seq)); | ||
24 | |||
25 | seq_printf(m, "%d.%02d %d.%02d %d.%02d %ld/%d %d\n", | ||
26 | LOAD_INT(a), LOAD_FRAC(a), | ||
27 | LOAD_INT(b), LOAD_FRAC(b), | ||
28 | LOAD_INT(c), LOAD_FRAC(c), | ||
29 | nr_running(), nr_threads, | ||
30 | task_active_pid_ns(current)->last_pid); | ||
31 | return 0; | ||
32 | } | ||
33 | |||
34 | static int loadavg_proc_open(struct inode *inode, struct file *file) | ||
35 | { | ||
36 | return single_open(file, loadavg_proc_show, NULL); | ||
37 | } | ||
38 | |||
39 | static const struct file_operations loadavg_proc_fops = { | ||
40 | .open = loadavg_proc_open, | ||
41 | .read = seq_read, | ||
42 | .llseek = seq_lseek, | ||
43 | .release = single_release, | ||
44 | }; | ||
45 | |||
46 | static int __init proc_loadavg_init(void) | ||
47 | { | ||
48 | proc_create("loadavg", 0, NULL, &loadavg_proc_fops); | ||
49 | return 0; | ||
50 | } | ||
51 | module_init(proc_loadavg_init); | ||
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c new file mode 100644 index 000000000000..b1675c4e66da --- /dev/null +++ b/fs/proc/meminfo.c | |||
@@ -0,0 +1,168 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/hugetlb.h> | ||
3 | #include <linux/init.h> | ||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/mm.h> | ||
6 | #include <linux/mman.h> | ||
7 | #include <linux/mmzone.h> | ||
8 | #include <linux/proc_fs.h> | ||
9 | #include <linux/quicklist.h> | ||
10 | #include <linux/seq_file.h> | ||
11 | #include <linux/swap.h> | ||
12 | #include <linux/vmstat.h> | ||
13 | #include <asm/atomic.h> | ||
14 | #include <asm/page.h> | ||
15 | #include <asm/pgtable.h> | ||
16 | #include "internal.h" | ||
17 | |||
18 | void __attribute__((weak)) arch_report_meminfo(struct seq_file *m) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | static int meminfo_proc_show(struct seq_file *m, void *v) | ||
23 | { | ||
24 | struct sysinfo i; | ||
25 | unsigned long committed; | ||
26 | unsigned long allowed; | ||
27 | struct vmalloc_info vmi; | ||
28 | long cached; | ||
29 | unsigned long pages[NR_LRU_LISTS]; | ||
30 | int lru; | ||
31 | |||
32 | /* | ||
33 | * display in kilobytes. | ||
34 | */ | ||
35 | #define K(x) ((x) << (PAGE_SHIFT - 10)) | ||
36 | si_meminfo(&i); | ||
37 | si_swapinfo(&i); | ||
38 | committed = atomic_long_read(&vm_committed_space); | ||
39 | allowed = ((totalram_pages - hugetlb_total_pages()) | ||
40 | * sysctl_overcommit_ratio / 100) + total_swap_pages; | ||
41 | |||
42 | cached = global_page_state(NR_FILE_PAGES) - | ||
43 | total_swapcache_pages - i.bufferram; | ||
44 | if (cached < 0) | ||
45 | cached = 0; | ||
46 | |||
47 | get_vmalloc_info(&vmi); | ||
48 | |||
49 | for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) | ||
50 | pages[lru] = global_page_state(NR_LRU_BASE + lru); | ||
51 | |||
52 | /* | ||
53 | * Tagged format, for easy grepping and expansion. | ||
54 | */ | ||
55 | seq_printf(m, | ||
56 | "MemTotal: %8lu kB\n" | ||
57 | "MemFree: %8lu kB\n" | ||
58 | "Buffers: %8lu kB\n" | ||
59 | "Cached: %8lu kB\n" | ||
60 | "SwapCached: %8lu kB\n" | ||
61 | "Active: %8lu kB\n" | ||
62 | "Inactive: %8lu kB\n" | ||
63 | "Active(anon): %8lu kB\n" | ||
64 | "Inactive(anon): %8lu kB\n" | ||
65 | "Active(file): %8lu kB\n" | ||
66 | "Inactive(file): %8lu kB\n" | ||
67 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
68 | "Unevictable: %8lu kB\n" | ||
69 | "Mlocked: %8lu kB\n" | ||
70 | #endif | ||
71 | #ifdef CONFIG_HIGHMEM | ||
72 | "HighTotal: %8lu kB\n" | ||
73 | "HighFree: %8lu kB\n" | ||
74 | "LowTotal: %8lu kB\n" | ||
75 | "LowFree: %8lu kB\n" | ||
76 | #endif | ||
77 | "SwapTotal: %8lu kB\n" | ||
78 | "SwapFree: %8lu kB\n" | ||
79 | "Dirty: %8lu kB\n" | ||
80 | "Writeback: %8lu kB\n" | ||
81 | "AnonPages: %8lu kB\n" | ||
82 | "Mapped: %8lu kB\n" | ||
83 | "Slab: %8lu kB\n" | ||
84 | "SReclaimable: %8lu kB\n" | ||
85 | "SUnreclaim: %8lu kB\n" | ||
86 | "PageTables: %8lu kB\n" | ||
87 | #ifdef CONFIG_QUICKLIST | ||
88 | "Quicklists: %8lu kB\n" | ||
89 | #endif | ||
90 | "NFS_Unstable: %8lu kB\n" | ||
91 | "Bounce: %8lu kB\n" | ||
92 | "WritebackTmp: %8lu kB\n" | ||
93 | "CommitLimit: %8lu kB\n" | ||
94 | "Committed_AS: %8lu kB\n" | ||
95 | "VmallocTotal: %8lu kB\n" | ||
96 | "VmallocUsed: %8lu kB\n" | ||
97 | "VmallocChunk: %8lu kB\n", | ||
98 | K(i.totalram), | ||
99 | K(i.freeram), | ||
100 | K(i.bufferram), | ||
101 | K(cached), | ||
102 | K(total_swapcache_pages), | ||
103 | K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]), | ||
104 | K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]), | ||
105 | K(pages[LRU_ACTIVE_ANON]), | ||
106 | K(pages[LRU_INACTIVE_ANON]), | ||
107 | K(pages[LRU_ACTIVE_FILE]), | ||
108 | K(pages[LRU_INACTIVE_FILE]), | ||
109 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
110 | K(pages[LRU_UNEVICTABLE]), | ||
111 | K(global_page_state(NR_MLOCK)), | ||
112 | #endif | ||
113 | #ifdef CONFIG_HIGHMEM | ||
114 | K(i.totalhigh), | ||
115 | K(i.freehigh), | ||
116 | K(i.totalram-i.totalhigh), | ||
117 | K(i.freeram-i.freehigh), | ||
118 | #endif | ||
119 | K(i.totalswap), | ||
120 | K(i.freeswap), | ||
121 | K(global_page_state(NR_FILE_DIRTY)), | ||
122 | K(global_page_state(NR_WRITEBACK)), | ||
123 | K(global_page_state(NR_ANON_PAGES)), | ||
124 | K(global_page_state(NR_FILE_MAPPED)), | ||
125 | K(global_page_state(NR_SLAB_RECLAIMABLE) + | ||
126 | global_page_state(NR_SLAB_UNRECLAIMABLE)), | ||
127 | K(global_page_state(NR_SLAB_RECLAIMABLE)), | ||
128 | K(global_page_state(NR_SLAB_UNRECLAIMABLE)), | ||
129 | K(global_page_state(NR_PAGETABLE)), | ||
130 | #ifdef CONFIG_QUICKLIST | ||
131 | K(quicklist_total_size()), | ||
132 | #endif | ||
133 | K(global_page_state(NR_UNSTABLE_NFS)), | ||
134 | K(global_page_state(NR_BOUNCE)), | ||
135 | K(global_page_state(NR_WRITEBACK_TEMP)), | ||
136 | K(allowed), | ||
137 | K(committed), | ||
138 | (unsigned long)VMALLOC_TOTAL >> 10, | ||
139 | vmi.used >> 10, | ||
140 | vmi.largest_chunk >> 10 | ||
141 | ); | ||
142 | |||
143 | hugetlb_report_meminfo(m); | ||
144 | |||
145 | arch_report_meminfo(m); | ||
146 | |||
147 | return 0; | ||
148 | #undef K | ||
149 | } | ||
150 | |||
151 | static int meminfo_proc_open(struct inode *inode, struct file *file) | ||
152 | { | ||
153 | return single_open(file, meminfo_proc_show, NULL); | ||
154 | } | ||
155 | |||
156 | static const struct file_operations meminfo_proc_fops = { | ||
157 | .open = meminfo_proc_open, | ||
158 | .read = seq_read, | ||
159 | .llseek = seq_lseek, | ||
160 | .release = single_release, | ||
161 | }; | ||
162 | |||
163 | static int __init proc_meminfo_init(void) | ||
164 | { | ||
165 | proc_create("meminfo", 0, NULL, &meminfo_proc_fops); | ||
166 | return 0; | ||
167 | } | ||
168 | module_init(proc_meminfo_init); | ||
diff --git a/fs/proc/page.c b/fs/proc/page.c new file mode 100644 index 000000000000..767d95a6d1b1 --- /dev/null +++ b/fs/proc/page.c | |||
@@ -0,0 +1,147 @@ | |||
1 | #include <linux/bootmem.h> | ||
2 | #include <linux/compiler.h> | ||
3 | #include <linux/fs.h> | ||
4 | #include <linux/init.h> | ||
5 | #include <linux/mm.h> | ||
6 | #include <linux/mmzone.h> | ||
7 | #include <linux/proc_fs.h> | ||
8 | #include <linux/seq_file.h> | ||
9 | #include <asm/uaccess.h> | ||
10 | #include "internal.h" | ||
11 | |||
12 | #define KPMSIZE sizeof(u64) | ||
13 | #define KPMMASK (KPMSIZE - 1) | ||
14 | /* /proc/kpagecount - an array exposing page counts | ||
15 | * | ||
16 | * Each entry is a u64 representing the corresponding | ||
17 | * physical page count. | ||
18 | */ | ||
19 | static ssize_t kpagecount_read(struct file *file, char __user *buf, | ||
20 | size_t count, loff_t *ppos) | ||
21 | { | ||
22 | u64 __user *out = (u64 __user *)buf; | ||
23 | struct page *ppage; | ||
24 | unsigned long src = *ppos; | ||
25 | unsigned long pfn; | ||
26 | ssize_t ret = 0; | ||
27 | u64 pcount; | ||
28 | |||
29 | pfn = src / KPMSIZE; | ||
30 | count = min_t(size_t, count, (max_pfn * KPMSIZE) - src); | ||
31 | if (src & KPMMASK || count & KPMMASK) | ||
32 | return -EINVAL; | ||
33 | |||
34 | while (count > 0) { | ||
35 | ppage = NULL; | ||
36 | if (pfn_valid(pfn)) | ||
37 | ppage = pfn_to_page(pfn); | ||
38 | pfn++; | ||
39 | if (!ppage) | ||
40 | pcount = 0; | ||
41 | else | ||
42 | pcount = page_mapcount(ppage); | ||
43 | |||
44 | if (put_user(pcount, out++)) { | ||
45 | ret = -EFAULT; | ||
46 | break; | ||
47 | } | ||
48 | |||
49 | count -= KPMSIZE; | ||
50 | } | ||
51 | |||
52 | *ppos += (char __user *)out - buf; | ||
53 | if (!ret) | ||
54 | ret = (char __user *)out - buf; | ||
55 | return ret; | ||
56 | } | ||
57 | |||
58 | static const struct file_operations proc_kpagecount_operations = { | ||
59 | .llseek = mem_lseek, | ||
60 | .read = kpagecount_read, | ||
61 | }; | ||
62 | |||
63 | /* /proc/kpageflags - an array exposing page flags | ||
64 | * | ||
65 | * Each entry is a u64 representing the corresponding | ||
66 | * physical page flags. | ||
67 | */ | ||
68 | |||
69 | /* These macros are used to decouple internal flags from exported ones */ | ||
70 | |||
71 | #define KPF_LOCKED 0 | ||
72 | #define KPF_ERROR 1 | ||
73 | #define KPF_REFERENCED 2 | ||
74 | #define KPF_UPTODATE 3 | ||
75 | #define KPF_DIRTY 4 | ||
76 | #define KPF_LRU 5 | ||
77 | #define KPF_ACTIVE 6 | ||
78 | #define KPF_SLAB 7 | ||
79 | #define KPF_WRITEBACK 8 | ||
80 | #define KPF_RECLAIM 9 | ||
81 | #define KPF_BUDDY 10 | ||
82 | |||
83 | #define kpf_copy_bit(flags, srcpos, dstpos) (((flags >> srcpos) & 1) << dstpos) | ||
84 | |||
85 | static ssize_t kpageflags_read(struct file *file, char __user *buf, | ||
86 | size_t count, loff_t *ppos) | ||
87 | { | ||
88 | u64 __user *out = (u64 __user *)buf; | ||
89 | struct page *ppage; | ||
90 | unsigned long src = *ppos; | ||
91 | unsigned long pfn; | ||
92 | ssize_t ret = 0; | ||
93 | u64 kflags, uflags; | ||
94 | |||
95 | pfn = src / KPMSIZE; | ||
96 | count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src); | ||
97 | if (src & KPMMASK || count & KPMMASK) | ||
98 | return -EINVAL; | ||
99 | |||
100 | while (count > 0) { | ||
101 | ppage = NULL; | ||
102 | if (pfn_valid(pfn)) | ||
103 | ppage = pfn_to_page(pfn); | ||
104 | pfn++; | ||
105 | if (!ppage) | ||
106 | kflags = 0; | ||
107 | else | ||
108 | kflags = ppage->flags; | ||
109 | |||
110 | uflags = kpf_copy_bit(KPF_LOCKED, PG_locked, kflags) | | ||
111 | kpf_copy_bit(kflags, KPF_ERROR, PG_error) | | ||
112 | kpf_copy_bit(kflags, KPF_REFERENCED, PG_referenced) | | ||
113 | kpf_copy_bit(kflags, KPF_UPTODATE, PG_uptodate) | | ||
114 | kpf_copy_bit(kflags, KPF_DIRTY, PG_dirty) | | ||
115 | kpf_copy_bit(kflags, KPF_LRU, PG_lru) | | ||
116 | kpf_copy_bit(kflags, KPF_ACTIVE, PG_active) | | ||
117 | kpf_copy_bit(kflags, KPF_SLAB, PG_slab) | | ||
118 | kpf_copy_bit(kflags, KPF_WRITEBACK, PG_writeback) | | ||
119 | kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) | | ||
120 | kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy); | ||
121 | |||
122 | if (put_user(uflags, out++)) { | ||
123 | ret = -EFAULT; | ||
124 | break; | ||
125 | } | ||
126 | |||
127 | count -= KPMSIZE; | ||
128 | } | ||
129 | |||
130 | *ppos += (char __user *)out - buf; | ||
131 | if (!ret) | ||
132 | ret = (char __user *)out - buf; | ||
133 | return ret; | ||
134 | } | ||
135 | |||
136 | static const struct file_operations proc_kpageflags_operations = { | ||
137 | .llseek = mem_lseek, | ||
138 | .read = kpageflags_read, | ||
139 | }; | ||
140 | |||
141 | static int __init proc_page_init(void) | ||
142 | { | ||
143 | proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations); | ||
144 | proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations); | ||
145 | return 0; | ||
146 | } | ||
147 | module_init(proc_page_init); | ||
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index eca471bc8512..d777789b7a89 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright 1997 Paul Mackerras | 4 | * Copyright 1997 Paul Mackerras |
5 | */ | 5 | */ |
6 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
7 | #include <linux/init.h> | ||
7 | #include <linux/time.h> | 8 | #include <linux/time.h> |
8 | #include <linux/proc_fs.h> | 9 | #include <linux/proc_fs.h> |
9 | #include <linux/stat.h> | 10 | #include <linux/stat.h> |
@@ -214,7 +215,7 @@ void proc_device_tree_add_node(struct device_node *np, | |||
214 | /* | 215 | /* |
215 | * Called on initialization to set up the /proc/device-tree subtree | 216 | * Called on initialization to set up the /proc/device-tree subtree |
216 | */ | 217 | */ |
217 | void proc_device_tree_init(void) | 218 | void __init proc_device_tree_init(void) |
218 | { | 219 | { |
219 | struct device_node *root; | 220 | struct device_node *root; |
220 | if ( !have_of ) | 221 | if ( !have_of ) |
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c deleted file mode 100644 index 7ea52c79b2da..000000000000 --- a/fs/proc/proc_misc.c +++ /dev/null | |||
@@ -1,933 +0,0 @@ | |||
1 | /* | ||
2 | * linux/fs/proc/proc_misc.c | ||
3 | * | ||
4 | * linux/fs/proc/array.c | ||
5 | * Copyright (C) 1992 by Linus Torvalds | ||
6 | * based on ideas by Darren Senn | ||
7 | * | ||
8 | * This used to be the part of array.c. See the rest of history and credits | ||
9 | * there. I took this into a separate file and switched the thing to generic | ||
10 | * proc_file_inode_operations, leaving in array.c only per-process stuff. | ||
11 | * Inumbers allocation made dynamic (via create_proc_entry()). AV, May 1999. | ||
12 | * | ||
13 | * Changes: | ||
14 | * Fulton Green : Encapsulated position metric calculations. | ||
15 | * <kernel@FultonGreen.com> | ||
16 | */ | ||
17 | |||
18 | #include <linux/types.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/time.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/kernel_stat.h> | ||
23 | #include <linux/fs.h> | ||
24 | #include <linux/tty.h> | ||
25 | #include <linux/string.h> | ||
26 | #include <linux/mman.h> | ||
27 | #include <linux/quicklist.h> | ||
28 | #include <linux/proc_fs.h> | ||
29 | #include <linux/ioport.h> | ||
30 | #include <linux/mm.h> | ||
31 | #include <linux/mmzone.h> | ||
32 | #include <linux/pagemap.h> | ||
33 | #include <linux/irq.h> | ||
34 | #include <linux/interrupt.h> | ||
35 | #include <linux/swap.h> | ||
36 | #include <linux/slab.h> | ||
37 | #include <linux/genhd.h> | ||
38 | #include <linux/smp.h> | ||
39 | #include <linux/signal.h> | ||
40 | #include <linux/module.h> | ||
41 | #include <linux/init.h> | ||
42 | #include <linux/seq_file.h> | ||
43 | #include <linux/times.h> | ||
44 | #include <linux/profile.h> | ||
45 | #include <linux/utsname.h> | ||
46 | #include <linux/blkdev.h> | ||
47 | #include <linux/hugetlb.h> | ||
48 | #include <linux/jiffies.h> | ||
49 | #include <linux/vmalloc.h> | ||
50 | #include <linux/crash_dump.h> | ||
51 | #include <linux/pid_namespace.h> | ||
52 | #include <linux/bootmem.h> | ||
53 | #include <asm/uaccess.h> | ||
54 | #include <asm/pgtable.h> | ||
55 | #include <asm/io.h> | ||
56 | #include <asm/tlb.h> | ||
57 | #include <asm/div64.h> | ||
58 | #include "internal.h" | ||
59 | |||
60 | #define LOAD_INT(x) ((x) >> FSHIFT) | ||
61 | #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) | ||
62 | /* | ||
63 | * Warning: stuff below (imported functions) assumes that its output will fit | ||
64 | * into one page. For some of those functions it may be wrong. Moreover, we | ||
65 | * have a way to deal with that gracefully. Right now I used straightforward | ||
66 | * wrappers, but this needs further analysis wrt potential overflows. | ||
67 | */ | ||
68 | extern int get_hardware_list(char *); | ||
69 | extern int get_stram_list(char *); | ||
70 | extern int get_exec_domain_list(char *); | ||
71 | |||
72 | static int proc_calc_metrics(char *page, char **start, off_t off, | ||
73 | int count, int *eof, int len) | ||
74 | { | ||
75 | if (len <= off+count) *eof = 1; | ||
76 | *start = page + off; | ||
77 | len -= off; | ||
78 | if (len>count) len = count; | ||
79 | if (len<0) len = 0; | ||
80 | return len; | ||
81 | } | ||
82 | |||
83 | static int loadavg_read_proc(char *page, char **start, off_t off, | ||
84 | int count, int *eof, void *data) | ||
85 | { | ||
86 | int a, b, c; | ||
87 | int len; | ||
88 | unsigned long seq; | ||
89 | |||
90 | do { | ||
91 | seq = read_seqbegin(&xtime_lock); | ||
92 | a = avenrun[0] + (FIXED_1/200); | ||
93 | b = avenrun[1] + (FIXED_1/200); | ||
94 | c = avenrun[2] + (FIXED_1/200); | ||
95 | } while (read_seqretry(&xtime_lock, seq)); | ||
96 | |||
97 | len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n", | ||
98 | LOAD_INT(a), LOAD_FRAC(a), | ||
99 | LOAD_INT(b), LOAD_FRAC(b), | ||
100 | LOAD_INT(c), LOAD_FRAC(c), | ||
101 | nr_running(), nr_threads, | ||
102 | task_active_pid_ns(current)->last_pid); | ||
103 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
104 | } | ||
105 | |||
106 | static int uptime_read_proc(char *page, char **start, off_t off, | ||
107 | int count, int *eof, void *data) | ||
108 | { | ||
109 | struct timespec uptime; | ||
110 | struct timespec idle; | ||
111 | int len; | ||
112 | cputime_t idletime = cputime_add(init_task.utime, init_task.stime); | ||
113 | |||
114 | do_posix_clock_monotonic_gettime(&uptime); | ||
115 | monotonic_to_bootbased(&uptime); | ||
116 | cputime_to_timespec(idletime, &idle); | ||
117 | len = sprintf(page,"%lu.%02lu %lu.%02lu\n", | ||
118 | (unsigned long) uptime.tv_sec, | ||
119 | (uptime.tv_nsec / (NSEC_PER_SEC / 100)), | ||
120 | (unsigned long) idle.tv_sec, | ||
121 | (idle.tv_nsec / (NSEC_PER_SEC / 100))); | ||
122 | |||
123 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
124 | } | ||
125 | |||
126 | int __attribute__((weak)) arch_report_meminfo(char *page) | ||
127 | { | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int meminfo_read_proc(char *page, char **start, off_t off, | ||
132 | int count, int *eof, void *data) | ||
133 | { | ||
134 | struct sysinfo i; | ||
135 | int len; | ||
136 | unsigned long committed; | ||
137 | unsigned long allowed; | ||
138 | struct vmalloc_info vmi; | ||
139 | long cached; | ||
140 | unsigned long pages[NR_LRU_LISTS]; | ||
141 | int lru; | ||
142 | |||
143 | /* | ||
144 | * display in kilobytes. | ||
145 | */ | ||
146 | #define K(x) ((x) << (PAGE_SHIFT - 10)) | ||
147 | si_meminfo(&i); | ||
148 | si_swapinfo(&i); | ||
149 | committed = atomic_long_read(&vm_committed_space); | ||
150 | allowed = ((totalram_pages - hugetlb_total_pages()) | ||
151 | * sysctl_overcommit_ratio / 100) + total_swap_pages; | ||
152 | |||
153 | cached = global_page_state(NR_FILE_PAGES) - | ||
154 | total_swapcache_pages - i.bufferram; | ||
155 | if (cached < 0) | ||
156 | cached = 0; | ||
157 | |||
158 | get_vmalloc_info(&vmi); | ||
159 | |||
160 | for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) | ||
161 | pages[lru] = global_page_state(NR_LRU_BASE + lru); | ||
162 | |||
163 | /* | ||
164 | * Tagged format, for easy grepping and expansion. | ||
165 | */ | ||
166 | len = sprintf(page, | ||
167 | "MemTotal: %8lu kB\n" | ||
168 | "MemFree: %8lu kB\n" | ||
169 | "Buffers: %8lu kB\n" | ||
170 | "Cached: %8lu kB\n" | ||
171 | "SwapCached: %8lu kB\n" | ||
172 | "Active: %8lu kB\n" | ||
173 | "Inactive: %8lu kB\n" | ||
174 | "Active(anon): %8lu kB\n" | ||
175 | "Inactive(anon): %8lu kB\n" | ||
176 | "Active(file): %8lu kB\n" | ||
177 | "Inactive(file): %8lu kB\n" | ||
178 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
179 | "Unevictable: %8lu kB\n" | ||
180 | "Mlocked: %8lu kB\n" | ||
181 | #endif | ||
182 | #ifdef CONFIG_HIGHMEM | ||
183 | "HighTotal: %8lu kB\n" | ||
184 | "HighFree: %8lu kB\n" | ||
185 | "LowTotal: %8lu kB\n" | ||
186 | "LowFree: %8lu kB\n" | ||
187 | #endif | ||
188 | "SwapTotal: %8lu kB\n" | ||
189 | "SwapFree: %8lu kB\n" | ||
190 | "Dirty: %8lu kB\n" | ||
191 | "Writeback: %8lu kB\n" | ||
192 | "AnonPages: %8lu kB\n" | ||
193 | "Mapped: %8lu kB\n" | ||
194 | "Slab: %8lu kB\n" | ||
195 | "SReclaimable: %8lu kB\n" | ||
196 | "SUnreclaim: %8lu kB\n" | ||
197 | "PageTables: %8lu kB\n" | ||
198 | #ifdef CONFIG_QUICKLIST | ||
199 | "Quicklists: %8lu kB\n" | ||
200 | #endif | ||
201 | "NFS_Unstable: %8lu kB\n" | ||
202 | "Bounce: %8lu kB\n" | ||
203 | "WritebackTmp: %8lu kB\n" | ||
204 | "CommitLimit: %8lu kB\n" | ||
205 | "Committed_AS: %8lu kB\n" | ||
206 | "VmallocTotal: %8lu kB\n" | ||
207 | "VmallocUsed: %8lu kB\n" | ||
208 | "VmallocChunk: %8lu kB\n", | ||
209 | K(i.totalram), | ||
210 | K(i.freeram), | ||
211 | K(i.bufferram), | ||
212 | K(cached), | ||
213 | K(total_swapcache_pages), | ||
214 | K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]), | ||
215 | K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]), | ||
216 | K(pages[LRU_ACTIVE_ANON]), | ||
217 | K(pages[LRU_INACTIVE_ANON]), | ||
218 | K(pages[LRU_ACTIVE_FILE]), | ||
219 | K(pages[LRU_INACTIVE_FILE]), | ||
220 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
221 | K(pages[LRU_UNEVICTABLE]), | ||
222 | K(global_page_state(NR_MLOCK)), | ||
223 | #endif | ||
224 | #ifdef CONFIG_HIGHMEM | ||
225 | K(i.totalhigh), | ||
226 | K(i.freehigh), | ||
227 | K(i.totalram-i.totalhigh), | ||
228 | K(i.freeram-i.freehigh), | ||
229 | #endif | ||
230 | K(i.totalswap), | ||
231 | K(i.freeswap), | ||
232 | K(global_page_state(NR_FILE_DIRTY)), | ||
233 | K(global_page_state(NR_WRITEBACK)), | ||
234 | K(global_page_state(NR_ANON_PAGES)), | ||
235 | K(global_page_state(NR_FILE_MAPPED)), | ||
236 | K(global_page_state(NR_SLAB_RECLAIMABLE) + | ||
237 | global_page_state(NR_SLAB_UNRECLAIMABLE)), | ||
238 | K(global_page_state(NR_SLAB_RECLAIMABLE)), | ||
239 | K(global_page_state(NR_SLAB_UNRECLAIMABLE)), | ||
240 | K(global_page_state(NR_PAGETABLE)), | ||
241 | #ifdef CONFIG_QUICKLIST | ||
242 | K(quicklist_total_size()), | ||
243 | #endif | ||
244 | K(global_page_state(NR_UNSTABLE_NFS)), | ||
245 | K(global_page_state(NR_BOUNCE)), | ||
246 | K(global_page_state(NR_WRITEBACK_TEMP)), | ||
247 | K(allowed), | ||
248 | K(committed), | ||
249 | (unsigned long)VMALLOC_TOTAL >> 10, | ||
250 | vmi.used >> 10, | ||
251 | vmi.largest_chunk >> 10 | ||
252 | ); | ||
253 | |||
254 | len += hugetlb_report_meminfo(page + len); | ||
255 | |||
256 | len += arch_report_meminfo(page + len); | ||
257 | |||
258 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
259 | #undef K | ||
260 | } | ||
261 | |||
262 | static int fragmentation_open(struct inode *inode, struct file *file) | ||
263 | { | ||
264 | (void)inode; | ||
265 | return seq_open(file, &fragmentation_op); | ||
266 | } | ||
267 | |||
268 | static const struct file_operations fragmentation_file_operations = { | ||
269 | .open = fragmentation_open, | ||
270 | .read = seq_read, | ||
271 | .llseek = seq_lseek, | ||
272 | .release = seq_release, | ||
273 | }; | ||
274 | |||
275 | static int pagetypeinfo_open(struct inode *inode, struct file *file) | ||
276 | { | ||
277 | return seq_open(file, &pagetypeinfo_op); | ||
278 | } | ||
279 | |||
280 | static const struct file_operations pagetypeinfo_file_ops = { | ||
281 | .open = pagetypeinfo_open, | ||
282 | .read = seq_read, | ||
283 | .llseek = seq_lseek, | ||
284 | .release = seq_release, | ||
285 | }; | ||
286 | |||
287 | static int zoneinfo_open(struct inode *inode, struct file *file) | ||
288 | { | ||
289 | return seq_open(file, &zoneinfo_op); | ||
290 | } | ||
291 | |||
292 | static const struct file_operations proc_zoneinfo_file_operations = { | ||
293 | .open = zoneinfo_open, | ||
294 | .read = seq_read, | ||
295 | .llseek = seq_lseek, | ||
296 | .release = seq_release, | ||
297 | }; | ||
298 | |||
299 | static int version_read_proc(char *page, char **start, off_t off, | ||
300 | int count, int *eof, void *data) | ||
301 | { | ||
302 | int len; | ||
303 | |||
304 | len = snprintf(page, PAGE_SIZE, linux_proc_banner, | ||
305 | utsname()->sysname, | ||
306 | utsname()->release, | ||
307 | utsname()->version); | ||
308 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
309 | } | ||
310 | |||
311 | extern const struct seq_operations cpuinfo_op; | ||
312 | static int cpuinfo_open(struct inode *inode, struct file *file) | ||
313 | { | ||
314 | return seq_open(file, &cpuinfo_op); | ||
315 | } | ||
316 | |||
317 | static const struct file_operations proc_cpuinfo_operations = { | ||
318 | .open = cpuinfo_open, | ||
319 | .read = seq_read, | ||
320 | .llseek = seq_lseek, | ||
321 | .release = seq_release, | ||
322 | }; | ||
323 | |||
324 | static int devinfo_show(struct seq_file *f, void *v) | ||
325 | { | ||
326 | int i = *(loff_t *) v; | ||
327 | |||
328 | if (i < CHRDEV_MAJOR_HASH_SIZE) { | ||
329 | if (i == 0) | ||
330 | seq_printf(f, "Character devices:\n"); | ||
331 | chrdev_show(f, i); | ||
332 | } | ||
333 | #ifdef CONFIG_BLOCK | ||
334 | else { | ||
335 | i -= CHRDEV_MAJOR_HASH_SIZE; | ||
336 | if (i == 0) | ||
337 | seq_printf(f, "\nBlock devices:\n"); | ||
338 | blkdev_show(f, i); | ||
339 | } | ||
340 | #endif | ||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | static void *devinfo_start(struct seq_file *f, loff_t *pos) | ||
345 | { | ||
346 | if (*pos < (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE)) | ||
347 | return pos; | ||
348 | return NULL; | ||
349 | } | ||
350 | |||
351 | static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos) | ||
352 | { | ||
353 | (*pos)++; | ||
354 | if (*pos >= (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE)) | ||
355 | return NULL; | ||
356 | return pos; | ||
357 | } | ||
358 | |||
359 | static void devinfo_stop(struct seq_file *f, void *v) | ||
360 | { | ||
361 | /* Nothing to do */ | ||
362 | } | ||
363 | |||
364 | static const struct seq_operations devinfo_ops = { | ||
365 | .start = devinfo_start, | ||
366 | .next = devinfo_next, | ||
367 | .stop = devinfo_stop, | ||
368 | .show = devinfo_show | ||
369 | }; | ||
370 | |||
371 | static int devinfo_open(struct inode *inode, struct file *filp) | ||
372 | { | ||
373 | return seq_open(filp, &devinfo_ops); | ||
374 | } | ||
375 | |||
376 | static const struct file_operations proc_devinfo_operations = { | ||
377 | .open = devinfo_open, | ||
378 | .read = seq_read, | ||
379 | .llseek = seq_lseek, | ||
380 | .release = seq_release, | ||
381 | }; | ||
382 | |||
383 | static int vmstat_open(struct inode *inode, struct file *file) | ||
384 | { | ||
385 | return seq_open(file, &vmstat_op); | ||
386 | } | ||
387 | static const struct file_operations proc_vmstat_file_operations = { | ||
388 | .open = vmstat_open, | ||
389 | .read = seq_read, | ||
390 | .llseek = seq_lseek, | ||
391 | .release = seq_release, | ||
392 | }; | ||
393 | |||
394 | #ifdef CONFIG_PROC_HARDWARE | ||
395 | static int hardware_read_proc(char *page, char **start, off_t off, | ||
396 | int count, int *eof, void *data) | ||
397 | { | ||
398 | int len = get_hardware_list(page); | ||
399 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
400 | } | ||
401 | #endif | ||
402 | |||
403 | #ifdef CONFIG_STRAM_PROC | ||
404 | static int stram_read_proc(char *page, char **start, off_t off, | ||
405 | int count, int *eof, void *data) | ||
406 | { | ||
407 | int len = get_stram_list(page); | ||
408 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
409 | } | ||
410 | #endif | ||
411 | |||
412 | #ifdef CONFIG_BLOCK | ||
413 | static int partitions_open(struct inode *inode, struct file *file) | ||
414 | { | ||
415 | return seq_open(file, &partitions_op); | ||
416 | } | ||
417 | static const struct file_operations proc_partitions_operations = { | ||
418 | .open = partitions_open, | ||
419 | .read = seq_read, | ||
420 | .llseek = seq_lseek, | ||
421 | .release = seq_release, | ||
422 | }; | ||
423 | |||
424 | static int diskstats_open(struct inode *inode, struct file *file) | ||
425 | { | ||
426 | return seq_open(file, &diskstats_op); | ||
427 | } | ||
428 | static const struct file_operations proc_diskstats_operations = { | ||
429 | .open = diskstats_open, | ||
430 | .read = seq_read, | ||
431 | .llseek = seq_lseek, | ||
432 | .release = seq_release, | ||
433 | }; | ||
434 | #endif | ||
435 | |||
436 | #ifdef CONFIG_MODULES | ||
437 | extern const struct seq_operations modules_op; | ||
438 | static int modules_open(struct inode *inode, struct file *file) | ||
439 | { | ||
440 | return seq_open(file, &modules_op); | ||
441 | } | ||
442 | static const struct file_operations proc_modules_operations = { | ||
443 | .open = modules_open, | ||
444 | .read = seq_read, | ||
445 | .llseek = seq_lseek, | ||
446 | .release = seq_release, | ||
447 | }; | ||
448 | #endif | ||
449 | |||
450 | #ifdef CONFIG_SLABINFO | ||
451 | static int slabinfo_open(struct inode *inode, struct file *file) | ||
452 | { | ||
453 | return seq_open(file, &slabinfo_op); | ||
454 | } | ||
455 | static const struct file_operations proc_slabinfo_operations = { | ||
456 | .open = slabinfo_open, | ||
457 | .read = seq_read, | ||
458 | .write = slabinfo_write, | ||
459 | .llseek = seq_lseek, | ||
460 | .release = seq_release, | ||
461 | }; | ||
462 | |||
463 | #ifdef CONFIG_DEBUG_SLAB_LEAK | ||
464 | extern const struct seq_operations slabstats_op; | ||
465 | static int slabstats_open(struct inode *inode, struct file *file) | ||
466 | { | ||
467 | unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); | ||
468 | int ret = -ENOMEM; | ||
469 | if (n) { | ||
470 | ret = seq_open(file, &slabstats_op); | ||
471 | if (!ret) { | ||
472 | struct seq_file *m = file->private_data; | ||
473 | *n = PAGE_SIZE / (2 * sizeof(unsigned long)); | ||
474 | m->private = n; | ||
475 | n = NULL; | ||
476 | } | ||
477 | kfree(n); | ||
478 | } | ||
479 | return ret; | ||
480 | } | ||
481 | |||
482 | static const struct file_operations proc_slabstats_operations = { | ||
483 | .open = slabstats_open, | ||
484 | .read = seq_read, | ||
485 | .llseek = seq_lseek, | ||
486 | .release = seq_release_private, | ||
487 | }; | ||
488 | #endif | ||
489 | #endif | ||
490 | |||
491 | #ifdef CONFIG_MMU | ||
492 | static int vmalloc_open(struct inode *inode, struct file *file) | ||
493 | { | ||
494 | unsigned int *ptr = NULL; | ||
495 | int ret; | ||
496 | |||
497 | if (NUMA_BUILD) | ||
498 | ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL); | ||
499 | ret = seq_open(file, &vmalloc_op); | ||
500 | if (!ret) { | ||
501 | struct seq_file *m = file->private_data; | ||
502 | m->private = ptr; | ||
503 | } else | ||
504 | kfree(ptr); | ||
505 | return ret; | ||
506 | } | ||
507 | |||
508 | static const struct file_operations proc_vmalloc_operations = { | ||
509 | .open = vmalloc_open, | ||
510 | .read = seq_read, | ||
511 | .llseek = seq_lseek, | ||
512 | .release = seq_release_private, | ||
513 | }; | ||
514 | #endif | ||
515 | |||
516 | #ifndef arch_irq_stat_cpu | ||
517 | #define arch_irq_stat_cpu(cpu) 0 | ||
518 | #endif | ||
519 | #ifndef arch_irq_stat | ||
520 | #define arch_irq_stat() 0 | ||
521 | #endif | ||
522 | |||
523 | static int show_stat(struct seq_file *p, void *v) | ||
524 | { | ||
525 | int i, j; | ||
526 | unsigned long jif; | ||
527 | cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; | ||
528 | cputime64_t guest; | ||
529 | u64 sum = 0; | ||
530 | struct timespec boottime; | ||
531 | unsigned int per_irq_sum; | ||
532 | |||
533 | user = nice = system = idle = iowait = | ||
534 | irq = softirq = steal = cputime64_zero; | ||
535 | guest = cputime64_zero; | ||
536 | getboottime(&boottime); | ||
537 | jif = boottime.tv_sec; | ||
538 | |||
539 | for_each_possible_cpu(i) { | ||
540 | user = cputime64_add(user, kstat_cpu(i).cpustat.user); | ||
541 | nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice); | ||
542 | system = cputime64_add(system, kstat_cpu(i).cpustat.system); | ||
543 | idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle); | ||
544 | iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait); | ||
545 | irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq); | ||
546 | softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); | ||
547 | steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); | ||
548 | guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); | ||
549 | |||
550 | for_each_irq_nr(j) | ||
551 | sum += kstat_irqs_cpu(j, i); | ||
552 | |||
553 | sum += arch_irq_stat_cpu(i); | ||
554 | } | ||
555 | sum += arch_irq_stat(); | ||
556 | |||
557 | seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", | ||
558 | (unsigned long long)cputime64_to_clock_t(user), | ||
559 | (unsigned long long)cputime64_to_clock_t(nice), | ||
560 | (unsigned long long)cputime64_to_clock_t(system), | ||
561 | (unsigned long long)cputime64_to_clock_t(idle), | ||
562 | (unsigned long long)cputime64_to_clock_t(iowait), | ||
563 | (unsigned long long)cputime64_to_clock_t(irq), | ||
564 | (unsigned long long)cputime64_to_clock_t(softirq), | ||
565 | (unsigned long long)cputime64_to_clock_t(steal), | ||
566 | (unsigned long long)cputime64_to_clock_t(guest)); | ||
567 | for_each_online_cpu(i) { | ||
568 | |||
569 | /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ | ||
570 | user = kstat_cpu(i).cpustat.user; | ||
571 | nice = kstat_cpu(i).cpustat.nice; | ||
572 | system = kstat_cpu(i).cpustat.system; | ||
573 | idle = kstat_cpu(i).cpustat.idle; | ||
574 | iowait = kstat_cpu(i).cpustat.iowait; | ||
575 | irq = kstat_cpu(i).cpustat.irq; | ||
576 | softirq = kstat_cpu(i).cpustat.softirq; | ||
577 | steal = kstat_cpu(i).cpustat.steal; | ||
578 | guest = kstat_cpu(i).cpustat.guest; | ||
579 | seq_printf(p, | ||
580 | "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", | ||
581 | i, | ||
582 | (unsigned long long)cputime64_to_clock_t(user), | ||
583 | (unsigned long long)cputime64_to_clock_t(nice), | ||
584 | (unsigned long long)cputime64_to_clock_t(system), | ||
585 | (unsigned long long)cputime64_to_clock_t(idle), | ||
586 | (unsigned long long)cputime64_to_clock_t(iowait), | ||
587 | (unsigned long long)cputime64_to_clock_t(irq), | ||
588 | (unsigned long long)cputime64_to_clock_t(softirq), | ||
589 | (unsigned long long)cputime64_to_clock_t(steal), | ||
590 | (unsigned long long)cputime64_to_clock_t(guest)); | ||
591 | } | ||
592 | seq_printf(p, "intr %llu", (unsigned long long)sum); | ||
593 | |||
594 | /* sum again ? it could be updated? */ | ||
595 | for_each_irq_nr(j) { | ||
596 | per_irq_sum = 0; | ||
597 | |||
598 | for_each_possible_cpu(i) | ||
599 | per_irq_sum += kstat_irqs_cpu(j, i); | ||
600 | |||
601 | seq_printf(p, " %u", per_irq_sum); | ||
602 | } | ||
603 | |||
604 | seq_printf(p, | ||
605 | "\nctxt %llu\n" | ||
606 | "btime %lu\n" | ||
607 | "processes %lu\n" | ||
608 | "procs_running %lu\n" | ||
609 | "procs_blocked %lu\n", | ||
610 | nr_context_switches(), | ||
611 | (unsigned long)jif, | ||
612 | total_forks, | ||
613 | nr_running(), | ||
614 | nr_iowait()); | ||
615 | |||
616 | return 0; | ||
617 | } | ||
618 | |||
619 | static int stat_open(struct inode *inode, struct file *file) | ||
620 | { | ||
621 | unsigned size = 4096 * (1 + num_possible_cpus() / 32); | ||
622 | char *buf; | ||
623 | struct seq_file *m; | ||
624 | int res; | ||
625 | |||
626 | /* don't ask for more than the kmalloc() max size, currently 128 KB */ | ||
627 | if (size > 128 * 1024) | ||
628 | size = 128 * 1024; | ||
629 | buf = kmalloc(size, GFP_KERNEL); | ||
630 | if (!buf) | ||
631 | return -ENOMEM; | ||
632 | |||
633 | res = single_open(file, show_stat, NULL); | ||
634 | if (!res) { | ||
635 | m = file->private_data; | ||
636 | m->buf = buf; | ||
637 | m->size = size; | ||
638 | } else | ||
639 | kfree(buf); | ||
640 | return res; | ||
641 | } | ||
642 | static const struct file_operations proc_stat_operations = { | ||
643 | .open = stat_open, | ||
644 | .read = seq_read, | ||
645 | .llseek = seq_lseek, | ||
646 | .release = single_release, | ||
647 | }; | ||
648 | |||
649 | /* | ||
650 | * /proc/interrupts | ||
651 | */ | ||
652 | static void *int_seq_start(struct seq_file *f, loff_t *pos) | ||
653 | { | ||
654 | return (*pos <= nr_irqs) ? pos : NULL; | ||
655 | } | ||
656 | |||
657 | |||
658 | static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) | ||
659 | { | ||
660 | (*pos)++; | ||
661 | return (*pos <= nr_irqs) ? pos : NULL; | ||
662 | } | ||
663 | |||
664 | static void int_seq_stop(struct seq_file *f, void *v) | ||
665 | { | ||
666 | /* Nothing to do */ | ||
667 | } | ||
668 | |||
669 | static const struct seq_operations int_seq_ops = { | ||
670 | .start = int_seq_start, | ||
671 | .next = int_seq_next, | ||
672 | .stop = int_seq_stop, | ||
673 | .show = show_interrupts | ||
674 | }; | ||
675 | |||
676 | static int interrupts_open(struct inode *inode, struct file *filp) | ||
677 | { | ||
678 | return seq_open(filp, &int_seq_ops); | ||
679 | } | ||
680 | |||
681 | static const struct file_operations proc_interrupts_operations = { | ||
682 | .open = interrupts_open, | ||
683 | .read = seq_read, | ||
684 | .llseek = seq_lseek, | ||
685 | .release = seq_release, | ||
686 | }; | ||
687 | |||
688 | static int filesystems_read_proc(char *page, char **start, off_t off, | ||
689 | int count, int *eof, void *data) | ||
690 | { | ||
691 | int len = get_filesystem_list(page); | ||
692 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
693 | } | ||
694 | |||
695 | static int cmdline_read_proc(char *page, char **start, off_t off, | ||
696 | int count, int *eof, void *data) | ||
697 | { | ||
698 | int len; | ||
699 | |||
700 | len = sprintf(page, "%s\n", saved_command_line); | ||
701 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
702 | } | ||
703 | |||
704 | #ifdef CONFIG_FILE_LOCKING | ||
705 | static int locks_open(struct inode *inode, struct file *filp) | ||
706 | { | ||
707 | return seq_open(filp, &locks_seq_operations); | ||
708 | } | ||
709 | |||
710 | static const struct file_operations proc_locks_operations = { | ||
711 | .open = locks_open, | ||
712 | .read = seq_read, | ||
713 | .llseek = seq_lseek, | ||
714 | .release = seq_release, | ||
715 | }; | ||
716 | #endif /* CONFIG_FILE_LOCKING */ | ||
717 | |||
718 | static int execdomains_read_proc(char *page, char **start, off_t off, | ||
719 | int count, int *eof, void *data) | ||
720 | { | ||
721 | int len = get_exec_domain_list(page); | ||
722 | return proc_calc_metrics(page, start, off, count, eof, len); | ||
723 | } | ||
724 | |||
725 | #ifdef CONFIG_PROC_PAGE_MONITOR | ||
726 | #define KPMSIZE sizeof(u64) | ||
727 | #define KPMMASK (KPMSIZE - 1) | ||
728 | /* /proc/kpagecount - an array exposing page counts | ||
729 | * | ||
730 | * Each entry is a u64 representing the corresponding | ||
731 | * physical page count. | ||
732 | */ | ||
733 | static ssize_t kpagecount_read(struct file *file, char __user *buf, | ||
734 | size_t count, loff_t *ppos) | ||
735 | { | ||
736 | u64 __user *out = (u64 __user *)buf; | ||
737 | struct page *ppage; | ||
738 | unsigned long src = *ppos; | ||
739 | unsigned long pfn; | ||
740 | ssize_t ret = 0; | ||
741 | u64 pcount; | ||
742 | |||
743 | pfn = src / KPMSIZE; | ||
744 | count = min_t(size_t, count, (max_pfn * KPMSIZE) - src); | ||
745 | if (src & KPMMASK || count & KPMMASK) | ||
746 | return -EINVAL; | ||
747 | |||
748 | while (count > 0) { | ||
749 | ppage = NULL; | ||
750 | if (pfn_valid(pfn)) | ||
751 | ppage = pfn_to_page(pfn); | ||
752 | pfn++; | ||
753 | if (!ppage) | ||
754 | pcount = 0; | ||
755 | else | ||
756 | pcount = page_mapcount(ppage); | ||
757 | |||
758 | if (put_user(pcount, out++)) { | ||
759 | ret = -EFAULT; | ||
760 | break; | ||
761 | } | ||
762 | |||
763 | count -= KPMSIZE; | ||
764 | } | ||
765 | |||
766 | *ppos += (char __user *)out - buf; | ||
767 | if (!ret) | ||
768 | ret = (char __user *)out - buf; | ||
769 | return ret; | ||
770 | } | ||
771 | |||
772 | static struct file_operations proc_kpagecount_operations = { | ||
773 | .llseek = mem_lseek, | ||
774 | .read = kpagecount_read, | ||
775 | }; | ||
776 | |||
777 | /* /proc/kpageflags - an array exposing page flags | ||
778 | * | ||
779 | * Each entry is a u64 representing the corresponding | ||
780 | * physical page flags. | ||
781 | */ | ||
782 | |||
783 | /* These macros are used to decouple internal flags from exported ones */ | ||
784 | |||
785 | #define KPF_LOCKED 0 | ||
786 | #define KPF_ERROR 1 | ||
787 | #define KPF_REFERENCED 2 | ||
788 | #define KPF_UPTODATE 3 | ||
789 | #define KPF_DIRTY 4 | ||
790 | #define KPF_LRU 5 | ||
791 | #define KPF_ACTIVE 6 | ||
792 | #define KPF_SLAB 7 | ||
793 | #define KPF_WRITEBACK 8 | ||
794 | #define KPF_RECLAIM 9 | ||
795 | #define KPF_BUDDY 10 | ||
796 | |||
797 | #define kpf_copy_bit(flags, srcpos, dstpos) (((flags >> srcpos) & 1) << dstpos) | ||
798 | |||
799 | static ssize_t kpageflags_read(struct file *file, char __user *buf, | ||
800 | size_t count, loff_t *ppos) | ||
801 | { | ||
802 | u64 __user *out = (u64 __user *)buf; | ||
803 | struct page *ppage; | ||
804 | unsigned long src = *ppos; | ||
805 | unsigned long pfn; | ||
806 | ssize_t ret = 0; | ||
807 | u64 kflags, uflags; | ||
808 | |||
809 | pfn = src / KPMSIZE; | ||
810 | count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src); | ||
811 | if (src & KPMMASK || count & KPMMASK) | ||
812 | return -EINVAL; | ||
813 | |||
814 | while (count > 0) { | ||
815 | ppage = NULL; | ||
816 | if (pfn_valid(pfn)) | ||
817 | ppage = pfn_to_page(pfn); | ||
818 | pfn++; | ||
819 | if (!ppage) | ||
820 | kflags = 0; | ||
821 | else | ||
822 | kflags = ppage->flags; | ||
823 | |||
824 | uflags = kpf_copy_bit(KPF_LOCKED, PG_locked, kflags) | | ||
825 | kpf_copy_bit(kflags, KPF_ERROR, PG_error) | | ||
826 | kpf_copy_bit(kflags, KPF_REFERENCED, PG_referenced) | | ||
827 | kpf_copy_bit(kflags, KPF_UPTODATE, PG_uptodate) | | ||
828 | kpf_copy_bit(kflags, KPF_DIRTY, PG_dirty) | | ||
829 | kpf_copy_bit(kflags, KPF_LRU, PG_lru) | | ||
830 | kpf_copy_bit(kflags, KPF_ACTIVE, PG_active) | | ||
831 | kpf_copy_bit(kflags, KPF_SLAB, PG_slab) | | ||
832 | kpf_copy_bit(kflags, KPF_WRITEBACK, PG_writeback) | | ||
833 | kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) | | ||
834 | kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy); | ||
835 | |||
836 | if (put_user(uflags, out++)) { | ||
837 | ret = -EFAULT; | ||
838 | break; | ||
839 | } | ||
840 | |||
841 | count -= KPMSIZE; | ||
842 | } | ||
843 | |||
844 | *ppos += (char __user *)out - buf; | ||
845 | if (!ret) | ||
846 | ret = (char __user *)out - buf; | ||
847 | return ret; | ||
848 | } | ||
849 | |||
850 | static struct file_operations proc_kpageflags_operations = { | ||
851 | .llseek = mem_lseek, | ||
852 | .read = kpageflags_read, | ||
853 | }; | ||
854 | #endif /* CONFIG_PROC_PAGE_MONITOR */ | ||
855 | |||
856 | struct proc_dir_entry *proc_root_kcore; | ||
857 | |||
858 | void __init proc_misc_init(void) | ||
859 | { | ||
860 | static struct { | ||
861 | char *name; | ||
862 | int (*read_proc)(char*,char**,off_t,int,int*,void*); | ||
863 | } *p, simple_ones[] = { | ||
864 | {"loadavg", loadavg_read_proc}, | ||
865 | {"uptime", uptime_read_proc}, | ||
866 | {"meminfo", meminfo_read_proc}, | ||
867 | {"version", version_read_proc}, | ||
868 | #ifdef CONFIG_PROC_HARDWARE | ||
869 | {"hardware", hardware_read_proc}, | ||
870 | #endif | ||
871 | #ifdef CONFIG_STRAM_PROC | ||
872 | {"stram", stram_read_proc}, | ||
873 | #endif | ||
874 | {"filesystems", filesystems_read_proc}, | ||
875 | {"cmdline", cmdline_read_proc}, | ||
876 | {"execdomains", execdomains_read_proc}, | ||
877 | {NULL,} | ||
878 | }; | ||
879 | for (p = simple_ones; p->name; p++) | ||
880 | create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL); | ||
881 | |||
882 | proc_symlink("mounts", NULL, "self/mounts"); | ||
883 | |||
884 | /* And now for trickier ones */ | ||
885 | #ifdef CONFIG_PRINTK | ||
886 | proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); | ||
887 | #endif | ||
888 | #ifdef CONFIG_FILE_LOCKING | ||
889 | proc_create("locks", 0, NULL, &proc_locks_operations); | ||
890 | #endif | ||
891 | proc_create("devices", 0, NULL, &proc_devinfo_operations); | ||
892 | proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); | ||
893 | #ifdef CONFIG_BLOCK | ||
894 | proc_create("partitions", 0, NULL, &proc_partitions_operations); | ||
895 | #endif | ||
896 | proc_create("stat", 0, NULL, &proc_stat_operations); | ||
897 | proc_create("interrupts", 0, NULL, &proc_interrupts_operations); | ||
898 | #ifdef CONFIG_SLABINFO | ||
899 | proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); | ||
900 | #ifdef CONFIG_DEBUG_SLAB_LEAK | ||
901 | proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); | ||
902 | #endif | ||
903 | #endif | ||
904 | #ifdef CONFIG_MMU | ||
905 | proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); | ||
906 | #endif | ||
907 | proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); | ||
908 | proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); | ||
909 | proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); | ||
910 | proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); | ||
911 | #ifdef CONFIG_BLOCK | ||
912 | proc_create("diskstats", 0, NULL, &proc_diskstats_operations); | ||
913 | #endif | ||
914 | #ifdef CONFIG_MODULES | ||
915 | proc_create("modules", 0, NULL, &proc_modules_operations); | ||
916 | #endif | ||
917 | #ifdef CONFIG_SCHEDSTATS | ||
918 | proc_create("schedstat", 0, NULL, &proc_schedstat_operations); | ||
919 | #endif | ||
920 | #ifdef CONFIG_PROC_KCORE | ||
921 | proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations); | ||
922 | if (proc_root_kcore) | ||
923 | proc_root_kcore->size = | ||
924 | (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE; | ||
925 | #endif | ||
926 | #ifdef CONFIG_PROC_PAGE_MONITOR | ||
927 | proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations); | ||
928 | proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations); | ||
929 | #endif | ||
930 | #ifdef CONFIG_PROC_VMCORE | ||
931 | proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); | ||
932 | #endif | ||
933 | } | ||
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 7b997754a25e..94fcfff6863a 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * /proc/sys support | 2 | * /proc/sys support |
3 | */ | 3 | */ |
4 | 4 | #include <linux/init.h> | |
5 | #include <linux/sysctl.h> | 5 | #include <linux/sysctl.h> |
6 | #include <linux/proc_fs.h> | 6 | #include <linux/proc_fs.h> |
7 | #include <linux/security.h> | 7 | #include <linux/security.h> |
@@ -402,7 +402,7 @@ static struct dentry_operations proc_sys_dentry_operations = { | |||
402 | .d_compare = proc_sys_compare, | 402 | .d_compare = proc_sys_compare, |
403 | }; | 403 | }; |
404 | 404 | ||
405 | int proc_sys_init(void) | 405 | int __init proc_sys_init(void) |
406 | { | 406 | { |
407 | struct proc_dir_entry *proc_sys_root; | 407 | struct proc_dir_entry *proc_sys_root; |
408 | 408 | ||
diff --git a/fs/proc/root.c b/fs/proc/root.c index 95117538a4f6..7761602af9de 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -104,9 +104,9 @@ static struct file_system_type proc_fs_type = { | |||
104 | 104 | ||
105 | void __init proc_root_init(void) | 105 | void __init proc_root_init(void) |
106 | { | 106 | { |
107 | int err = proc_init_inodecache(); | 107 | int err; |
108 | if (err) | 108 | |
109 | return; | 109 | proc_init_inodecache(); |
110 | err = register_filesystem(&proc_fs_type); | 110 | err = register_filesystem(&proc_fs_type); |
111 | if (err) | 111 | if (err) |
112 | return; | 112 | return; |
@@ -117,7 +117,7 @@ void __init proc_root_init(void) | |||
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | 119 | ||
120 | proc_misc_init(); | 120 | proc_symlink("mounts", NULL, "self/mounts"); |
121 | 121 | ||
122 | proc_net_init(); | 122 | proc_net_init(); |
123 | 123 | ||
diff --git a/fs/proc/stat.c b/fs/proc/stat.c new file mode 100644 index 000000000000..81904f07679d --- /dev/null +++ b/fs/proc/stat.c | |||
@@ -0,0 +1,153 @@ | |||
1 | #include <linux/cpumask.h> | ||
2 | #include <linux/fs.h> | ||
3 | #include <linux/gfp.h> | ||
4 | #include <linux/init.h> | ||
5 | #include <linux/interrupt.h> | ||
6 | #include <linux/kernel_stat.h> | ||
7 | #include <linux/proc_fs.h> | ||
8 | #include <linux/sched.h> | ||
9 | #include <linux/seq_file.h> | ||
10 | #include <linux/slab.h> | ||
11 | #include <linux/time.h> | ||
12 | #include <asm/cputime.h> | ||
13 | |||
14 | #ifndef arch_irq_stat_cpu | ||
15 | #define arch_irq_stat_cpu(cpu) 0 | ||
16 | #endif | ||
17 | #ifndef arch_irq_stat | ||
18 | #define arch_irq_stat() 0 | ||
19 | #endif | ||
20 | |||
21 | static int show_stat(struct seq_file *p, void *v) | ||
22 | { | ||
23 | int i, j; | ||
24 | unsigned long jif; | ||
25 | cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; | ||
26 | cputime64_t guest; | ||
27 | u64 sum = 0; | ||
28 | struct timespec boottime; | ||
29 | unsigned int per_irq_sum; | ||
30 | |||
31 | user = nice = system = idle = iowait = | ||
32 | irq = softirq = steal = cputime64_zero; | ||
33 | guest = cputime64_zero; | ||
34 | getboottime(&boottime); | ||
35 | jif = boottime.tv_sec; | ||
36 | |||
37 | for_each_possible_cpu(i) { | ||
38 | user = cputime64_add(user, kstat_cpu(i).cpustat.user); | ||
39 | nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice); | ||
40 | system = cputime64_add(system, kstat_cpu(i).cpustat.system); | ||
41 | idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle); | ||
42 | iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait); | ||
43 | irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq); | ||
44 | softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); | ||
45 | steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); | ||
46 | guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); | ||
47 | |||
48 | for_each_irq_nr(j) | ||
49 | sum += kstat_irqs_cpu(j, i); | ||
50 | |||
51 | sum += arch_irq_stat_cpu(i); | ||
52 | } | ||
53 | sum += arch_irq_stat(); | ||
54 | |||
55 | seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", | ||
56 | (unsigned long long)cputime64_to_clock_t(user), | ||
57 | (unsigned long long)cputime64_to_clock_t(nice), | ||
58 | (unsigned long long)cputime64_to_clock_t(system), | ||
59 | (unsigned long long)cputime64_to_clock_t(idle), | ||
60 | (unsigned long long)cputime64_to_clock_t(iowait), | ||
61 | (unsigned long long)cputime64_to_clock_t(irq), | ||
62 | (unsigned long long)cputime64_to_clock_t(softirq), | ||
63 | (unsigned long long)cputime64_to_clock_t(steal), | ||
64 | (unsigned long long)cputime64_to_clock_t(guest)); | ||
65 | for_each_online_cpu(i) { | ||
66 | |||
67 | /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ | ||
68 | user = kstat_cpu(i).cpustat.user; | ||
69 | nice = kstat_cpu(i).cpustat.nice; | ||
70 | system = kstat_cpu(i).cpustat.system; | ||
71 | idle = kstat_cpu(i).cpustat.idle; | ||
72 | iowait = kstat_cpu(i).cpustat.iowait; | ||
73 | irq = kstat_cpu(i).cpustat.irq; | ||
74 | softirq = kstat_cpu(i).cpustat.softirq; | ||
75 | steal = kstat_cpu(i).cpustat.steal; | ||
76 | guest = kstat_cpu(i).cpustat.guest; | ||
77 | seq_printf(p, | ||
78 | "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", | ||
79 | i, | ||
80 | (unsigned long long)cputime64_to_clock_t(user), | ||
81 | (unsigned long long)cputime64_to_clock_t(nice), | ||
82 | (unsigned long long)cputime64_to_clock_t(system), | ||
83 | (unsigned long long)cputime64_to_clock_t(idle), | ||
84 | (unsigned long long)cputime64_to_clock_t(iowait), | ||
85 | (unsigned long long)cputime64_to_clock_t(irq), | ||
86 | (unsigned long long)cputime64_to_clock_t(softirq), | ||
87 | (unsigned long long)cputime64_to_clock_t(steal), | ||
88 | (unsigned long long)cputime64_to_clock_t(guest)); | ||
89 | } | ||
90 | seq_printf(p, "intr %llu", (unsigned long long)sum); | ||
91 | |||
92 | /* sum again ? it could be updated? */ | ||
93 | for_each_irq_nr(j) { | ||
94 | per_irq_sum = 0; | ||
95 | |||
96 | for_each_possible_cpu(i) | ||
97 | per_irq_sum += kstat_irqs_cpu(j, i); | ||
98 | |||
99 | seq_printf(p, " %u", per_irq_sum); | ||
100 | } | ||
101 | |||
102 | seq_printf(p, | ||
103 | "\nctxt %llu\n" | ||
104 | "btime %lu\n" | ||
105 | "processes %lu\n" | ||
106 | "procs_running %lu\n" | ||
107 | "procs_blocked %lu\n", | ||
108 | nr_context_switches(), | ||
109 | (unsigned long)jif, | ||
110 | total_forks, | ||
111 | nr_running(), | ||
112 | nr_iowait()); | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static int stat_open(struct inode *inode, struct file *file) | ||
118 | { | ||
119 | unsigned size = 4096 * (1 + num_possible_cpus() / 32); | ||
120 | char *buf; | ||
121 | struct seq_file *m; | ||
122 | int res; | ||
123 | |||
124 | /* don't ask for more than the kmalloc() max size, currently 128 KB */ | ||
125 | if (size > 128 * 1024) | ||
126 | size = 128 * 1024; | ||
127 | buf = kmalloc(size, GFP_KERNEL); | ||
128 | if (!buf) | ||
129 | return -ENOMEM; | ||
130 | |||
131 | res = single_open(file, show_stat, NULL); | ||
132 | if (!res) { | ||
133 | m = file->private_data; | ||
134 | m->buf = buf; | ||
135 | m->size = size; | ||
136 | } else | ||
137 | kfree(buf); | ||
138 | return res; | ||
139 | } | ||
140 | |||
141 | static const struct file_operations proc_stat_operations = { | ||
142 | .open = stat_open, | ||
143 | .read = seq_read, | ||
144 | .llseek = seq_lseek, | ||
145 | .release = single_release, | ||
146 | }; | ||
147 | |||
148 | static int __init proc_stat_init(void) | ||
149 | { | ||
150 | proc_create("stat", 0, NULL, &proc_stat_operations); | ||
151 | return 0; | ||
152 | } | ||
153 | module_init(proc_stat_init); | ||
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 4806830ea2a1..b770c095e45c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -198,11 +198,8 @@ static int do_maps_open(struct inode *inode, struct file *file, | |||
198 | return ret; | 198 | return ret; |
199 | } | 199 | } |
200 | 200 | ||
201 | static int show_map(struct seq_file *m, void *v) | 201 | static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) |
202 | { | 202 | { |
203 | struct proc_maps_private *priv = m->private; | ||
204 | struct task_struct *task = priv->task; | ||
205 | struct vm_area_struct *vma = v; | ||
206 | struct mm_struct *mm = vma->vm_mm; | 203 | struct mm_struct *mm = vma->vm_mm; |
207 | struct file *file = vma->vm_file; | 204 | struct file *file = vma->vm_file; |
208 | int flags = vma->vm_flags; | 205 | int flags = vma->vm_flags; |
@@ -254,6 +251,15 @@ static int show_map(struct seq_file *m, void *v) | |||
254 | } | 251 | } |
255 | } | 252 | } |
256 | seq_putc(m, '\n'); | 253 | seq_putc(m, '\n'); |
254 | } | ||
255 | |||
256 | static int show_map(struct seq_file *m, void *v) | ||
257 | { | ||
258 | struct vm_area_struct *vma = v; | ||
259 | struct proc_maps_private *priv = m->private; | ||
260 | struct task_struct *task = priv->task; | ||
261 | |||
262 | show_map_vma(m, vma); | ||
257 | 263 | ||
258 | if (m->count < m->size) /* vma is copied successfully */ | 264 | if (m->count < m->size) /* vma is copied successfully */ |
259 | m->version = (vma != get_gate_vma(task))? vma->vm_start: 0; | 265 | m->version = (vma != get_gate_vma(task))? vma->vm_start: 0; |
@@ -364,9 +370,10 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | |||
364 | 370 | ||
365 | static int show_smap(struct seq_file *m, void *v) | 371 | static int show_smap(struct seq_file *m, void *v) |
366 | { | 372 | { |
373 | struct proc_maps_private *priv = m->private; | ||
374 | struct task_struct *task = priv->task; | ||
367 | struct vm_area_struct *vma = v; | 375 | struct vm_area_struct *vma = v; |
368 | struct mem_size_stats mss; | 376 | struct mem_size_stats mss; |
369 | int ret; | ||
370 | struct mm_walk smaps_walk = { | 377 | struct mm_walk smaps_walk = { |
371 | .pmd_entry = smaps_pte_range, | 378 | .pmd_entry = smaps_pte_range, |
372 | .mm = vma->vm_mm, | 379 | .mm = vma->vm_mm, |
@@ -378,9 +385,7 @@ static int show_smap(struct seq_file *m, void *v) | |||
378 | if (vma->vm_mm && !is_vm_hugetlb_page(vma)) | 385 | if (vma->vm_mm && !is_vm_hugetlb_page(vma)) |
379 | walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk); | 386 | walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk); |
380 | 387 | ||
381 | ret = show_map(m, v); | 388 | show_map_vma(m, vma); |
382 | if (ret) | ||
383 | return ret; | ||
384 | 389 | ||
385 | seq_printf(m, | 390 | seq_printf(m, |
386 | "Size: %8lu kB\n" | 391 | "Size: %8lu kB\n" |
@@ -402,7 +407,9 @@ static int show_smap(struct seq_file *m, void *v) | |||
402 | mss.referenced >> 10, | 407 | mss.referenced >> 10, |
403 | mss.swap >> 10); | 408 | mss.swap >> 10); |
404 | 409 | ||
405 | return ret; | 410 | if (m->count < m->size) /* vma is copied successfully */ |
411 | m->version = (vma != get_gate_vma(task)) ? vma->vm_start : 0; | ||
412 | return 0; | ||
406 | } | 413 | } |
407 | 414 | ||
408 | static const struct seq_operations proc_pid_smaps_op = { | 415 | static const struct seq_operations proc_pid_smaps_op = { |
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c new file mode 100644 index 000000000000..0c10a0b3f146 --- /dev/null +++ b/fs/proc/uptime.c | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/proc_fs.h> | ||
4 | #include <linux/sched.h> | ||
5 | #include <linux/seq_file.h> | ||
6 | #include <linux/time.h> | ||
7 | #include <asm/cputime.h> | ||
8 | |||
9 | static int uptime_proc_show(struct seq_file *m, void *v) | ||
10 | { | ||
11 | struct timespec uptime; | ||
12 | struct timespec idle; | ||
13 | cputime_t idletime = cputime_add(init_task.utime, init_task.stime); | ||
14 | |||
15 | do_posix_clock_monotonic_gettime(&uptime); | ||
16 | monotonic_to_bootbased(&uptime); | ||
17 | cputime_to_timespec(idletime, &idle); | ||
18 | seq_printf(m, "%lu.%02lu %lu.%02lu\n", | ||
19 | (unsigned long) uptime.tv_sec, | ||
20 | (uptime.tv_nsec / (NSEC_PER_SEC / 100)), | ||
21 | (unsigned long) idle.tv_sec, | ||
22 | (idle.tv_nsec / (NSEC_PER_SEC / 100))); | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | static int uptime_proc_open(struct inode *inode, struct file *file) | ||
27 | { | ||
28 | return single_open(file, uptime_proc_show, NULL); | ||
29 | } | ||
30 | |||
31 | static const struct file_operations uptime_proc_fops = { | ||
32 | .open = uptime_proc_open, | ||
33 | .read = seq_read, | ||
34 | .llseek = seq_lseek, | ||
35 | .release = single_release, | ||
36 | }; | ||
37 | |||
38 | static int __init proc_uptime_init(void) | ||
39 | { | ||
40 | proc_create("uptime", 0, NULL, &uptime_proc_fops); | ||
41 | return 0; | ||
42 | } | ||
43 | module_init(proc_uptime_init); | ||
diff --git a/fs/proc/version.c b/fs/proc/version.c new file mode 100644 index 000000000000..76817a60678c --- /dev/null +++ b/fs/proc/version.c | |||
@@ -0,0 +1,34 @@ | |||
1 | #include <linux/fs.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/kernel.h> | ||
4 | #include <linux/proc_fs.h> | ||
5 | #include <linux/seq_file.h> | ||
6 | #include <linux/utsname.h> | ||
7 | |||
8 | static int version_proc_show(struct seq_file *m, void *v) | ||
9 | { | ||
10 | seq_printf(m, linux_proc_banner, | ||
11 | utsname()->sysname, | ||
12 | utsname()->release, | ||
13 | utsname()->version); | ||
14 | return 0; | ||
15 | } | ||
16 | |||
17 | static int version_proc_open(struct inode *inode, struct file *file) | ||
18 | { | ||
19 | return single_open(file, version_proc_show, NULL); | ||
20 | } | ||
21 | |||
22 | static const struct file_operations version_proc_fops = { | ||
23 | .open = version_proc_open, | ||
24 | .read = seq_read, | ||
25 | .llseek = seq_lseek, | ||
26 | .release = single_release, | ||
27 | }; | ||
28 | |||
29 | static int __init proc_version_init(void) | ||
30 | { | ||
31 | proc_create("version", 0, NULL, &version_proc_fops); | ||
32 | return 0; | ||
33 | } | ||
34 | module_init(proc_version_init); | ||
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index cd9ca67f841b..03ec59504906 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
@@ -32,7 +32,7 @@ static size_t elfcorebuf_sz; | |||
32 | /* Total size of vmcore file. */ | 32 | /* Total size of vmcore file. */ |
33 | static u64 vmcore_size; | 33 | static u64 vmcore_size; |
34 | 34 | ||
35 | struct proc_dir_entry *proc_vmcore = NULL; | 35 | static struct proc_dir_entry *proc_vmcore = NULL; |
36 | 36 | ||
37 | /* Reads a page from the oldmem device from given offset. */ | 37 | /* Reads a page from the oldmem device from given offset. */ |
38 | static ssize_t read_from_oldmem(char *buf, size_t count, | 38 | static ssize_t read_from_oldmem(char *buf, size_t count, |
@@ -162,7 +162,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer, | |||
162 | return acc; | 162 | return acc; |
163 | } | 163 | } |
164 | 164 | ||
165 | const struct file_operations proc_vmcore_operations = { | 165 | static const struct file_operations proc_vmcore_operations = { |
166 | .read = read_vmcore, | 166 | .read = read_vmcore, |
167 | }; | 167 | }; |
168 | 168 | ||
@@ -652,7 +652,7 @@ static int __init vmcore_init(void) | |||
652 | return rc; | 652 | return rc; |
653 | } | 653 | } |
654 | 654 | ||
655 | /* Initialize /proc/vmcore size if proc is already up. */ | 655 | proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); |
656 | if (proc_vmcore) | 656 | if (proc_vmcore) |
657 | proc_vmcore->size = vmcore_size; | 657 | proc_vmcore->size = vmcore_size; |
658 | return 0; | 658 | return 0; |
diff --git a/include/asm-m68k/machdep.h b/include/asm-m68k/machdep.h index 26d2b91209c5..5637dcef314e 100644 --- a/include/asm-m68k/machdep.h +++ b/include/asm-m68k/machdep.h | |||
@@ -14,7 +14,7 @@ extern void (*mach_sched_init) (irq_handler_t handler); | |||
14 | /* machine dependent irq functions */ | 14 | /* machine dependent irq functions */ |
15 | extern void (*mach_init_IRQ) (void); | 15 | extern void (*mach_init_IRQ) (void); |
16 | extern void (*mach_get_model) (char *model); | 16 | extern void (*mach_get_model) (char *model); |
17 | extern int (*mach_get_hardware_list) (char *buffer); | 17 | extern void (*mach_get_hardware_list) (struct seq_file *m); |
18 | /* machine dependent timer functions */ | 18 | /* machine dependent timer functions */ |
19 | extern unsigned long (*mach_gettimeoffset)(void); | 19 | extern unsigned long (*mach_gettimeoffset)(void); |
20 | extern int (*mach_hwclk)(int, struct rtc_time*); | 20 | extern int (*mach_hwclk)(int, struct rtc_time*); |
diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h index 0acf3b737e2e..2dac064d8359 100644 --- a/include/linux/crash_dump.h +++ b/include/linux/crash_dump.h | |||
@@ -14,8 +14,6 @@ extern unsigned long long elfcorehdr_addr; | |||
14 | 14 | ||
15 | extern ssize_t copy_oldmem_page(unsigned long, char *, size_t, | 15 | extern ssize_t copy_oldmem_page(unsigned long, char *, size_t, |
16 | unsigned long, int); | 16 | unsigned long, int); |
17 | extern const struct file_operations proc_vmcore_operations; | ||
18 | extern struct proc_dir_entry *proc_vmcore; | ||
19 | 17 | ||
20 | /* Architecture code defines this if there are other possible ELF | 18 | /* Architecture code defines this if there are other possible ELF |
21 | * machine types, e.g. on bi-arch capable hardware. */ | 19 | * machine types, e.g. on bi-arch capable hardware. */ |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 43659ae52e4d..5b248d61430c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1042,7 +1042,6 @@ extern int vfs_setlease(struct file *, long, struct file_lock **); | |||
1042 | extern int lease_modify(struct file_lock **, int); | 1042 | extern int lease_modify(struct file_lock **, int); |
1043 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); | 1043 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); |
1044 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); | 1044 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); |
1045 | extern struct seq_operations locks_seq_operations; | ||
1046 | #else /* !CONFIG_FILE_LOCKING */ | 1045 | #else /* !CONFIG_FILE_LOCKING */ |
1047 | #define fcntl_getlk(a, b) ({ -EINVAL; }) | 1046 | #define fcntl_getlk(a, b) ({ -EINVAL; }) |
1048 | #define fcntl_setlk(a, b, c, d) ({ -EACCES; }) | 1047 | #define fcntl_setlk(a, b, c, d) ({ -EACCES; }) |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 206cdf96c3a7..e439e6aed832 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -25,9 +25,6 @@ extern struct device_type part_type; | |||
25 | extern struct kobject *block_depr; | 25 | extern struct kobject *block_depr; |
26 | extern struct class block_class; | 26 | extern struct class block_class; |
27 | 27 | ||
28 | extern const struct seq_operations partitions_op; | ||
29 | extern const struct seq_operations diskstats_op; | ||
30 | |||
31 | enum { | 28 | enum { |
32 | /* These three have identical behaviour; use the second one if DOS FDISK gets | 29 | /* These three have identical behaviour; use the second one if DOS FDISK gets |
33 | confused about extended/logical partitions starting past cylinder 1023. */ | 30 | confused about extended/logical partitions starting past cylinder 1023. */ |
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 32e0ef0f6e1f..e1c8afc002c0 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
@@ -27,7 +27,7 @@ void unmap_hugepage_range(struct vm_area_struct *, | |||
27 | void __unmap_hugepage_range(struct vm_area_struct *, | 27 | void __unmap_hugepage_range(struct vm_area_struct *, |
28 | unsigned long, unsigned long, struct page *); | 28 | unsigned long, unsigned long, struct page *); |
29 | int hugetlb_prefault(struct address_space *, struct vm_area_struct *); | 29 | int hugetlb_prefault(struct address_space *, struct vm_area_struct *); |
30 | int hugetlb_report_meminfo(char *); | 30 | void hugetlb_report_meminfo(struct seq_file *); |
31 | int hugetlb_report_node_meminfo(int, char *); | 31 | int hugetlb_report_node_meminfo(int, char *); |
32 | unsigned long hugetlb_total_pages(void); | 32 | unsigned long hugetlb_total_pages(void); |
33 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | 33 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, |
@@ -79,7 +79,9 @@ static inline unsigned long hugetlb_total_pages(void) | |||
79 | #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) | 79 | #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) |
80 | #define hugetlb_prefault(mapping, vma) ({ BUG(); 0; }) | 80 | #define hugetlb_prefault(mapping, vma) ({ BUG(); 0; }) |
81 | #define unmap_hugepage_range(vma, start, end, page) BUG() | 81 | #define unmap_hugepage_range(vma, start, end, page) BUG() |
82 | #define hugetlb_report_meminfo(buf) 0 | 82 | static inline void hugetlb_report_meminfo(struct seq_file *m) |
83 | { | ||
84 | } | ||
83 | #define hugetlb_report_node_meminfo(n, buf) 0 | 85 | #define hugetlb_report_node_meminfo(n, buf) 0 |
84 | #define follow_huge_pmd(mm, addr, pmd, write) NULL | 86 | #define follow_huge_pmd(mm, addr, pmd, write) NULL |
85 | #define follow_huge_pud(mm, addr, pud, write) NULL | 87 | #define follow_huge_pud(mm, addr, pud, write) NULL |
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 27d534f4470d..b8bdb96eff78 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -97,12 +97,9 @@ struct vmcore { | |||
97 | 97 | ||
98 | #ifdef CONFIG_PROC_FS | 98 | #ifdef CONFIG_PROC_FS |
99 | 99 | ||
100 | extern struct proc_dir_entry *proc_root_kcore; | ||
101 | |||
102 | extern spinlock_t proc_subdir_lock; | 100 | extern spinlock_t proc_subdir_lock; |
103 | 101 | ||
104 | extern void proc_root_init(void); | 102 | extern void proc_root_init(void); |
105 | extern void proc_misc_init(void); | ||
106 | 103 | ||
107 | void proc_flush_task(struct task_struct *task); | 104 | void proc_flush_task(struct task_struct *task); |
108 | struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *); | 105 | struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *); |
@@ -138,8 +135,6 @@ extern struct inode *proc_get_inode(struct super_block *, unsigned int, struct p | |||
138 | extern int proc_readdir(struct file *, void *, filldir_t); | 135 | extern int proc_readdir(struct file *, void *, filldir_t); |
139 | extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *); | 136 | extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *); |
140 | 137 | ||
141 | extern const struct file_operations proc_kcore_operations; | ||
142 | |||
143 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | 138 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); |
144 | extern void pid_ns_release_proc(struct pid_namespace *ns); | 139 | extern void pid_ns_release_proc(struct pid_namespace *ns); |
145 | 140 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index 5ca620573d47..8478f334d732 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -680,10 +680,6 @@ struct sched_info { | |||
680 | }; | 680 | }; |
681 | #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ | 681 | #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ |
682 | 682 | ||
683 | #ifdef CONFIG_SCHEDSTATS | ||
684 | extern const struct file_operations proc_schedstat_operations; | ||
685 | #endif /* CONFIG_SCHEDSTATS */ | ||
686 | |||
687 | #ifdef CONFIG_TASK_DELAY_ACCT | 683 | #ifdef CONFIG_TASK_DELAY_ACCT |
688 | struct task_delay_info { | 684 | struct task_delay_info { |
689 | spinlock_t lock; | 685 | spinlock_t lock; |
diff --git a/include/linux/slab.h b/include/linux/slab.h index 5ff9676c1e2c..ba965c84ae06 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -288,9 +288,4 @@ static inline void *kzalloc_node(size_t size, gfp_t flags, int node) | |||
288 | return kmalloc_node(size, flags | __GFP_ZERO, node); | 288 | return kmalloc_node(size, flags | __GFP_ZERO, node); |
289 | } | 289 | } |
290 | 290 | ||
291 | #ifdef CONFIG_SLABINFO | ||
292 | extern const struct seq_operations slabinfo_op; | ||
293 | ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *); | ||
294 | #endif | ||
295 | |||
296 | #endif /* _LINUX_SLAB_H */ | 291 | #endif /* _LINUX_SLAB_H */ |
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 4c28c4d564e2..307b88577eaa 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h | |||
@@ -103,6 +103,4 @@ extern void free_vm_area(struct vm_struct *area); | |||
103 | extern rwlock_t vmlist_lock; | 103 | extern rwlock_t vmlist_lock; |
104 | extern struct vm_struct *vmlist; | 104 | extern struct vm_struct *vmlist; |
105 | 105 | ||
106 | extern const struct seq_operations vmalloc_op; | ||
107 | |||
108 | #endif /* _LINUX_VMALLOC_H */ | 106 | #endif /* _LINUX_VMALLOC_H */ |
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 9cd3ab0f554d..524cd1b28ecb 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h | |||
@@ -54,10 +54,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, | |||
54 | NR_VM_EVENT_ITEMS | 54 | NR_VM_EVENT_ITEMS |
55 | }; | 55 | }; |
56 | 56 | ||
57 | extern const struct seq_operations fragmentation_op; | ||
58 | extern const struct seq_operations pagetypeinfo_op; | ||
59 | extern const struct seq_operations zoneinfo_op; | ||
60 | extern const struct seq_operations vmstat_op; | ||
61 | extern int sysctl_stat_interval; | 57 | extern int sysctl_stat_interval; |
62 | 58 | ||
63 | #ifdef CONFIG_VM_EVENT_COUNTERS | 59 | #ifdef CONFIG_VM_EVENT_COUNTERS |
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index 0d407e886735..0511716e9424 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c | |||
@@ -12,7 +12,9 @@ | |||
12 | #include <linux/kmod.h> | 12 | #include <linux/kmod.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/personality.h> | 14 | #include <linux/personality.h> |
15 | #include <linux/proc_fs.h> | ||
15 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/seq_file.h> | ||
16 | #include <linux/syscalls.h> | 18 | #include <linux/syscalls.h> |
17 | #include <linux/sysctl.h> | 19 | #include <linux/sysctl.h> |
18 | #include <linux/types.h> | 20 | #include <linux/types.h> |
@@ -173,20 +175,39 @@ __set_personality(u_long personality) | |||
173 | return 0; | 175 | return 0; |
174 | } | 176 | } |
175 | 177 | ||
176 | int | 178 | #ifdef CONFIG_PROC_FS |
177 | get_exec_domain_list(char *page) | 179 | static int execdomains_proc_show(struct seq_file *m, void *v) |
178 | { | 180 | { |
179 | struct exec_domain *ep; | 181 | struct exec_domain *ep; |
180 | int len = 0; | ||
181 | 182 | ||
182 | read_lock(&exec_domains_lock); | 183 | read_lock(&exec_domains_lock); |
183 | for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next) | 184 | for (ep = exec_domains; ep; ep = ep->next) |
184 | len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n", | 185 | seq_printf(m, "%d-%d\t%-16s\t[%s]\n", |
185 | ep->pers_low, ep->pers_high, ep->name, | 186 | ep->pers_low, ep->pers_high, ep->name, |
186 | module_name(ep->module)); | 187 | module_name(ep->module)); |
187 | read_unlock(&exec_domains_lock); | 188 | read_unlock(&exec_domains_lock); |
188 | return (len); | 189 | return 0; |
190 | } | ||
191 | |||
192 | static int execdomains_proc_open(struct inode *inode, struct file *file) | ||
193 | { | ||
194 | return single_open(file, execdomains_proc_show, NULL); | ||
195 | } | ||
196 | |||
197 | static const struct file_operations execdomains_proc_fops = { | ||
198 | .open = execdomains_proc_open, | ||
199 | .read = seq_read, | ||
200 | .llseek = seq_lseek, | ||
201 | .release = single_release, | ||
202 | }; | ||
203 | |||
204 | static int __init proc_execdomains_init(void) | ||
205 | { | ||
206 | proc_create("execdomains", 0, NULL, &execdomains_proc_fops); | ||
207 | return 0; | ||
189 | } | 208 | } |
209 | module_init(proc_execdomains_init); | ||
210 | #endif | ||
190 | 211 | ||
191 | asmlinkage long | 212 | asmlinkage long |
192 | sys_personality(u_long personality) | 213 | sys_personality(u_long personality) |
diff --git a/kernel/module.c b/kernel/module.c index c0f1826e2d9e..1f4cc00e0c20 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -20,11 +20,13 @@ | |||
20 | #include <linux/moduleloader.h> | 20 | #include <linux/moduleloader.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/kallsyms.h> | 22 | #include <linux/kallsyms.h> |
23 | #include <linux/fs.h> | ||
23 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
25 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
26 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
27 | #include <linux/elf.h> | 28 | #include <linux/elf.h> |
29 | #include <linux/proc_fs.h> | ||
28 | #include <linux/seq_file.h> | 30 | #include <linux/seq_file.h> |
29 | #include <linux/syscalls.h> | 31 | #include <linux/syscalls.h> |
30 | #include <linux/fcntl.h> | 32 | #include <linux/fcntl.h> |
@@ -2556,23 +2558,6 @@ unsigned long module_kallsyms_lookup_name(const char *name) | |||
2556 | } | 2558 | } |
2557 | #endif /* CONFIG_KALLSYMS */ | 2559 | #endif /* CONFIG_KALLSYMS */ |
2558 | 2560 | ||
2559 | /* Called by the /proc file system to return a list of modules. */ | ||
2560 | static void *m_start(struct seq_file *m, loff_t *pos) | ||
2561 | { | ||
2562 | mutex_lock(&module_mutex); | ||
2563 | return seq_list_start(&modules, *pos); | ||
2564 | } | ||
2565 | |||
2566 | static void *m_next(struct seq_file *m, void *p, loff_t *pos) | ||
2567 | { | ||
2568 | return seq_list_next(p, &modules, pos); | ||
2569 | } | ||
2570 | |||
2571 | static void m_stop(struct seq_file *m, void *p) | ||
2572 | { | ||
2573 | mutex_unlock(&module_mutex); | ||
2574 | } | ||
2575 | |||
2576 | static char *module_flags(struct module *mod, char *buf) | 2561 | static char *module_flags(struct module *mod, char *buf) |
2577 | { | 2562 | { |
2578 | int bx = 0; | 2563 | int bx = 0; |
@@ -2606,6 +2591,24 @@ static char *module_flags(struct module *mod, char *buf) | |||
2606 | return buf; | 2591 | return buf; |
2607 | } | 2592 | } |
2608 | 2593 | ||
2594 | #ifdef CONFIG_PROC_FS | ||
2595 | /* Called by the /proc file system to return a list of modules. */ | ||
2596 | static void *m_start(struct seq_file *m, loff_t *pos) | ||
2597 | { | ||
2598 | mutex_lock(&module_mutex); | ||
2599 | return seq_list_start(&modules, *pos); | ||
2600 | } | ||
2601 | |||
2602 | static void *m_next(struct seq_file *m, void *p, loff_t *pos) | ||
2603 | { | ||
2604 | return seq_list_next(p, &modules, pos); | ||
2605 | } | ||
2606 | |||
2607 | static void m_stop(struct seq_file *m, void *p) | ||
2608 | { | ||
2609 | mutex_unlock(&module_mutex); | ||
2610 | } | ||
2611 | |||
2609 | static int m_show(struct seq_file *m, void *p) | 2612 | static int m_show(struct seq_file *m, void *p) |
2610 | { | 2613 | { |
2611 | struct module *mod = list_entry(p, struct module, list); | 2614 | struct module *mod = list_entry(p, struct module, list); |
@@ -2636,13 +2639,33 @@ static int m_show(struct seq_file *m, void *p) | |||
2636 | Where refcount is a number or -, and deps is a comma-separated list | 2639 | Where refcount is a number or -, and deps is a comma-separated list |
2637 | of depends or -. | 2640 | of depends or -. |
2638 | */ | 2641 | */ |
2639 | const struct seq_operations modules_op = { | 2642 | static const struct seq_operations modules_op = { |
2640 | .start = m_start, | 2643 | .start = m_start, |
2641 | .next = m_next, | 2644 | .next = m_next, |
2642 | .stop = m_stop, | 2645 | .stop = m_stop, |
2643 | .show = m_show | 2646 | .show = m_show |
2644 | }; | 2647 | }; |
2645 | 2648 | ||
2649 | static int modules_open(struct inode *inode, struct file *file) | ||
2650 | { | ||
2651 | return seq_open(file, &modules_op); | ||
2652 | } | ||
2653 | |||
2654 | static const struct file_operations proc_modules_operations = { | ||
2655 | .open = modules_open, | ||
2656 | .read = seq_read, | ||
2657 | .llseek = seq_lseek, | ||
2658 | .release = seq_release, | ||
2659 | }; | ||
2660 | |||
2661 | static int __init proc_modules_init(void) | ||
2662 | { | ||
2663 | proc_create("modules", 0, NULL, &proc_modules_operations); | ||
2664 | return 0; | ||
2665 | } | ||
2666 | module_init(proc_modules_init); | ||
2667 | #endif | ||
2668 | |||
2646 | /* Given an address, look for it in the module exception tables. */ | 2669 | /* Given an address, look for it in the module exception tables. */ |
2647 | const struct exception_table_entry *search_module_extables(unsigned long addr) | 2670 | const struct exception_table_entry *search_module_extables(unsigned long addr) |
2648 | { | 2671 | { |
diff --git a/kernel/sched.c b/kernel/sched.c index 1645c7211944..6625c3c4b10d 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/cpuset.h> | 55 | #include <linux/cpuset.h> |
56 | #include <linux/percpu.h> | 56 | #include <linux/percpu.h> |
57 | #include <linux/kthread.h> | 57 | #include <linux/kthread.h> |
58 | #include <linux/proc_fs.h> | ||
58 | #include <linux/seq_file.h> | 59 | #include <linux/seq_file.h> |
59 | #include <linux/sysctl.h> | 60 | #include <linux/sysctl.h> |
60 | #include <linux/syscalls.h> | 61 | #include <linux/syscalls.h> |
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h index 2df9d297d292..ee71bec1da66 100644 --- a/kernel/sched_stats.h +++ b/kernel/sched_stats.h | |||
@@ -90,13 +90,20 @@ static int schedstat_open(struct inode *inode, struct file *file) | |||
90 | return res; | 90 | return res; |
91 | } | 91 | } |
92 | 92 | ||
93 | const struct file_operations proc_schedstat_operations = { | 93 | static const struct file_operations proc_schedstat_operations = { |
94 | .open = schedstat_open, | 94 | .open = schedstat_open, |
95 | .read = seq_read, | 95 | .read = seq_read, |
96 | .llseek = seq_lseek, | 96 | .llseek = seq_lseek, |
97 | .release = single_release, | 97 | .release = single_release, |
98 | }; | 98 | }; |
99 | 99 | ||
100 | static int __init proc_schedstat_init(void) | ||
101 | { | ||
102 | proc_create("schedstat", 0, NULL, &proc_schedstat_operations); | ||
103 | return 0; | ||
104 | } | ||
105 | module_init(proc_schedstat_init); | ||
106 | |||
100 | /* | 107 | /* |
101 | * Expects runqueue lock to be held for atomicity of update | 108 | * Expects runqueue lock to be held for atomicity of update |
102 | */ | 109 | */ |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ce8cbb29860b..421aee99b84a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/seq_file.h> | ||
10 | #include <linux/sysctl.h> | 11 | #include <linux/sysctl.h> |
11 | #include <linux/highmem.h> | 12 | #include <linux/highmem.h> |
12 | #include <linux/mmu_notifier.h> | 13 | #include <linux/mmu_notifier.h> |
@@ -1455,10 +1456,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, | |||
1455 | 1456 | ||
1456 | #endif /* CONFIG_SYSCTL */ | 1457 | #endif /* CONFIG_SYSCTL */ |
1457 | 1458 | ||
1458 | int hugetlb_report_meminfo(char *buf) | 1459 | void hugetlb_report_meminfo(struct seq_file *m) |
1459 | { | 1460 | { |
1460 | struct hstate *h = &default_hstate; | 1461 | struct hstate *h = &default_hstate; |
1461 | return sprintf(buf, | 1462 | seq_printf(m, |
1462 | "HugePages_Total: %5lu\n" | 1463 | "HugePages_Total: %5lu\n" |
1463 | "HugePages_Free: %5lu\n" | 1464 | "HugePages_Free: %5lu\n" |
1464 | "HugePages_Rsvd: %5lu\n" | 1465 | "HugePages_Rsvd: %5lu\n" |
@@ -95,6 +95,7 @@ | |||
95 | #include <linux/init.h> | 95 | #include <linux/init.h> |
96 | #include <linux/compiler.h> | 96 | #include <linux/compiler.h> |
97 | #include <linux/cpuset.h> | 97 | #include <linux/cpuset.h> |
98 | #include <linux/proc_fs.h> | ||
98 | #include <linux/seq_file.h> | 99 | #include <linux/seq_file.h> |
99 | #include <linux/notifier.h> | 100 | #include <linux/notifier.h> |
100 | #include <linux/kallsyms.h> | 101 | #include <linux/kallsyms.h> |
@@ -4258,7 +4259,7 @@ static int s_show(struct seq_file *m, void *p) | |||
4258 | * + further values on SMP and with statistics enabled | 4259 | * + further values on SMP and with statistics enabled |
4259 | */ | 4260 | */ |
4260 | 4261 | ||
4261 | const struct seq_operations slabinfo_op = { | 4262 | static const struct seq_operations slabinfo_op = { |
4262 | .start = s_start, | 4263 | .start = s_start, |
4263 | .next = s_next, | 4264 | .next = s_next, |
4264 | .stop = s_stop, | 4265 | .stop = s_stop, |
@@ -4315,6 +4316,19 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer, | |||
4315 | return res; | 4316 | return res; |
4316 | } | 4317 | } |
4317 | 4318 | ||
4319 | static int slabinfo_open(struct inode *inode, struct file *file) | ||
4320 | { | ||
4321 | return seq_open(file, &slabinfo_op); | ||
4322 | } | ||
4323 | |||
4324 | static const struct file_operations proc_slabinfo_operations = { | ||
4325 | .open = slabinfo_open, | ||
4326 | .read = seq_read, | ||
4327 | .write = slabinfo_write, | ||
4328 | .llseek = seq_lseek, | ||
4329 | .release = seq_release, | ||
4330 | }; | ||
4331 | |||
4318 | #ifdef CONFIG_DEBUG_SLAB_LEAK | 4332 | #ifdef CONFIG_DEBUG_SLAB_LEAK |
4319 | 4333 | ||
4320 | static void *leaks_start(struct seq_file *m, loff_t *pos) | 4334 | static void *leaks_start(struct seq_file *m, loff_t *pos) |
@@ -4443,13 +4457,47 @@ static int leaks_show(struct seq_file *m, void *p) | |||
4443 | return 0; | 4457 | return 0; |
4444 | } | 4458 | } |
4445 | 4459 | ||
4446 | const struct seq_operations slabstats_op = { | 4460 | static const struct seq_operations slabstats_op = { |
4447 | .start = leaks_start, | 4461 | .start = leaks_start, |
4448 | .next = s_next, | 4462 | .next = s_next, |
4449 | .stop = s_stop, | 4463 | .stop = s_stop, |
4450 | .show = leaks_show, | 4464 | .show = leaks_show, |
4451 | }; | 4465 | }; |
4466 | |||
4467 | static int slabstats_open(struct inode *inode, struct file *file) | ||
4468 | { | ||
4469 | unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); | ||
4470 | int ret = -ENOMEM; | ||
4471 | if (n) { | ||
4472 | ret = seq_open(file, &slabstats_op); | ||
4473 | if (!ret) { | ||
4474 | struct seq_file *m = file->private_data; | ||
4475 | *n = PAGE_SIZE / (2 * sizeof(unsigned long)); | ||
4476 | m->private = n; | ||
4477 | n = NULL; | ||
4478 | } | ||
4479 | kfree(n); | ||
4480 | } | ||
4481 | return ret; | ||
4482 | } | ||
4483 | |||
4484 | static const struct file_operations proc_slabstats_operations = { | ||
4485 | .open = slabstats_open, | ||
4486 | .read = seq_read, | ||
4487 | .llseek = seq_lseek, | ||
4488 | .release = seq_release_private, | ||
4489 | }; | ||
4490 | #endif | ||
4491 | |||
4492 | static int __init slab_proc_init(void) | ||
4493 | { | ||
4494 | proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); | ||
4495 | #ifdef CONFIG_DEBUG_SLAB_LEAK | ||
4496 | proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); | ||
4452 | #endif | 4497 | #endif |
4498 | return 0; | ||
4499 | } | ||
4500 | module_init(slab_proc_init); | ||
4453 | #endif | 4501 | #endif |
4454 | 4502 | ||
4455 | /** | 4503 | /** |
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/bitops.h> | 15 | #include <linux/bitops.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/proc_fs.h> | ||
17 | #include <linux/seq_file.h> | 18 | #include <linux/seq_file.h> |
18 | #include <linux/cpu.h> | 19 | #include <linux/cpu.h> |
19 | #include <linux/cpuset.h> | 20 | #include <linux/cpuset.h> |
@@ -4417,14 +4418,6 @@ __initcall(slab_sysfs_init); | |||
4417 | * The /proc/slabinfo ABI | 4418 | * The /proc/slabinfo ABI |
4418 | */ | 4419 | */ |
4419 | #ifdef CONFIG_SLABINFO | 4420 | #ifdef CONFIG_SLABINFO |
4420 | |||
4421 | ssize_t slabinfo_write(struct file *file, const char __user *buffer, | ||
4422 | size_t count, loff_t *ppos) | ||
4423 | { | ||
4424 | return -EINVAL; | ||
4425 | } | ||
4426 | |||
4427 | |||
4428 | static void print_slabinfo_header(struct seq_file *m) | 4421 | static void print_slabinfo_header(struct seq_file *m) |
4429 | { | 4422 | { |
4430 | seq_puts(m, "slabinfo - version: 2.1\n"); | 4423 | seq_puts(m, "slabinfo - version: 2.1\n"); |
@@ -4492,11 +4485,29 @@ static int s_show(struct seq_file *m, void *p) | |||
4492 | return 0; | 4485 | return 0; |
4493 | } | 4486 | } |
4494 | 4487 | ||
4495 | const struct seq_operations slabinfo_op = { | 4488 | static const struct seq_operations slabinfo_op = { |
4496 | .start = s_start, | 4489 | .start = s_start, |
4497 | .next = s_next, | 4490 | .next = s_next, |
4498 | .stop = s_stop, | 4491 | .stop = s_stop, |
4499 | .show = s_show, | 4492 | .show = s_show, |
4500 | }; | 4493 | }; |
4501 | 4494 | ||
4495 | static int slabinfo_open(struct inode *inode, struct file *file) | ||
4496 | { | ||
4497 | return seq_open(file, &slabinfo_op); | ||
4498 | } | ||
4499 | |||
4500 | static const struct file_operations proc_slabinfo_operations = { | ||
4501 | .open = slabinfo_open, | ||
4502 | .read = seq_read, | ||
4503 | .llseek = seq_lseek, | ||
4504 | .release = seq_release, | ||
4505 | }; | ||
4506 | |||
4507 | static int __init slab_proc_init(void) | ||
4508 | { | ||
4509 | proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); | ||
4510 | return 0; | ||
4511 | } | ||
4512 | module_init(slab_proc_init); | ||
4502 | #endif /* CONFIG_SLABINFO */ | 4513 | #endif /* CONFIG_SLABINFO */ |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 65ae576030da..036536945dd9 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/spinlock.h> | 16 | #include <linux/spinlock.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/proc_fs.h> | ||
18 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
19 | #include <linux/debugobjects.h> | 20 | #include <linux/debugobjects.h> |
20 | #include <linux/kallsyms.h> | 21 | #include <linux/kallsyms.h> |
@@ -1718,11 +1719,41 @@ static int s_show(struct seq_file *m, void *p) | |||
1718 | return 0; | 1719 | return 0; |
1719 | } | 1720 | } |
1720 | 1721 | ||
1721 | const struct seq_operations vmalloc_op = { | 1722 | static const struct seq_operations vmalloc_op = { |
1722 | .start = s_start, | 1723 | .start = s_start, |
1723 | .next = s_next, | 1724 | .next = s_next, |
1724 | .stop = s_stop, | 1725 | .stop = s_stop, |
1725 | .show = s_show, | 1726 | .show = s_show, |
1726 | }; | 1727 | }; |
1728 | |||
1729 | static int vmalloc_open(struct inode *inode, struct file *file) | ||
1730 | { | ||
1731 | unsigned int *ptr = NULL; | ||
1732 | int ret; | ||
1733 | |||
1734 | if (NUMA_BUILD) | ||
1735 | ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL); | ||
1736 | ret = seq_open(file, &vmalloc_op); | ||
1737 | if (!ret) { | ||
1738 | struct seq_file *m = file->private_data; | ||
1739 | m->private = ptr; | ||
1740 | } else | ||
1741 | kfree(ptr); | ||
1742 | return ret; | ||
1743 | } | ||
1744 | |||
1745 | static const struct file_operations proc_vmalloc_operations = { | ||
1746 | .open = vmalloc_open, | ||
1747 | .read = seq_read, | ||
1748 | .llseek = seq_lseek, | ||
1749 | .release = seq_release_private, | ||
1750 | }; | ||
1751 | |||
1752 | static int __init proc_vmalloc_init(void) | ||
1753 | { | ||
1754 | proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); | ||
1755 | return 0; | ||
1756 | } | ||
1757 | module_init(proc_vmalloc_init); | ||
1727 | #endif | 1758 | #endif |
1728 | 1759 | ||
diff --git a/mm/vmstat.c b/mm/vmstat.c index 9343227c5c60..c3ccfda23adc 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Copyright (C) 2006 Silicon Graphics, Inc., | 8 | * Copyright (C) 2006 Silicon Graphics, Inc., |
9 | * Christoph Lameter <christoph@lameter.com> | 9 | * Christoph Lameter <christoph@lameter.com> |
10 | */ | 10 | */ |
11 | 11 | #include <linux/fs.h> | |
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
@@ -384,7 +384,7 @@ void zone_statistics(struct zone *preferred_zone, struct zone *z) | |||
384 | #endif | 384 | #endif |
385 | 385 | ||
386 | #ifdef CONFIG_PROC_FS | 386 | #ifdef CONFIG_PROC_FS |
387 | 387 | #include <linux/proc_fs.h> | |
388 | #include <linux/seq_file.h> | 388 | #include <linux/seq_file.h> |
389 | 389 | ||
390 | static char * const migratetype_names[MIGRATE_TYPES] = { | 390 | static char * const migratetype_names[MIGRATE_TYPES] = { |
@@ -581,20 +581,44 @@ static int pagetypeinfo_show(struct seq_file *m, void *arg) | |||
581 | return 0; | 581 | return 0; |
582 | } | 582 | } |
583 | 583 | ||
584 | const struct seq_operations fragmentation_op = { | 584 | static const struct seq_operations fragmentation_op = { |
585 | .start = frag_start, | 585 | .start = frag_start, |
586 | .next = frag_next, | 586 | .next = frag_next, |
587 | .stop = frag_stop, | 587 | .stop = frag_stop, |
588 | .show = frag_show, | 588 | .show = frag_show, |
589 | }; | 589 | }; |
590 | 590 | ||
591 | const struct seq_operations pagetypeinfo_op = { | 591 | static int fragmentation_open(struct inode *inode, struct file *file) |
592 | { | ||
593 | return seq_open(file, &fragmentation_op); | ||
594 | } | ||
595 | |||
596 | static const struct file_operations fragmentation_file_operations = { | ||
597 | .open = fragmentation_open, | ||
598 | .read = seq_read, | ||
599 | .llseek = seq_lseek, | ||
600 | .release = seq_release, | ||
601 | }; | ||
602 | |||
603 | static const struct seq_operations pagetypeinfo_op = { | ||
592 | .start = frag_start, | 604 | .start = frag_start, |
593 | .next = frag_next, | 605 | .next = frag_next, |
594 | .stop = frag_stop, | 606 | .stop = frag_stop, |
595 | .show = pagetypeinfo_show, | 607 | .show = pagetypeinfo_show, |
596 | }; | 608 | }; |
597 | 609 | ||
610 | static int pagetypeinfo_open(struct inode *inode, struct file *file) | ||
611 | { | ||
612 | return seq_open(file, &pagetypeinfo_op); | ||
613 | } | ||
614 | |||
615 | static const struct file_operations pagetypeinfo_file_ops = { | ||
616 | .open = pagetypeinfo_open, | ||
617 | .read = seq_read, | ||
618 | .llseek = seq_lseek, | ||
619 | .release = seq_release, | ||
620 | }; | ||
621 | |||
598 | #ifdef CONFIG_ZONE_DMA | 622 | #ifdef CONFIG_ZONE_DMA |
599 | #define TEXT_FOR_DMA(xx) xx "_dma", | 623 | #define TEXT_FOR_DMA(xx) xx "_dma", |
600 | #else | 624 | #else |
@@ -771,7 +795,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg) | |||
771 | return 0; | 795 | return 0; |
772 | } | 796 | } |
773 | 797 | ||
774 | const struct seq_operations zoneinfo_op = { | 798 | static const struct seq_operations zoneinfo_op = { |
775 | .start = frag_start, /* iterate over all zones. The same as in | 799 | .start = frag_start, /* iterate over all zones. The same as in |
776 | * fragmentation. */ | 800 | * fragmentation. */ |
777 | .next = frag_next, | 801 | .next = frag_next, |
@@ -779,6 +803,18 @@ const struct seq_operations zoneinfo_op = { | |||
779 | .show = zoneinfo_show, | 803 | .show = zoneinfo_show, |
780 | }; | 804 | }; |
781 | 805 | ||
806 | static int zoneinfo_open(struct inode *inode, struct file *file) | ||
807 | { | ||
808 | return seq_open(file, &zoneinfo_op); | ||
809 | } | ||
810 | |||
811 | static const struct file_operations proc_zoneinfo_file_operations = { | ||
812 | .open = zoneinfo_open, | ||
813 | .read = seq_read, | ||
814 | .llseek = seq_lseek, | ||
815 | .release = seq_release, | ||
816 | }; | ||
817 | |||
782 | static void *vmstat_start(struct seq_file *m, loff_t *pos) | 818 | static void *vmstat_start(struct seq_file *m, loff_t *pos) |
783 | { | 819 | { |
784 | unsigned long *v; | 820 | unsigned long *v; |
@@ -834,13 +870,24 @@ static void vmstat_stop(struct seq_file *m, void *arg) | |||
834 | m->private = NULL; | 870 | m->private = NULL; |
835 | } | 871 | } |
836 | 872 | ||
837 | const struct seq_operations vmstat_op = { | 873 | static const struct seq_operations vmstat_op = { |
838 | .start = vmstat_start, | 874 | .start = vmstat_start, |
839 | .next = vmstat_next, | 875 | .next = vmstat_next, |
840 | .stop = vmstat_stop, | 876 | .stop = vmstat_stop, |
841 | .show = vmstat_show, | 877 | .show = vmstat_show, |
842 | }; | 878 | }; |
843 | 879 | ||
880 | static int vmstat_open(struct inode *inode, struct file *file) | ||
881 | { | ||
882 | return seq_open(file, &vmstat_op); | ||
883 | } | ||
884 | |||
885 | static const struct file_operations proc_vmstat_file_operations = { | ||
886 | .open = vmstat_open, | ||
887 | .read = seq_read, | ||
888 | .llseek = seq_lseek, | ||
889 | .release = seq_release, | ||
890 | }; | ||
844 | #endif /* CONFIG_PROC_FS */ | 891 | #endif /* CONFIG_PROC_FS */ |
845 | 892 | ||
846 | #ifdef CONFIG_SMP | 893 | #ifdef CONFIG_SMP |
@@ -898,9 +945,11 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb, | |||
898 | 945 | ||
899 | static struct notifier_block __cpuinitdata vmstat_notifier = | 946 | static struct notifier_block __cpuinitdata vmstat_notifier = |
900 | { &vmstat_cpuup_callback, NULL, 0 }; | 947 | { &vmstat_cpuup_callback, NULL, 0 }; |
948 | #endif | ||
901 | 949 | ||
902 | static int __init setup_vmstat(void) | 950 | static int __init setup_vmstat(void) |
903 | { | 951 | { |
952 | #ifdef CONFIG_SMP | ||
904 | int cpu; | 953 | int cpu; |
905 | 954 | ||
906 | refresh_zone_stat_thresholds(); | 955 | refresh_zone_stat_thresholds(); |
@@ -908,7 +957,13 @@ static int __init setup_vmstat(void) | |||
908 | 957 | ||
909 | for_each_online_cpu(cpu) | 958 | for_each_online_cpu(cpu) |
910 | start_cpu_timer(cpu); | 959 | start_cpu_timer(cpu); |
960 | #endif | ||
961 | #ifdef CONFIG_PROC_FS | ||
962 | proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); | ||
963 | proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); | ||
964 | proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); | ||
965 | proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); | ||
966 | #endif | ||
911 | return 0; | 967 | return 0; |
912 | } | 968 | } |
913 | module_init(setup_vmstat) | 969 | module_init(setup_vmstat) |
914 | #endif | ||