convert buddyinfo to seq_file()
Subsystems (3)
hch thought this might be a good idea. Basically, it just changes it to seq_file instead of the sprintf into the buffer + proc_calc_metrics. I think there might be some extra buffer overflow safety with seq_file. Most of this code was borrowed/stolen from my lazy_buddy tree.
Against 2.4.19rc2aa1
Cheers,
Bill
fs/proc/proc_misc.c +12 -15
@@ -234,21 +234,20 @@#undef K } -extern int buddyinfo (char *buf,int node_id); - -int buddyinfo_read_proc (char *page,char **start,off_t off, -int count,int *eof,void *data) +extern struct seq_operations fragmentation_op; +static int fragmentation_open (struct inode *inode,struct file *file) { -int node_id; -int len =0 ; - -for (node_id =0 ; node_id < numnodes; node_id++) { - len +=buddyinfo (page+len, node_id); - } - -return proc_calc_metrics (page, start, off, count, eof, len); + (void )inode; +return seq_open (file, &fragmentation_op); } +static struct file_operations fragmentation_file_operations = { + open: fragmentation_open, + read: seq_read, + llseek: seq_lseek, + release: seq_release, +}; +static int version_read_proc (char *page,char **start,off_t off,int count,int *eof,void *data) {
@@ -691,6 +690,7 @@ entry->proc_fops = &proc_kmsg_operations;create_seq_entry ("cpuinfo" ,0 , &proc_cpuinfo_operations);create_seq_entry ("slabinfo" ,S_IWUSR |S_IRUGO ,&proc_slabinfo_operations); +create_seq_entry ("buddyinfo" ,S_IRUGO , &fragmentation_file_operations);#ifdef CONFIG_MODULES create_seq_entry ("ksyms" ,0 , &proc_ksyms_operations);#endif
@@ -715,7 +715,4 @@ entry->proc_fops = &ppc_htab_operations; }#endif - -create_proc_read_entry ("buddyinfo" ,S_IWUSR |S_IRUGO ,NULL , - buddyinfo_read_proc,NULL ); }
mm/page_alloc.c +55 -22
92 lines not on this page · raw message