From e1759c215bee5abbcb6cb066590ab20905154ed5 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Wed, 15 Oct 2008 23:50:22 +0400 Subject: proc: switch /proc/meminfo to seq_file and move it to fs/proc/meminfo.c while I'm at it. Signed-off-by: Alexey Dobriyan --- include/asm-x86/pgtable.h | 3 ++- include/linux/hugetlb.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h index 88a53b1a17f0..a3dda6d615be 100644 --- a/include/asm-x86/pgtable.h +++ b/include/asm-x86/pgtable.h @@ -348,7 +348,8 @@ static inline void native_pagetable_setup_start(pgd_t *base) {} static inline void native_pagetable_setup_done(pgd_t *base) {} #endif -extern int arch_report_meminfo(char *page); +struct seq_file; +extern void arch_report_meminfo(struct seq_file *m); #ifdef CONFIG_PARAVIRT #include 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 *, void __unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long, struct page *); int hugetlb_prefault(struct address_space *, struct vm_area_struct *); -int hugetlb_report_meminfo(char *); +void hugetlb_report_meminfo(struct seq_file *); int hugetlb_report_node_meminfo(int, char *); unsigned long hugetlb_total_pages(void); int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, @@ -79,7 +79,9 @@ static inline unsigned long hugetlb_total_pages(void) #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) #define hugetlb_prefault(mapping, vma) ({ BUG(); 0; }) #define unmap_hugepage_range(vma, start, end, page) BUG() -#define hugetlb_report_meminfo(buf) 0 +static inline void hugetlb_report_meminfo(struct seq_file *m) +{ +} #define hugetlb_report_node_meminfo(n, buf) 0 #define follow_huge_pmd(mm, addr, pmd, write) NULL #define follow_huge_pud(mm, addr, pud, write) NULL -- cgit v1.2.3 From 813dcf7a6e642feb1ea566b96ce2912249d2b57d Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Fri, 3 Oct 2008 22:42:36 +0400 Subject: proc: move /proc/hardware to m68k-specific code Signed-off-by: Alexey Dobriyan --- arch/m68k/amiga/config.c | 21 +++++++++------------ arch/m68k/atari/config.c | 15 +++++++-------- arch/m68k/bvme6000/config.c | 11 ----------- arch/m68k/kernel/setup.c | 35 ++++++++++++++++++++++++++++------- arch/m68k/mvme147/config.c | 10 ---------- arch/m68k/mvme16x/config.c | 15 +++++---------- arch/m68k/q40/config.c | 10 ---------- arch/m68k/sun3/config.c | 12 +++--------- arch/m68k/sun3x/config.c | 12 +++--------- fs/proc/proc_misc.c | 13 ------------- include/asm-m68k/machdep.h | 2 +- 11 files changed, 56 insertions(+), 100 deletions(-) (limited to 'include') 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 @@ #include #include #include +#include #include #include #include @@ -93,7 +94,7 @@ static char amiga_model_name[13] = "Amiga "; static void amiga_sched_init(irq_handler_t handler); static void amiga_get_model(char *model); -static int amiga_get_hardware_list(char *buffer); +static void amiga_get_hardware_list(struct seq_file *m); /* amiga specific timer functions */ static unsigned long amiga_gettimeoffset(void); static int a3000_hwclk(int, struct rtc_time *); @@ -911,13 +912,11 @@ static void amiga_get_model(char *model) } -static int amiga_get_hardware_list(char *buffer) +static void amiga_get_hardware_list(struct seq_file *m) { - int len = 0; - if (AMIGAHW_PRESENT(CHIP_RAM)) - len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); - len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", + seq_printf(m, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); + seq_printf(m, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", amiga_psfreq, amiga_eclock); if (AMIGAHW_PRESENT(AMI_VIDEO)) { char *type; @@ -935,14 +934,14 @@ static int amiga_get_hardware_list(char *buffer) type = "Old or Unknown"; break; } - len += sprintf(buffer+len, "Graphics:\t%s\n", type); + seq_printf(m, "Graphics:\t%s\n", type); } #define AMIGAHW_ANNOUNCE(name, str) \ if (AMIGAHW_PRESENT(name)) \ - len += sprintf (buffer+len, "\t%s\n", str) + seq_printf (m, "\t%s\n", str) - len += sprintf (buffer + len, "Detected hardware:\n"); + seq_printf (m, "Detected hardware:\n"); AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video"); AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter"); @@ -975,15 +974,13 @@ static int amiga_get_hardware_list(char *buffer) AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot"); #ifdef CONFIG_ZORRO if (AMIGAHW_PRESENT(ZORRO)) - len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion " + seq_printf(m, "\tZorro II%s AutoConfig: %d Expansion " "Device%s\n", AMIGAHW_PRESENT(ZORRO3) ? "I" : "", zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s"); #endif /* CONFIG_ZORRO */ #undef AMIGAHW_ANNOUNCE - - return len; } /* 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 @@ #include #include +#include #include #include #include @@ -63,7 +64,7 @@ int atari_rtc_year_offset; /* local function prototypes */ static void atari_reset(void); static void atari_get_model(char *model); -static int atari_get_hardware_list(char *buffer); +static void atari_get_hardware_list(struct seq_file *m); /* atari specific irq functions */ extern void atari_init_IRQ (void); @@ -611,21 +612,21 @@ static void atari_get_model(char *model) } -static int atari_get_hardware_list(char *buffer) +static void atari_get_hardware_list(struct seq_file *m) { - int len = 0, i; + int i; for (i = 0; i < m68k_num_memory; i++) - len += sprintf(buffer+len, "\t%3ld MB at 0x%08lx (%s)\n", + seq_printf(m, "\t%3ld MB at 0x%08lx (%s)\n", m68k_memory[i].size >> 20, m68k_memory[i].addr, (m68k_memory[i].addr & 0xff000000 ? "alternate RAM" : "ST-RAM")); #define ATARIHW_ANNOUNCE(name, str) \ if (ATARIHW_PRESENT(name)) \ - len += sprintf(buffer + len, "\t%s\n", str) + seq_printf(m, "\t%s\n", str) - len += sprintf(buffer + len, "Detected hardware:\n"); + seq_printf(m, "Detected hardware:\n"); ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter"); ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter"); ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter"); @@ -654,6 +655,4 @@ static int atari_get_hardware_list(char *buffer) ATARIHW_ANNOUNCE(BLITTER, "Blitter"); ATARIHW_ANNOUNCE(VME, "VME Bus"); ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor"); - - return len; } 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 @@ #include static void bvme6000_get_model(char *model); -static int bvme6000_get_hardware_list(char *buffer); extern void bvme6000_sched_init(irq_handler_t handler); extern unsigned long bvme6000_gettimeoffset (void); extern int bvme6000_hwclk (int, struct rtc_time *); @@ -82,15 +81,6 @@ static void bvme6000_get_model(char *model) sprintf(model, "BVME%d000", m68k_cputype == CPU_68060 ? 6 : 4); } - -/* No hardware options on BVME6000? */ - -static int bvme6000_get_hardware_list(char *buffer) -{ - *buffer = '\0'; - return 0; -} - /* * This function is called during kernel startup to initialize * the bvme6000 IRQ handling routines. @@ -127,7 +117,6 @@ void __init config_bvme6000(void) mach_set_clock_mmss = bvme6000_set_clock_mmss; mach_reset = bvme6000_reset; mach_get_model = bvme6000_get_model; - mach_get_hardware_list = bvme6000_get_hardware_list; printk ("Board is %sconfigured as a System Controller\n", *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 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,7 @@ void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL; /* machine dependent irq functions */ void (*mach_init_IRQ) (void) __initdata = NULL; void (*mach_get_model) (char *model); -int (*mach_get_hardware_list) (char *buffer); +void (*mach_get_hardware_list) (struct seq_file *m); /* machine dependent timer functions */ unsigned long (*mach_gettimeoffset) (void); int (*mach_hwclk) (int, struct rtc_time*); @@ -467,9 +468,9 @@ const struct seq_operations cpuinfo_op = { .show = show_cpuinfo, }; -int get_hardware_list(char *buffer) +#ifdef CONFIG_PROC_HARDWARE +static int hardware_proc_show(struct seq_file *m, void *v) { - int len = 0; char model[80]; unsigned long mem; int i; @@ -479,17 +480,37 @@ int get_hardware_list(char *buffer) else strcpy(model, "Unknown m68k"); - len += sprintf(buffer + len, "Model:\t\t%s\n", model); + seq_printf(m, "Model:\t\t%s\n", model); for (mem = 0, i = 0; i < m68k_num_memory; i++) mem += m68k_memory[i].size; - len += sprintf(buffer + len, "System Memory:\t%ldK\n", mem >> 10); + seq_printf(m, "System Memory:\t%ldK\n", mem >> 10); if (mach_get_hardware_list) - len += mach_get_hardware_list(buffer + len); + mach_get_hardware_list(m); - return len; + return 0; +} + +static int hardware_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, hardware_proc_show, NULL); } +static const struct file_operations hardware_proc_fops = { + .open = hardware_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int __init proc_hardware_init(void) +{ + proc_create("hardware", 0, NULL, &hardware_proc_fops); + return 0; +} +module_init(proc_hardware_init); +#endif + void check_bugs(void) { #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 @@ static void mvme147_get_model(char *model); -static int mvme147_get_hardware_list(char *buffer); extern void mvme147_sched_init(irq_handler_t handler); extern unsigned long mvme147_gettimeoffset (void); extern int mvme147_hwclk (int, struct rtc_time *); @@ -76,14 +75,6 @@ static void mvme147_get_model(char *model) sprintf(model, "Motorola MVME147"); } - -static int mvme147_get_hardware_list(char *buffer) -{ - *buffer = '\0'; - - return 0; -} - /* * This function is called during kernel startup to initialize * the mvme147 IRQ handling routines. @@ -104,7 +95,6 @@ void __init config_mvme147(void) mach_set_clock_mmss = mvme147_set_clock_mmss; mach_reset = mvme147_reset; mach_get_model = mvme147_get_model; - mach_get_hardware_list = mvme147_get_hardware_list; /* Board type is only set by newer versions of vmelilo/tftplilo */ 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 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,6 @@ extern t_bdid mvme_bdid; static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE; static void mvme16x_get_model(char *model); -static int mvme16x_get_hardware_list(char *buffer); extern void mvme16x_sched_init(irq_handler_t handler); extern unsigned long mvme16x_gettimeoffset (void); extern int mvme16x_hwclk (int, struct rtc_time *); @@ -93,26 +93,21 @@ static void mvme16x_get_model(char *model) } -static int mvme16x_get_hardware_list(char *buffer) +static void mvme16x_get_hardware_list(struct seq_file *m) { p_bdid p = &mvme_bdid; - int len = 0; if (p->brdno == 0x0162 || p->brdno == 0x0172) { unsigned char rev = *(unsigned char *)MVME162_VERSION_REG; - len += sprintf (buffer+len, "VMEchip2 %spresent\n", + seq_printf (m, "VMEchip2 %spresent\n", rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : ""); - len += sprintf (buffer+len, "SCSI interface %spresent\n", + seq_printf (m, "SCSI interface %spresent\n", rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : ""); - len += sprintf (buffer+len, "Ethernet i/f %spresent\n", + seq_printf (m, "Ethernet i/f %spresent\n", rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : ""); } - else - *buffer = '\0'; - - return (len); } /* 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 @@ extern irqreturn_t q40_process_int(int level, struct pt_regs *regs); extern void q40_init_IRQ(void); static void q40_get_model(char *model); -static int q40_get_hardware_list(char *buffer); extern void q40_sched_init(irq_handler_t handler); static unsigned long q40_gettimeoffset(void); @@ -153,14 +152,6 @@ static void q40_get_model(char *model) sprintf(model, "Q40"); } -/* No hardware options on Q40? */ - -static int q40_get_hardware_list(char *buffer) -{ - *buffer = '\0'; - return 0; -} - static unsigned int serports[] = { 0x3f8,0x2f8,0x3e8,0x2e8,0 @@ -191,7 +182,6 @@ void __init config_q40(void) mach_reset = q40_reset; mach_get_model = q40_get_model; - mach_get_hardware_list = q40_get_hardware_list; #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 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 @@ #include #include #include +#include #include #include #include @@ -46,16 +47,9 @@ extern volatile unsigned char* sun3_intreg; extern unsigned long availmem; unsigned long num_pages; -static int sun3_get_hardware_list(char *buffer) +static void sun3_get_hardware_list(struct seq_file *m) { - - int len = 0; - - len += sprintf(buffer + len, "PROM Revision:\t%s\n", - romvec->pv_monid); - - return len; - + seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid); } 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 @@ #include #include +#include #include #include @@ -31,16 +32,9 @@ void sun3_leds(unsigned int i) } -static int sun3x_get_hardware_list(char *buffer) +static void sun3x_get_hardware_list(struct seq_file *m) { - - int len = 0; - - len += sprintf(buffer + len, "PROM Revision:\t%s\n", - romvec->pv_monid); - - return len; - + seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid); } /* diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 4814b111d836..542527f6630f 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -63,7 +63,6 @@ * have a way to deal with that gracefully. Right now I used straightforward * wrappers, but this needs further analysis wrt potential overflows. */ -extern int get_hardware_list(char *); extern int get_stram_list(char *); extern int get_exec_domain_list(char *); @@ -198,15 +197,6 @@ static const struct file_operations proc_vmstat_file_operations = { .release = seq_release, }; -#ifdef CONFIG_PROC_HARDWARE -static int hardware_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - int len = get_hardware_list(page); - return proc_calc_metrics(page, start, off, count, eof, len); -} -#endif - #ifdef CONFIG_STRAM_PROC static int stram_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -668,9 +658,6 @@ void __init proc_misc_init(void) char *name; int (*read_proc)(char*,char**,off_t,int,int*,void*); } *p, simple_ones[] = { -#ifdef CONFIG_PROC_HARDWARE - {"hardware", hardware_read_proc}, -#endif #ifdef CONFIG_STRAM_PROC {"stram", stram_read_proc}, #endif 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); /* machine dependent irq functions */ extern void (*mach_init_IRQ) (void); extern void (*mach_get_model) (char *model); -extern int (*mach_get_hardware_list) (char *buffer); +extern void (*mach_get_hardware_list) (struct seq_file *m); /* machine dependent timer functions */ extern unsigned long (*mach_gettimeoffset)(void); extern int (*mach_hwclk)(int, struct rtc_time*); -- cgit v1.2.3 From d8ba7a363393f803c93c8cffabd6d0362618bc2a Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sat, 4 Oct 2008 22:34:18 +0400 Subject: proc: move rest of /proc/locks to fs/locks.c Signed-off-by: Alexey Dobriyan --- fs/locks.c | 22 +++++++++++++++++++++- fs/proc/proc_misc.c | 17 ----------------- include/linux/fs.h | 1 - 3 files changed, 21 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/fs/locks.c b/fs/locks.c index 5eb259e3cd38..90e87f57b331 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2078,6 +2078,7 @@ int vfs_cancel_lock(struct file *filp, struct file_lock *fl) EXPORT_SYMBOL_GPL(vfs_cancel_lock); #ifdef CONFIG_PROC_FS +#include #include static void lock_get_status(struct seq_file *f, struct file_lock *fl, @@ -2183,12 +2184,31 @@ static void locks_stop(struct seq_file *f, void *v) unlock_kernel(); } -struct seq_operations locks_seq_operations = { +static const struct seq_operations locks_seq_operations = { .start = locks_start, .next = locks_next, .stop = locks_stop, .show = locks_show, }; + +static int locks_open(struct inode *inode, struct file *filp) +{ + return seq_open(filp, &locks_seq_operations); +} + +static const struct file_operations proc_locks_operations = { + .open = locks_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int __init proc_locks_init(void) +{ + proc_create("locks", 0, NULL, &proc_locks_operations); + return 0; +} +module_init(proc_locks_init); #endif /** diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index fcac25edaef7..fea7d658fff6 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -453,20 +453,6 @@ static const struct file_operations proc_interrupts_operations = { .release = seq_release, }; -#ifdef CONFIG_FILE_LOCKING -static int locks_open(struct inode *inode, struct file *filp) -{ - return seq_open(filp, &locks_seq_operations); -} - -static const struct file_operations proc_locks_operations = { - .open = locks_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; -#endif /* CONFIG_FILE_LOCKING */ - #ifdef CONFIG_PROC_PAGE_MONITOR #define KPMSIZE sizeof(u64) #define KPMMASK (KPMSIZE - 1) @@ -605,9 +591,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_FILE_LOCKING - proc_create("locks", 0, NULL, &proc_locks_operations); -#endif proc_create("devices", 0, NULL, &proc_devinfo_operations); proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); #ifdef CONFIG_BLOCK diff --git a/include/linux/fs.h b/include/linux/fs.h index a6a625be13fc..024049543ae1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1037,7 +1037,6 @@ extern int vfs_setlease(struct file *, long, struct file_lock **); extern int lease_modify(struct file_lock **, int); extern int lock_may_read(struct inode *, loff_t start, unsigned long count); extern int lock_may_write(struct inode *, loff_t start, unsigned long count); -extern struct seq_operations locks_seq_operations; #else /* !CONFIG_FILE_LOCKING */ #define fcntl_getlk(a, b) ({ -EINVAL; }) #define fcntl_setlk(a, b, c, d) ({ -EACCES; }) -- cgit v1.2.3 From f500975a3f3ecf3611d79f1d933906753460b9f2 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sat, 4 Oct 2008 23:53:21 +0400 Subject: proc: move rest of /proc/partitions code to block/genhd.c Signed-off-by: Alexey Dobriyan Acked-by: Jens Axboe --- block/genhd.c | 22 +++++++++++++++++++++- fs/proc/proc_misc.c | 14 -------------- include/linux/genhd.h | 1 - 3 files changed, 21 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/block/genhd.c b/block/genhd.c index 646e1d2507c7..15f4d2b12c48 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -727,12 +728,24 @@ static int show_partition(struct seq_file *seqf, void *v) return 0; } -const struct seq_operations partitions_op = { +static const struct seq_operations partitions_op = { .start = show_partition_start, .next = disk_seqf_next, .stop = disk_seqf_stop, .show = show_partition }; + +static int partitions_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &partitions_op); +} + +static const struct file_operations proc_partitions_operations = { + .open = partitions_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif @@ -998,6 +1011,13 @@ const struct seq_operations diskstats_op = { .stop = disk_seqf_stop, .show = diskstats_show }; + +static int __init proc_genhd_init(void) +{ + proc_create("partitions", 0, NULL, &proc_partitions_operations); + return 0; +} +module_init(proc_genhd_init); #endif /* CONFIG_PROC_FS */ static void media_change_notify_thread(struct work_struct *work) diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 8974809be5f6..253ea50c4393 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -106,17 +106,6 @@ static const struct file_operations proc_vmstat_file_operations = { }; #ifdef CONFIG_BLOCK -static int partitions_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &partitions_op); -} -static const struct file_operations proc_partitions_operations = { - .open = partitions_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - static int diskstats_open(struct inode *inode, struct file *file) { return seq_open(file, &diskstats_op); @@ -519,9 +508,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_BLOCK - proc_create("partitions", 0, NULL, &proc_partitions_operations); -#endif proc_create("stat", 0, NULL, &proc_stat_operations); proc_create("interrupts", 0, NULL, &proc_interrupts_operations); #ifdef CONFIG_SLABINFO diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 206cdf96c3a7..074a4fdf4365 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -25,7 +25,6 @@ extern struct device_type part_type; extern struct kobject *block_depr; extern struct class block_class; -extern const struct seq_operations partitions_op; extern const struct seq_operations diskstats_op; enum { -- cgit v1.2.3 From 7b3c3a50a3e0ea46815150d420fa276ac254572b Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 02:42:17 +0400 Subject: proc: move /proc/slabinfo boilerplate to mm/slub.c, mm/slab.c Lose dummy ->write hook in case of SLUB, it's possible now. Signed-off-by: Alexey Dobriyan Acked-by: Pekka Enberg --- fs/proc/proc_misc.c | 17 ----------------- include/linux/slab.h | 5 ----- mm/slab.c | 16 +++++++++++++++- mm/slub.c | 29 ++++++++++++++++++++--------- 4 files changed, 35 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 5bca02842d07..1d6d5c5cc2a8 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -132,20 +132,6 @@ static const struct file_operations proc_modules_operations = { }; #endif -#ifdef CONFIG_SLABINFO -static int slabinfo_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &slabinfo_op); -} -static const struct file_operations proc_slabinfo_operations = { - .open = slabinfo_open, - .read = seq_read, - .write = slabinfo_write, - .llseek = seq_lseek, - .release = seq_release, -}; -#endif - #ifdef CONFIG_MMU static int vmalloc_open(struct inode *inode, struct file *file) { @@ -309,9 +295,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_SLABINFO - proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); -#endif #ifdef CONFIG_MMU proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); #endif 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) return kmalloc_node(size, flags | __GFP_ZERO, node); } -#ifdef CONFIG_SLABINFO -extern const struct seq_operations slabinfo_op; -ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *); -#endif - #endif /* _LINUX_SLAB_H */ diff --git a/mm/slab.c b/mm/slab.c index d53ac9c26ab7..09187517f9dc 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -4259,7 +4259,7 @@ static int s_show(struct seq_file *m, void *p) * + further values on SMP and with statistics enabled */ -const struct seq_operations slabinfo_op = { +static const struct seq_operations slabinfo_op = { .start = s_start, .next = s_next, .stop = s_stop, @@ -4316,6 +4316,19 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer, return res; } +static int slabinfo_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &slabinfo_op); +} + +static const struct file_operations proc_slabinfo_operations = { + .open = slabinfo_open, + .read = seq_read, + .write = slabinfo_write, + .llseek = seq_lseek, + .release = seq_release, +}; + #ifdef CONFIG_DEBUG_SLAB_LEAK static void *leaks_start(struct seq_file *m, loff_t *pos) @@ -4478,6 +4491,7 @@ static const struct file_operations proc_slabstats_operations = { static int __init slab_proc_init(void) { + proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); #ifdef CONFIG_DEBUG_SLAB_LEAK proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); #endif diff --git a/mm/slub.c b/mm/slub.c index 0c83e6afe7b2..7ad489af9561 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -4417,14 +4418,6 @@ __initcall(slab_sysfs_init); * The /proc/slabinfo ABI */ #ifdef CONFIG_SLABINFO - -ssize_t slabinfo_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - return -EINVAL; -} - - static void print_slabinfo_header(struct seq_file *m) { seq_puts(m, "slabinfo - version: 2.1\n"); @@ -4492,11 +4485,29 @@ static int s_show(struct seq_file *m, void *p) return 0; } -const struct seq_operations slabinfo_op = { +static const struct seq_operations slabinfo_op = { .start = s_start, .next = s_next, .stop = s_stop, .show = s_show, }; +static int slabinfo_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &slabinfo_op); +} + +static const struct file_operations proc_slabinfo_operations = { + .open = slabinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int __init slab_proc_init(void) +{ + proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); + return 0; +} +module_init(slab_proc_init); #endif /* CONFIG_SLABINFO */ -- cgit v1.2.3 From 5f6a6a9c4e4d790aae55cb412a7643329057c5e0 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 03:50:47 +0400 Subject: proc: move /proc/vmallocinfo to mm/vmalloc.c Signed-off-by: Alexey Dobriyan Acked-by: Christoph Lameter --- fs/proc/proc_misc.c | 28 ---------------------------- include/linux/vmalloc.h | 2 -- mm/vmalloc.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 1d6d5c5cc2a8..fd41a032456b 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -132,31 +132,6 @@ static const struct file_operations proc_modules_operations = { }; #endif -#ifdef CONFIG_MMU -static int vmalloc_open(struct inode *inode, struct file *file) -{ - unsigned int *ptr = NULL; - int ret; - - if (NUMA_BUILD) - ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL); - ret = seq_open(file, &vmalloc_op); - if (!ret) { - struct seq_file *m = file->private_data; - m->private = ptr; - } else - kfree(ptr); - return ret; -} - -static const struct file_operations proc_vmalloc_operations = { - .open = vmalloc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, -}; -#endif - #ifdef CONFIG_PROC_PAGE_MONITOR #define KPMSIZE sizeof(u64) #define KPMMASK (KPMSIZE - 1) @@ -295,9 +270,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_MMU - proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); -#endif proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); 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); extern rwlock_t vmlist_lock; extern struct vm_struct *vmlist; -extern const struct seq_operations vmalloc_op; - #endif /* _LINUX_VMALLOC_H */ 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 @@ #include #include #include +#include #include #include #include @@ -1718,11 +1719,41 @@ static int s_show(struct seq_file *m, void *p) return 0; } -const struct seq_operations vmalloc_op = { +static const struct seq_operations vmalloc_op = { .start = s_start, .next = s_next, .stop = s_stop, .show = s_show, }; + +static int vmalloc_open(struct inode *inode, struct file *file) +{ + unsigned int *ptr = NULL; + int ret; + + if (NUMA_BUILD) + ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL); + ret = seq_open(file, &vmalloc_op); + if (!ret) { + struct seq_file *m = file->private_data; + m->private = ptr; + } else + kfree(ptr); + return ret; +} + +static const struct file_operations proc_vmalloc_operations = { + .open = vmalloc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, +}; + +static int __init proc_vmalloc_init(void) +{ + proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); + return 0; +} +module_init(proc_vmalloc_init); #endif -- cgit v1.2.3 From 8f32f7e5ac2ed11b0659b6b55af926f3d58ffd9d Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 04:13:52 +0400 Subject: proc: move /proc/buddyinfo boilerplate to mm/vmstat.c Signed-off-by: Alexey Dobriyan --- fs/proc/proc_misc.c | 14 -------------- include/linux/vmstat.h | 1 - mm/vmstat.c | 25 +++++++++++++++++++++---- 3 files changed, 21 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index fd41a032456b..a35e50659b8d 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -57,19 +57,6 @@ #include #include "internal.h" -static int fragmentation_open(struct inode *inode, struct file *file) -{ - (void)inode; - return seq_open(file, &fragmentation_op); -} - -static const struct file_operations fragmentation_file_operations = { - .open = fragmentation_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - static int pagetypeinfo_open(struct inode *inode, struct file *file) { return seq_open(file, &pagetypeinfo_op); @@ -270,7 +257,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 9cd3ab0f554d..d4551f206409 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -54,7 +54,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, NR_VM_EVENT_ITEMS }; -extern const struct seq_operations fragmentation_op; extern const struct seq_operations pagetypeinfo_op; extern const struct seq_operations zoneinfo_op; extern const struct seq_operations vmstat_op; diff --git a/mm/vmstat.c b/mm/vmstat.c index 9343227c5c60..f45d7245a282 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -8,7 +8,7 @@ * Copyright (C) 2006 Silicon Graphics, Inc., * Christoph Lameter */ - +#include #include #include #include @@ -384,7 +384,7 @@ void zone_statistics(struct zone *preferred_zone, struct zone *z) #endif #ifdef CONFIG_PROC_FS - +#include #include static char * const migratetype_names[MIGRATE_TYPES] = { @@ -581,13 +581,25 @@ static int pagetypeinfo_show(struct seq_file *m, void *arg) return 0; } -const struct seq_operations fragmentation_op = { +static const struct seq_operations fragmentation_op = { .start = frag_start, .next = frag_next, .stop = frag_stop, .show = frag_show, }; +static int fragmentation_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &fragmentation_op); +} + +static const struct file_operations fragmentation_file_operations = { + .open = fragmentation_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + const struct seq_operations pagetypeinfo_op = { .start = frag_start, .next = frag_next, @@ -898,9 +910,11 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb, static struct notifier_block __cpuinitdata vmstat_notifier = { &vmstat_cpuup_callback, NULL, 0 }; +#endif static int __init setup_vmstat(void) { +#ifdef CONFIG_SMP int cpu; refresh_zone_stat_thresholds(); @@ -908,7 +922,10 @@ static int __init setup_vmstat(void) for_each_online_cpu(cpu) start_cpu_timer(cpu); +#endif +#ifdef CONFIG_PROC_FS + proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); +#endif return 0; } module_init(setup_vmstat) -#endif -- cgit v1.2.3 From 74e2e8e8ce7b3c0f878a349f9fa6cf2831548eef Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 04:15:36 +0400 Subject: proc: move /proc/pagetypeinfo boilerplate to mm/vmstat.c Signed-off-by: Alexey Dobriyan --- fs/proc/proc_misc.c | 13 ------------- include/linux/vmstat.h | 1 - mm/vmstat.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index a35e50659b8d..900331a634ef 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -57,18 +57,6 @@ #include #include "internal.h" -static int pagetypeinfo_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &pagetypeinfo_op); -} - -static const struct file_operations pagetypeinfo_file_ops = { - .open = pagetypeinfo_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - static int zoneinfo_open(struct inode *inode, struct file *file) { return seq_open(file, &zoneinfo_op); @@ -257,7 +245,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); #ifdef CONFIG_BLOCK diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index d4551f206409..33ffd89a88ac 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -54,7 +54,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, NR_VM_EVENT_ITEMS }; -extern const struct seq_operations pagetypeinfo_op; extern const struct seq_operations zoneinfo_op; extern const struct seq_operations vmstat_op; extern int sysctl_stat_interval; diff --git a/mm/vmstat.c b/mm/vmstat.c index f45d7245a282..d624d251946d 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -600,13 +600,25 @@ static const struct file_operations fragmentation_file_operations = { .release = seq_release, }; -const struct seq_operations pagetypeinfo_op = { +static const struct seq_operations pagetypeinfo_op = { .start = frag_start, .next = frag_next, .stop = frag_stop, .show = pagetypeinfo_show, }; +static int pagetypeinfo_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &pagetypeinfo_op); +} + +static const struct file_operations pagetypeinfo_file_ops = { + .open = pagetypeinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + #ifdef CONFIG_ZONE_DMA #define TEXT_FOR_DMA(xx) xx "_dma", #else @@ -925,6 +937,7 @@ static int __init setup_vmstat(void) #endif #ifdef CONFIG_PROC_FS proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); + proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); #endif return 0; } -- cgit v1.2.3 From b6aa44ab698c7df9d951d3eb45c4fcb8ba68fb25 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 04:17:48 +0400 Subject: proc: move /proc/vmstat boilerplate to mm/vmstat.c Signed-off-by: Alexey Dobriyan Acked-by: Christoph Lameter --- fs/proc/proc_misc.c | 12 ------------ include/linux/vmstat.h | 1 - mm/vmstat.c | 14 +++++++++++++- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 900331a634ef..e7a301d5d432 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -69,17 +69,6 @@ static const struct file_operations proc_zoneinfo_file_operations = { .release = seq_release, }; -static int vmstat_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &vmstat_op); -} -static const struct file_operations proc_vmstat_file_operations = { - .open = vmstat_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - #ifdef CONFIG_BLOCK static int diskstats_open(struct inode *inode, struct file *file) { @@ -245,7 +234,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); #ifdef CONFIG_BLOCK proc_create("diskstats", 0, NULL, &proc_diskstats_operations); diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 33ffd89a88ac..7b68c4c1e19c 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -55,7 +55,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, }; extern const struct seq_operations zoneinfo_op; -extern const struct seq_operations vmstat_op; extern int sysctl_stat_interval; #ifdef CONFIG_VM_EVENT_COUNTERS diff --git a/mm/vmstat.c b/mm/vmstat.c index d624d251946d..7e1854b81868 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -858,13 +858,24 @@ static void vmstat_stop(struct seq_file *m, void *arg) m->private = NULL; } -const struct seq_operations vmstat_op = { +static const struct seq_operations vmstat_op = { .start = vmstat_start, .next = vmstat_next, .stop = vmstat_stop, .show = vmstat_show, }; +static int vmstat_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &vmstat_op); +} + +static const struct file_operations proc_vmstat_file_operations = { + .open = vmstat_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif /* CONFIG_PROC_FS */ #ifdef CONFIG_SMP @@ -938,6 +949,7 @@ static int __init setup_vmstat(void) #ifdef CONFIG_PROC_FS proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); #endif return 0; } -- cgit v1.2.3 From 5c9fe6281b75832e8d2555ec8700ea763d9a865e Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 04:19:42 +0400 Subject: proc: move /proc/zoneinfo boilerplate to mm/vmstat.c Signed-off-by: Alexey Dobriyan Acked-by: Christoph Lameter --- fs/proc/proc_misc.c | 13 ------------- include/linux/vmstat.h | 1 - mm/vmstat.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index e7a301d5d432..8f3a6f085c5f 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -57,18 +57,6 @@ #include #include "internal.h" -static int zoneinfo_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &zoneinfo_op); -} - -static const struct file_operations proc_zoneinfo_file_operations = { - .open = zoneinfo_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - #ifdef CONFIG_BLOCK static int diskstats_open(struct inode *inode, struct file *file) { @@ -234,7 +222,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); #ifdef CONFIG_BLOCK proc_create("diskstats", 0, NULL, &proc_diskstats_operations); #endif diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 7b68c4c1e19c..524cd1b28ecb 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -54,7 +54,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, NR_VM_EVENT_ITEMS }; -extern const struct seq_operations zoneinfo_op; extern int sysctl_stat_interval; #ifdef CONFIG_VM_EVENT_COUNTERS diff --git a/mm/vmstat.c b/mm/vmstat.c index 7e1854b81868..c3ccfda23adc 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -795,7 +795,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg) return 0; } -const struct seq_operations zoneinfo_op = { +static const struct seq_operations zoneinfo_op = { .start = frag_start, /* iterate over all zones. The same as in * fragmentation. */ .next = frag_next, @@ -803,6 +803,18 @@ const struct seq_operations zoneinfo_op = { .show = zoneinfo_show, }; +static int zoneinfo_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &zoneinfo_op); +} + +static const struct file_operations proc_zoneinfo_file_operations = { + .open = zoneinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static void *vmstat_start(struct seq_file *m, loff_t *pos) { unsigned long *v; @@ -950,6 +962,7 @@ static int __init setup_vmstat(void) proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); + proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); #endif return 0; } -- cgit v1.2.3 From 31d85ab28e71b0c938e0ef48af45747e80d99b53 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 12:55:38 +0400 Subject: proc: move /proc/diskstats boilerplate to block/genhd.c Signed-off-by: Alexey Dobriyan Acked-by: Jens Axboe --- block/genhd.c | 15 ++++++++++++++- fs/proc/proc_misc.c | 16 ---------------- include/linux/genhd.h | 2 -- 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/block/genhd.c b/block/genhd.c index 15f4d2b12c48..4e5e7493f676 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1005,15 +1005,28 @@ static int diskstats_show(struct seq_file *seqf, void *v) return 0; } -const struct seq_operations diskstats_op = { +static const struct seq_operations diskstats_op = { .start = disk_seqf_start, .next = disk_seqf_next, .stop = disk_seqf_stop, .show = diskstats_show }; +static int diskstats_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &diskstats_op); +} + +static const struct file_operations proc_diskstats_operations = { + .open = diskstats_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int __init proc_genhd_init(void) { + proc_create("diskstats", 0, NULL, &proc_diskstats_operations); proc_create("partitions", 0, NULL, &proc_partitions_operations); return 0; } diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 8f3a6f085c5f..7c22831efd94 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -57,19 +57,6 @@ #include #include "internal.h" -#ifdef CONFIG_BLOCK -static int diskstats_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &diskstats_op); -} -static const struct file_operations proc_diskstats_operations = { - .open = diskstats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; -#endif - #ifdef CONFIG_MODULES extern const struct seq_operations modules_op; static int modules_open(struct inode *inode, struct file *file) @@ -222,9 +209,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_BLOCK - proc_create("diskstats", 0, NULL, &proc_diskstats_operations); -#endif #ifdef CONFIG_MODULES proc_create("modules", 0, NULL, &proc_modules_operations); #endif diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 074a4fdf4365..e439e6aed832 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -25,8 +25,6 @@ extern struct device_type part_type; extern struct kobject *block_depr; extern struct class block_class; -extern const struct seq_operations diskstats_op; - enum { /* These three have identical behaviour; use the second one if DOS FDISK gets confused about extended/logical partitions starting past cylinder 1023. */ -- cgit v1.2.3 From b5aadf7f14c1acc94956aa257e018e9de3881f41 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 13:23:43 +0400 Subject: proc: move /proc/schedstat boilerplate to kernel/sched_stats.h Signed-off-by: Alexey Dobriyan --- fs/proc/proc_misc.c | 3 --- include/linux/sched.h | 4 ---- kernel/sched.c | 1 + kernel/sched_stats.h | 9 ++++++++- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index f6d25db98922..4a768ed5da2e 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -195,9 +195,6 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_SCHEDSTATS - proc_create("schedstat", 0, NULL, &proc_schedstat_operations); -#endif #ifdef CONFIG_PROC_KCORE proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations); if (proc_root_kcore) diff --git a/include/linux/sched.h b/include/linux/sched.h index 5c38db536e07..7f60cb9b53cb 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -681,10 +681,6 @@ struct sched_info { }; #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ -#ifdef CONFIG_SCHEDSTATS -extern const struct file_operations proc_schedstat_operations; -#endif /* CONFIG_SCHEDSTATS */ - #ifdef CONFIG_TASK_DELAY_ACCT struct task_delay_info { spinlock_t lock; diff --git a/kernel/sched.c b/kernel/sched.c index d906f72b42d2..5a70189d5051 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h index b8c156979cf2..3d14ce273902 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) return res; } -const struct file_operations proc_schedstat_operations = { +static const struct file_operations proc_schedstat_operations = { .open = schedstat_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; +static int __init proc_schedstat_init(void) +{ + proc_create("schedstat", 0, NULL, &proc_schedstat_operations); + return 0; +} +module_init(proc_schedstat_init); + /* * Expects runqueue lock to be held for atomicity of update */ -- cgit v1.2.3 From 97ce5d6dcb07c403c0fc6001b755aacc38b5d7ff Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 14:14:19 +0400 Subject: proc: move all /proc/kcore stuff to fs/proc/kcore.c Signed-off-by: Alexey Dobriyan --- fs/proc/kcore.c | 14 +++++++++++++- fs/proc/proc_misc.c | 8 -------- include/linux/proc_fs.h | 4 ---- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'include') 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 @@ #define ELF_CORE_EFLAGS 0 #endif +static struct proc_dir_entry *proc_root_kcore; + static int open_kcore(struct inode * inode, struct file * filp) { return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; @@ -34,7 +36,7 @@ static int open_kcore(struct inode * inode, struct file * filp) static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *); -const struct file_operations proc_kcore_operations = { +static const struct file_operations proc_kcore_operations = { .read = read_kcore, .open = open_kcore, }; @@ -399,3 +401,13 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) return acc; } + +static int __init proc_kcore_init(void) +{ + proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations); + if (proc_root_kcore) + proc_root_kcore->size = + (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE; + return 0; +} +module_init(proc_kcore_init); diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 4a768ed5da2e..5ed15ff8fd1d 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -188,19 +188,11 @@ static struct file_operations proc_kpageflags_operations = { }; #endif /* CONFIG_PROC_PAGE_MONITOR */ -struct proc_dir_entry *proc_root_kcore; - void __init proc_misc_init(void) { proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_PROC_KCORE - proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations); - if (proc_root_kcore) - proc_root_kcore->size = - (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE; -#endif #ifdef CONFIG_PROC_PAGE_MONITOR proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations); proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations); diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 27d534f4470d..9d8308905053 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -97,8 +97,6 @@ struct vmcore { #ifdef CONFIG_PROC_FS -extern struct proc_dir_entry *proc_root_kcore; - extern spinlock_t proc_subdir_lock; extern void proc_root_init(void); @@ -138,8 +136,6 @@ extern struct inode *proc_get_inode(struct super_block *, unsigned int, struct p extern int proc_readdir(struct file *, void *, filldir_t); extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *); -extern const struct file_operations proc_kcore_operations; - extern int pid_ns_prepare_proc(struct pid_namespace *ns); extern void pid_ns_release_proc(struct pid_namespace *ns); -- cgit v1.2.3 From 5aa140c2deca3701238d5acddf436ad7b02664c7 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 14:36:31 +0400 Subject: proc: move /proc/vmcore creation to fs/proc/vmcore.c Signed-off-by: Alexey Dobriyan --- fs/proc/proc_misc.c | 3 --- fs/proc/vmcore.c | 6 +++--- include/linux/crash_dump.h | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 2ef9ef9bc8c1..e2db35006c05 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -62,7 +62,4 @@ void __init proc_misc_init(void) proc_symlink("mounts", NULL, "self/mounts"); /* And now for trickier ones */ -#ifdef CONFIG_PROC_VMCORE - proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); -#endif } 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; /* Total size of vmcore file. */ static u64 vmcore_size; -struct proc_dir_entry *proc_vmcore = NULL; +static struct proc_dir_entry *proc_vmcore = NULL; /* Reads a page from the oldmem device from given offset. */ 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, return acc; } -const struct file_operations proc_vmcore_operations = { +static const struct file_operations proc_vmcore_operations = { .read = read_vmcore, }; @@ -652,7 +652,7 @@ static int __init vmcore_init(void) return rc; } - /* Initialize /proc/vmcore size if proc is already up. */ + proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); if (proc_vmcore) proc_vmcore->size = vmcore_size; return 0; 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; extern ssize_t copy_oldmem_page(unsigned long, char *, size_t, unsigned long, int); -extern const struct file_operations proc_vmcore_operations; -extern struct proc_dir_entry *proc_vmcore; /* Architecture code defines this if there are other possible ELF * machine types, e.g. on bi-arch capable hardware. */ -- cgit v1.2.3 From 59c7572e82d69483a66eaa67b46548baeb69ecf4 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Mon, 6 Oct 2008 14:49:39 +0400 Subject: proc: remove fs/proc/proc_misc.c Now that everything was moved to their more or less expected places, apply rm(1). Signed-off-by: Alexey Dobriyan --- fs/proc/Makefile | 2 +- fs/proc/proc_misc.c | 65 ------------------------------------------------- fs/proc/root.c | 2 +- include/linux/proc_fs.h | 1 - 4 files changed, 2 insertions(+), 68 deletions(-) delete mode 100644 fs/proc/proc_misc.c (limited to 'include') diff --git a/fs/proc/Makefile b/fs/proc/Makefile index fef524410e86..63d965193b22 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile @@ -8,7 +8,7 @@ proc-y := nommu.o task_nommu.o proc-$(CONFIG_MMU) := mmu.o task_mmu.o proc-y += inode.o root.o base.o generic.o array.o \ - proc_tty.o proc_misc.o + proc_tty.o proc-y += cmdline.o proc-y += cpuinfo.o proc-y += devices.o diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c deleted file mode 100644 index e2db35006c05..000000000000 --- a/fs/proc/proc_misc.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * linux/fs/proc/proc_misc.c - * - * linux/fs/proc/array.c - * Copyright (C) 1992 by Linus Torvalds - * based on ideas by Darren Senn - * - * This used to be the part of array.c. See the rest of history and credits - * there. I took this into a separate file and switched the thing to generic - * proc_file_inode_operations, leaving in array.c only per-process stuff. - * Inumbers allocation made dynamic (via create_proc_entry()). AV, May 1999. - * - * Changes: - * Fulton Green : Encapsulated position metric calculations. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "internal.h" - -void __init proc_misc_init(void) -{ - proc_symlink("mounts", NULL, "self/mounts"); - - /* And now for trickier ones */ -} diff --git a/fs/proc/root.c b/fs/proc/root.c index 2a3abd25b30b..7761602af9de 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -117,7 +117,7 @@ void __init proc_root_init(void) return; } - proc_misc_init(); + proc_symlink("mounts", NULL, "self/mounts"); proc_net_init(); diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 9d8308905053..b8bdb96eff78 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -100,7 +100,6 @@ struct vmcore { extern spinlock_t proc_subdir_lock; extern void proc_root_init(void); -extern void proc_misc_init(void); void proc_flush_task(struct task_struct *task); struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *); -- cgit v1.2.3