[lc-checkins] CVS: linux/fs/proc proc_misc.c,1.8,1.9
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2003-05-19 01:39:20
|
Update of /cvsroot/linuxcompressed/linux/fs/proc
In directory sc8-pr-cvs1:/tmp/cvs-serv25395/fs/proc
Modified Files:
proc_misc.c
Log Message:
o Port code to 2.4.20
Bug fix (?)
o Changes checks in vswap.c to avoid oopses. It will BUG()
instead. Some of the checks were done after the value had been
accessed.
Note
o Virtual swap addresses are temporarily disabled, due to debugging
sessions related to the use of swap files instead of swap partitions.
Index: proc_misc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/fs/proc/proc_misc.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** proc_misc.c 10 Sep 2002 16:43:00 -0000 1.8
--- proc_misc.c 19 May 2003 01:38:46 -0000 1.9
***************
*** 43,47 ****
#include <asm/io.h>
-
#define LOAD_INT(x) ((x) >> FSHIFT)
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
--- 43,46 ----
***************
*** 52,60 ****
* wrappers, but this needs further analysis wrt potential overflows.
*/
#ifdef CONFIG_MODULES
extern int get_module_list(char *);
#endif
extern int get_device_list(char *);
- extern int get_partition_list(char *, char **, off_t, int);
extern int get_filesystem_list(char *);
extern int get_exec_domain_list(char *);
--- 51,60 ----
* wrappers, but this needs further analysis wrt potential overflows.
*/
+ extern int get_hardware_list(char *);
+ extern int get_stram_list(char *);
#ifdef CONFIG_MODULES
extern int get_module_list(char *);
#endif
extern int get_device_list(char *);
extern int get_filesystem_list(char *);
extern int get_exec_domain_list(char *);
***************
*** 67,70 ****
--- 67,91 ----
#endif
+ void proc_sprintf(char *page, off_t *off, int *lenp, const char *format, ...)
+ {
+ int len = *lenp;
+ va_list args;
+
+ /* try to only print whole lines */
+ if (len > PAGE_SIZE-512)
+ return;
+
+ va_start(args, format);
+ len += vsnprintf(page + len, PAGE_SIZE-len, format, args);
+ va_end(args);
+
+ if (len <= *off) {
+ *off -= len;
+ len = 0;
+ }
+
+ *lenp = len;
+ }
+
static int proc_calc_metrics(char *page, char **start, off_t off,
int count, int *eof, int len)
***************
*** 227,230 ****
--- 248,281 ----
};
+ #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)
+ {
+ int len = get_stram_list(page);
+ return proc_calc_metrics(page, start, off, count, eof, len);
+ }
+ #endif
+
+ extern struct seq_operations partitions_op;
+ static int partitions_open(struct inode *inode, struct file *file)
+ {
+ return seq_open(file, &partitions_op);
+ }
+ static struct file_operations proc_partitions_operations = {
+ open: partitions_open,
+ read: seq_read,
+ llseek: seq_lseek,
+ release: seq_release,
+ };
+
#ifdef CONFIG_MODULES
static int modules_read_proc(char *page, char **start, off_t off,
***************
*** 248,255 ****
#endif
static int kstat_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
! int i, len;
extern unsigned long total_forks;
unsigned long jif = jiffies;
--- 299,320 ----
#endif
+ extern struct seq_operations slabinfo_op;
+ extern ssize_t slabinfo_write(struct file *, const char *, size_t, loff_t *);
+ static int slabinfo_open(struct inode *inode, struct file *file)
+ {
+ return seq_open(file, &slabinfo_op);
+ }
+ static struct file_operations proc_slabinfo_operations = {
+ open: slabinfo_open,
+ read: seq_read,
+ write: slabinfo_write,
+ llseek: seq_lseek,
+ release: seq_release,
+ };
+
static int kstat_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
! int i, len = 0;
extern unsigned long total_forks;
unsigned long jif = jiffies;
***************
*** 269,276 ****
}
! len = sprintf(page, "cpu %u %u %u %lu\n", user, nice, system,
jif * smp_num_cpus - (user + nice + system));
for (i = 0 ; i < smp_num_cpus; i++)
! len += sprintf(page + len, "cpu%d %u %u %u %lu\n",
i,
kstat.per_cpu_user[cpu_logical_map(i)],
--- 334,343 ----
}
! proc_sprintf(page, &off, &len,
! "cpu %u %u %u %lu\n", user, nice, system,
jif * smp_num_cpus - (user + nice + system));
for (i = 0 ; i < smp_num_cpus; i++)
! proc_sprintf(page, &off, &len,
! "cpu%d %u %u %u %lu\n",
i,
kstat.per_cpu_user[cpu_logical_map(i)],
***************
*** 280,284 ****
+ kstat.per_cpu_nice[cpu_logical_map(i)] \
+ kstat.per_cpu_system[cpu_logical_map(i)]));
! len += sprintf(page + len,
"page %u %u\n"
"swap %u %u\n"
--- 347,351 ----
+ kstat.per_cpu_nice[cpu_logical_map(i)] \
+ kstat.per_cpu_system[cpu_logical_map(i)]));
! proc_sprintf(page, &off, &len,
"page %u %u\n"
"swap %u %u\n"
***************
*** 292,299 ****
#if !defined(CONFIG_ARCH_S390)
for (i = 0 ; i < NR_IRQS ; i++)
! len += sprintf(page + len, " %u", kstat_irqs(i));
#endif
! len += sprintf(page + len, "\ndisk_io: ");
for (major = 0; major < DK_MAX_MAJOR; major++) {
--- 359,367 ----
#if !defined(CONFIG_ARCH_S390)
for (i = 0 ; i < NR_IRQS ; i++)
! proc_sprintf(page, &off, &len,
! " %u", kstat_irqs(i));
#endif
! proc_sprintf(page, &off, &len, "\ndisk_io: ");
for (major = 0; major < DK_MAX_MAJOR; major++) {
***************
*** 303,307 ****
kstat.dk_drive_wblk[major][disk];
if (active)
! len += sprintf(page + len,
"(%u,%u):(%u,%u,%u,%u,%u) ",
major, disk,
--- 371,375 ----
kstat.dk_drive_wblk[major][disk];
if (active)
! proc_sprintf(page, &off, &len,
"(%u,%u):(%u,%u,%u,%u,%u) ",
major, disk,
***************
*** 315,319 ****
}
! len += sprintf(page + len,
"\nctxt %u\n"
"btime %lu\n"
--- 383,387 ----
}
! proc_sprintf(page, &off, &len,
"\nctxt %u\n"
"btime %lu\n"
***************
*** 333,344 ****
}
- static int partitions_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
- {
- int len = get_partition_list(page, start, off, count);
- if (len < count) *eof = 1;
- return len;
- }
-
#if !defined(CONFIG_ARCH_S390)
static int interrupts_read_proc(char *page, char **start, off_t off,
--- 401,404 ----
***************
*** 377,382 ****
int len;
! len = sprintf(page, "%s\n", saved_command_line);
! len = strlen(page);
return proc_calc_metrics(page, start, off, count, eof, len);
}
--- 437,441 ----
int len;
! len = snprintf(page, count, "%s\n", saved_command_line);
return proc_calc_metrics(page, start, off, count, eof, len);
}
***************
*** 486,501 ****
};
- extern struct seq_operations mounts_op;
- static int mounts_open(struct inode *inode, struct file *file)
- {
- return seq_open(file, &mounts_op);
- }
- static struct file_operations proc_mounts_operations = {
- open: mounts_open,
- read: seq_read,
- llseek: seq_lseek,
- release: seq_release,
- };
-
struct proc_dir_entry *proc_root_kcore;
--- 545,548 ----
***************
*** 519,522 ****
--- 566,575 ----
{"meminfo", meminfo_read_proc},
{"version", version_read_proc},
+ #ifdef CONFIG_PROC_HARDWARE
+ {"hardware", hardware_read_proc},
+ #endif
+ #ifdef CONFIG_STRAM_PROC
+ {"stram", stram_read_proc},
+ #endif
#ifdef CONFIG_MODULES
{"modules", modules_read_proc},
***************
*** 529,533 ****
#endif
{"devices", devices_read_proc},
- {"partitions", partitions_read_proc},
#if !defined(CONFIG_ARCH_S390)
{"interrupts", interrupts_read_proc},
--- 582,585 ----
***************
*** 549,558 ****
create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL);
/* And now for trickier ones */
entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
if (entry)
entry->proc_fops = &proc_kmsg_operations;
- create_seq_entry("mounts", 0, &proc_mounts_operations);
create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
#ifdef CONFIG_MODULES
create_seq_entry("ksyms", 0, &proc_ksyms_operations);
--- 601,613 ----
create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL);
+ proc_symlink("mounts", NULL, "self/mounts");
+
/* And now for trickier ones */
entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
if (entry)
entry->proc_fops = &proc_kmsg_operations;
create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
+ create_seq_entry("partitions", 0, &proc_partitions_operations);
+ create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
#ifdef CONFIG_MODULES
create_seq_entry("ksyms", 0, &proc_ksyms_operations);
***************
*** 579,585 ****
}
#endif
- entry = create_proc_read_entry("slabinfo", S_IWUSR | S_IRUGO, NULL,
- slabinfo_read_proc, NULL);
- if (entry)
- entry->write_proc = slabinfo_write_proc;
}
--- 634,636 ----
|