proc_misc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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. #include <linux/types.h>
  18. #include <linux/errno.h>
  19. #include <linux/time.h>
  20. #include <linux/kernel.h>
  21. #include <linux/kernel_stat.h>
  22. #include <linux/fs.h>
  23. #include <linux/tty.h>
  24. #include <linux/string.h>
  25. #include <linux/mman.h>
  26. #include <linux/quicklist.h>
  27. #include <linux/proc_fs.h>
  28. #include <linux/ioport.h>
  29. #include <linux/mm.h>
  30. #include <linux/mmzone.h>
  31. #include <linux/pagemap.h>
  32. #include <linux/irq.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/swap.h>
  35. #include <linux/slab.h>
  36. #include <linux/genhd.h>
  37. #include <linux/smp.h>
  38. #include <linux/signal.h>
  39. #include <linux/module.h>
  40. #include <linux/init.h>
  41. #include <linux/seq_file.h>
  42. #include <linux/times.h>
  43. #include <linux/profile.h>
  44. #include <linux/utsname.h>
  45. #include <linux/blkdev.h>
  46. #include <linux/hugetlb.h>
  47. #include <linux/jiffies.h>
  48. #include <linux/vmalloc.h>
  49. #include <linux/crash_dump.h>
  50. #include <linux/pid_namespace.h>
  51. #include <linux/bootmem.h>
  52. #include <asm/uaccess.h>
  53. #include <asm/pgtable.h>
  54. #include <asm/io.h>
  55. #include <asm/tlb.h>
  56. #include <asm/div64.h>
  57. #include "internal.h"
  58. /*
  59. * Warning: stuff below (imported functions) assumes that its output will fit
  60. * into one page. For some of those functions it may be wrong. Moreover, we
  61. * have a way to deal with that gracefully. Right now I used straightforward
  62. * wrappers, but this needs further analysis wrt potential overflows.
  63. */
  64. extern int get_stram_list(char *);
  65. extern int get_exec_domain_list(char *);
  66. static int proc_calc_metrics(char *page, char **start, off_t off,
  67. int count, int *eof, int len)
  68. {
  69. if (len <= off+count) *eof = 1;
  70. *start = page + off;
  71. len -= off;
  72. if (len>count) len = count;
  73. if (len<0) len = 0;
  74. return len;
  75. }
  76. static int fragmentation_open(struct inode *inode, struct file *file)
  77. {
  78. (void)inode;
  79. return seq_open(file, &fragmentation_op);
  80. }
  81. static const struct file_operations fragmentation_file_operations = {
  82. .open = fragmentation_open,
  83. .read = seq_read,
  84. .llseek = seq_lseek,
  85. .release = seq_release,
  86. };
  87. static int pagetypeinfo_open(struct inode *inode, struct file *file)
  88. {
  89. return seq_open(file, &pagetypeinfo_op);
  90. }
  91. static const struct file_operations pagetypeinfo_file_ops = {
  92. .open = pagetypeinfo_open,
  93. .read = seq_read,
  94. .llseek = seq_lseek,
  95. .release = seq_release,
  96. };
  97. static int zoneinfo_open(struct inode *inode, struct file *file)
  98. {
  99. return seq_open(file, &zoneinfo_op);
  100. }
  101. static const struct file_operations proc_zoneinfo_file_operations = {
  102. .open = zoneinfo_open,
  103. .read = seq_read,
  104. .llseek = seq_lseek,
  105. .release = seq_release,
  106. };
  107. extern const struct seq_operations cpuinfo_op;
  108. static int cpuinfo_open(struct inode *inode, struct file *file)
  109. {
  110. return seq_open(file, &cpuinfo_op);
  111. }
  112. static const struct file_operations proc_cpuinfo_operations = {
  113. .open = cpuinfo_open,
  114. .read = seq_read,
  115. .llseek = seq_lseek,
  116. .release = seq_release,
  117. };
  118. static int devinfo_show(struct seq_file *f, void *v)
  119. {
  120. int i = *(loff_t *) v;
  121. if (i < CHRDEV_MAJOR_HASH_SIZE) {
  122. if (i == 0)
  123. seq_printf(f, "Character devices:\n");
  124. chrdev_show(f, i);
  125. }
  126. #ifdef CONFIG_BLOCK
  127. else {
  128. i -= CHRDEV_MAJOR_HASH_SIZE;
  129. if (i == 0)
  130. seq_printf(f, "\nBlock devices:\n");
  131. blkdev_show(f, i);
  132. }
  133. #endif
  134. return 0;
  135. }
  136. static void *devinfo_start(struct seq_file *f, loff_t *pos)
  137. {
  138. if (*pos < (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE))
  139. return pos;
  140. return NULL;
  141. }
  142. static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
  143. {
  144. (*pos)++;
  145. if (*pos >= (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE))
  146. return NULL;
  147. return pos;
  148. }
  149. static void devinfo_stop(struct seq_file *f, void *v)
  150. {
  151. /* Nothing to do */
  152. }
  153. static const struct seq_operations devinfo_ops = {
  154. .start = devinfo_start,
  155. .next = devinfo_next,
  156. .stop = devinfo_stop,
  157. .show = devinfo_show
  158. };
  159. static int devinfo_open(struct inode *inode, struct file *filp)
  160. {
  161. return seq_open(filp, &devinfo_ops);
  162. }
  163. static const struct file_operations proc_devinfo_operations = {
  164. .open = devinfo_open,
  165. .read = seq_read,
  166. .llseek = seq_lseek,
  167. .release = seq_release,
  168. };
  169. static int vmstat_open(struct inode *inode, struct file *file)
  170. {
  171. return seq_open(file, &vmstat_op);
  172. }
  173. static const struct file_operations proc_vmstat_file_operations = {
  174. .open = vmstat_open,
  175. .read = seq_read,
  176. .llseek = seq_lseek,
  177. .release = seq_release,
  178. };
  179. #ifdef CONFIG_STRAM_PROC
  180. static int stram_read_proc(char *page, char **start, off_t off,
  181. int count, int *eof, void *data)
  182. {
  183. int len = get_stram_list(page);
  184. return proc_calc_metrics(page, start, off, count, eof, len);
  185. }
  186. #endif
  187. #ifdef CONFIG_BLOCK
  188. static int partitions_open(struct inode *inode, struct file *file)
  189. {
  190. return seq_open(file, &partitions_op);
  191. }
  192. static const struct file_operations proc_partitions_operations = {
  193. .open = partitions_open,
  194. .read = seq_read,
  195. .llseek = seq_lseek,
  196. .release = seq_release,
  197. };
  198. static int diskstats_open(struct inode *inode, struct file *file)
  199. {
  200. return seq_open(file, &diskstats_op);
  201. }
  202. static const struct file_operations proc_diskstats_operations = {
  203. .open = diskstats_open,
  204. .read = seq_read,
  205. .llseek = seq_lseek,
  206. .release = seq_release,
  207. };
  208. #endif
  209. #ifdef CONFIG_MODULES
  210. extern const struct seq_operations modules_op;
  211. static int modules_open(struct inode *inode, struct file *file)
  212. {
  213. return seq_open(file, &modules_op);
  214. }
  215. static const struct file_operations proc_modules_operations = {
  216. .open = modules_open,
  217. .read = seq_read,
  218. .llseek = seq_lseek,
  219. .release = seq_release,
  220. };
  221. #endif
  222. #ifdef CONFIG_SLABINFO
  223. static int slabinfo_open(struct inode *inode, struct file *file)
  224. {
  225. return seq_open(file, &slabinfo_op);
  226. }
  227. static const struct file_operations proc_slabinfo_operations = {
  228. .open = slabinfo_open,
  229. .read = seq_read,
  230. .write = slabinfo_write,
  231. .llseek = seq_lseek,
  232. .release = seq_release,
  233. };
  234. #ifdef CONFIG_DEBUG_SLAB_LEAK
  235. extern const struct seq_operations slabstats_op;
  236. static int slabstats_open(struct inode *inode, struct file *file)
  237. {
  238. unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
  239. int ret = -ENOMEM;
  240. if (n) {
  241. ret = seq_open(file, &slabstats_op);
  242. if (!ret) {
  243. struct seq_file *m = file->private_data;
  244. *n = PAGE_SIZE / (2 * sizeof(unsigned long));
  245. m->private = n;
  246. n = NULL;
  247. }
  248. kfree(n);
  249. }
  250. return ret;
  251. }
  252. static const struct file_operations proc_slabstats_operations = {
  253. .open = slabstats_open,
  254. .read = seq_read,
  255. .llseek = seq_lseek,
  256. .release = seq_release_private,
  257. };
  258. #endif
  259. #endif
  260. #ifdef CONFIG_MMU
  261. static int vmalloc_open(struct inode *inode, struct file *file)
  262. {
  263. unsigned int *ptr = NULL;
  264. int ret;
  265. if (NUMA_BUILD)
  266. ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
  267. ret = seq_open(file, &vmalloc_op);
  268. if (!ret) {
  269. struct seq_file *m = file->private_data;
  270. m->private = ptr;
  271. } else
  272. kfree(ptr);
  273. return ret;
  274. }
  275. static const struct file_operations proc_vmalloc_operations = {
  276. .open = vmalloc_open,
  277. .read = seq_read,
  278. .llseek = seq_lseek,
  279. .release = seq_release_private,
  280. };
  281. #endif
  282. #ifndef arch_irq_stat_cpu
  283. #define arch_irq_stat_cpu(cpu) 0
  284. #endif
  285. #ifndef arch_irq_stat
  286. #define arch_irq_stat() 0
  287. #endif
  288. static int show_stat(struct seq_file *p, void *v)
  289. {
  290. int i, j;
  291. unsigned long jif;
  292. cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
  293. cputime64_t guest;
  294. u64 sum = 0;
  295. struct timespec boottime;
  296. unsigned int per_irq_sum;
  297. user = nice = system = idle = iowait =
  298. irq = softirq = steal = cputime64_zero;
  299. guest = cputime64_zero;
  300. getboottime(&boottime);
  301. jif = boottime.tv_sec;
  302. for_each_possible_cpu(i) {
  303. user = cputime64_add(user, kstat_cpu(i).cpustat.user);
  304. nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
  305. system = cputime64_add(system, kstat_cpu(i).cpustat.system);
  306. idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle);
  307. iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait);
  308. irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
  309. softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
  310. steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
  311. guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
  312. for_each_irq_nr(j)
  313. sum += kstat_irqs_cpu(j, i);
  314. sum += arch_irq_stat_cpu(i);
  315. }
  316. sum += arch_irq_stat();
  317. seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
  318. (unsigned long long)cputime64_to_clock_t(user),
  319. (unsigned long long)cputime64_to_clock_t(nice),
  320. (unsigned long long)cputime64_to_clock_t(system),
  321. (unsigned long long)cputime64_to_clock_t(idle),
  322. (unsigned long long)cputime64_to_clock_t(iowait),
  323. (unsigned long long)cputime64_to_clock_t(irq),
  324. (unsigned long long)cputime64_to_clock_t(softirq),
  325. (unsigned long long)cputime64_to_clock_t(steal),
  326. (unsigned long long)cputime64_to_clock_t(guest));
  327. for_each_online_cpu(i) {
  328. /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
  329. user = kstat_cpu(i).cpustat.user;
  330. nice = kstat_cpu(i).cpustat.nice;
  331. system = kstat_cpu(i).cpustat.system;
  332. idle = kstat_cpu(i).cpustat.idle;
  333. iowait = kstat_cpu(i).cpustat.iowait;
  334. irq = kstat_cpu(i).cpustat.irq;
  335. softirq = kstat_cpu(i).cpustat.softirq;
  336. steal = kstat_cpu(i).cpustat.steal;
  337. guest = kstat_cpu(i).cpustat.guest;
  338. seq_printf(p,
  339. "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
  340. i,
  341. (unsigned long long)cputime64_to_clock_t(user),
  342. (unsigned long long)cputime64_to_clock_t(nice),
  343. (unsigned long long)cputime64_to_clock_t(system),
  344. (unsigned long long)cputime64_to_clock_t(idle),
  345. (unsigned long long)cputime64_to_clock_t(iowait),
  346. (unsigned long long)cputime64_to_clock_t(irq),
  347. (unsigned long long)cputime64_to_clock_t(softirq),
  348. (unsigned long long)cputime64_to_clock_t(steal),
  349. (unsigned long long)cputime64_to_clock_t(guest));
  350. }
  351. seq_printf(p, "intr %llu", (unsigned long long)sum);
  352. /* sum again ? it could be updated? */
  353. for_each_irq_nr(j) {
  354. per_irq_sum = 0;
  355. for_each_possible_cpu(i)
  356. per_irq_sum += kstat_irqs_cpu(j, i);
  357. seq_printf(p, " %u", per_irq_sum);
  358. }
  359. seq_printf(p,
  360. "\nctxt %llu\n"
  361. "btime %lu\n"
  362. "processes %lu\n"
  363. "procs_running %lu\n"
  364. "procs_blocked %lu\n",
  365. nr_context_switches(),
  366. (unsigned long)jif,
  367. total_forks,
  368. nr_running(),
  369. nr_iowait());
  370. return 0;
  371. }
  372. static int stat_open(struct inode *inode, struct file *file)
  373. {
  374. unsigned size = 4096 * (1 + num_possible_cpus() / 32);
  375. char *buf;
  376. struct seq_file *m;
  377. int res;
  378. /* don't ask for more than the kmalloc() max size, currently 128 KB */
  379. if (size > 128 * 1024)
  380. size = 128 * 1024;
  381. buf = kmalloc(size, GFP_KERNEL);
  382. if (!buf)
  383. return -ENOMEM;
  384. res = single_open(file, show_stat, NULL);
  385. if (!res) {
  386. m = file->private_data;
  387. m->buf = buf;
  388. m->size = size;
  389. } else
  390. kfree(buf);
  391. return res;
  392. }
  393. static const struct file_operations proc_stat_operations = {
  394. .open = stat_open,
  395. .read = seq_read,
  396. .llseek = seq_lseek,
  397. .release = single_release,
  398. };
  399. /*
  400. * /proc/interrupts
  401. */
  402. static void *int_seq_start(struct seq_file *f, loff_t *pos)
  403. {
  404. return (*pos <= nr_irqs) ? pos : NULL;
  405. }
  406. static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
  407. {
  408. (*pos)++;
  409. return (*pos <= nr_irqs) ? pos : NULL;
  410. }
  411. static void int_seq_stop(struct seq_file *f, void *v)
  412. {
  413. /* Nothing to do */
  414. }
  415. static const struct seq_operations int_seq_ops = {
  416. .start = int_seq_start,
  417. .next = int_seq_next,
  418. .stop = int_seq_stop,
  419. .show = show_interrupts
  420. };
  421. static int interrupts_open(struct inode *inode, struct file *filp)
  422. {
  423. return seq_open(filp, &int_seq_ops);
  424. }
  425. static const struct file_operations proc_interrupts_operations = {
  426. .open = interrupts_open,
  427. .read = seq_read,
  428. .llseek = seq_lseek,
  429. .release = seq_release,
  430. };
  431. static int filesystems_read_proc(char *page, char **start, off_t off,
  432. int count, int *eof, void *data)
  433. {
  434. int len = get_filesystem_list(page);
  435. return proc_calc_metrics(page, start, off, count, eof, len);
  436. }
  437. static int cmdline_read_proc(char *page, char **start, off_t off,
  438. int count, int *eof, void *data)
  439. {
  440. int len;
  441. len = sprintf(page, "%s\n", saved_command_line);
  442. return proc_calc_metrics(page, start, off, count, eof, len);
  443. }
  444. #ifdef CONFIG_FILE_LOCKING
  445. static int locks_open(struct inode *inode, struct file *filp)
  446. {
  447. return seq_open(filp, &locks_seq_operations);
  448. }
  449. static const struct file_operations proc_locks_operations = {
  450. .open = locks_open,
  451. .read = seq_read,
  452. .llseek = seq_lseek,
  453. .release = seq_release,
  454. };
  455. #endif /* CONFIG_FILE_LOCKING */
  456. static int execdomains_read_proc(char *page, char **start, off_t off,
  457. int count, int *eof, void *data)
  458. {
  459. int len = get_exec_domain_list(page);
  460. return proc_calc_metrics(page, start, off, count, eof, len);
  461. }
  462. #ifdef CONFIG_PROC_PAGE_MONITOR
  463. #define KPMSIZE sizeof(u64)
  464. #define KPMMASK (KPMSIZE - 1)
  465. /* /proc/kpagecount - an array exposing page counts
  466. *
  467. * Each entry is a u64 representing the corresponding
  468. * physical page count.
  469. */
  470. static ssize_t kpagecount_read(struct file *file, char __user *buf,
  471. size_t count, loff_t *ppos)
  472. {
  473. u64 __user *out = (u64 __user *)buf;
  474. struct page *ppage;
  475. unsigned long src = *ppos;
  476. unsigned long pfn;
  477. ssize_t ret = 0;
  478. u64 pcount;
  479. pfn = src / KPMSIZE;
  480. count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
  481. if (src & KPMMASK || count & KPMMASK)
  482. return -EINVAL;
  483. while (count > 0) {
  484. ppage = NULL;
  485. if (pfn_valid(pfn))
  486. ppage = pfn_to_page(pfn);
  487. pfn++;
  488. if (!ppage)
  489. pcount = 0;
  490. else
  491. pcount = page_mapcount(ppage);
  492. if (put_user(pcount, out++)) {
  493. ret = -EFAULT;
  494. break;
  495. }
  496. count -= KPMSIZE;
  497. }
  498. *ppos += (char __user *)out - buf;
  499. if (!ret)
  500. ret = (char __user *)out - buf;
  501. return ret;
  502. }
  503. static struct file_operations proc_kpagecount_operations = {
  504. .llseek = mem_lseek,
  505. .read = kpagecount_read,
  506. };
  507. /* /proc/kpageflags - an array exposing page flags
  508. *
  509. * Each entry is a u64 representing the corresponding
  510. * physical page flags.
  511. */
  512. /* These macros are used to decouple internal flags from exported ones */
  513. #define KPF_LOCKED 0
  514. #define KPF_ERROR 1
  515. #define KPF_REFERENCED 2
  516. #define KPF_UPTODATE 3
  517. #define KPF_DIRTY 4
  518. #define KPF_LRU 5
  519. #define KPF_ACTIVE 6
  520. #define KPF_SLAB 7
  521. #define KPF_WRITEBACK 8
  522. #define KPF_RECLAIM 9
  523. #define KPF_BUDDY 10
  524. #define kpf_copy_bit(flags, srcpos, dstpos) (((flags >> srcpos) & 1) << dstpos)
  525. static ssize_t kpageflags_read(struct file *file, char __user *buf,
  526. size_t count, loff_t *ppos)
  527. {
  528. u64 __user *out = (u64 __user *)buf;
  529. struct page *ppage;
  530. unsigned long src = *ppos;
  531. unsigned long pfn;
  532. ssize_t ret = 0;
  533. u64 kflags, uflags;
  534. pfn = src / KPMSIZE;
  535. count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
  536. if (src & KPMMASK || count & KPMMASK)
  537. return -EINVAL;
  538. while (count > 0) {
  539. ppage = NULL;
  540. if (pfn_valid(pfn))
  541. ppage = pfn_to_page(pfn);
  542. pfn++;
  543. if (!ppage)
  544. kflags = 0;
  545. else
  546. kflags = ppage->flags;
  547. uflags = kpf_copy_bit(KPF_LOCKED, PG_locked, kflags) |
  548. kpf_copy_bit(kflags, KPF_ERROR, PG_error) |
  549. kpf_copy_bit(kflags, KPF_REFERENCED, PG_referenced) |
  550. kpf_copy_bit(kflags, KPF_UPTODATE, PG_uptodate) |
  551. kpf_copy_bit(kflags, KPF_DIRTY, PG_dirty) |
  552. kpf_copy_bit(kflags, KPF_LRU, PG_lru) |
  553. kpf_copy_bit(kflags, KPF_ACTIVE, PG_active) |
  554. kpf_copy_bit(kflags, KPF_SLAB, PG_slab) |
  555. kpf_copy_bit(kflags, KPF_WRITEBACK, PG_writeback) |
  556. kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) |
  557. kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy);
  558. if (put_user(uflags, out++)) {
  559. ret = -EFAULT;
  560. break;
  561. }
  562. count -= KPMSIZE;
  563. }
  564. *ppos += (char __user *)out - buf;
  565. if (!ret)
  566. ret = (char __user *)out - buf;
  567. return ret;
  568. }
  569. static struct file_operations proc_kpageflags_operations = {
  570. .llseek = mem_lseek,
  571. .read = kpageflags_read,
  572. };
  573. #endif /* CONFIG_PROC_PAGE_MONITOR */
  574. struct proc_dir_entry *proc_root_kcore;
  575. void __init proc_misc_init(void)
  576. {
  577. static struct {
  578. char *name;
  579. int (*read_proc)(char*,char**,off_t,int,int*,void*);
  580. } *p, simple_ones[] = {
  581. #ifdef CONFIG_STRAM_PROC
  582. {"stram", stram_read_proc},
  583. #endif
  584. {"filesystems", filesystems_read_proc},
  585. {"cmdline", cmdline_read_proc},
  586. {"execdomains", execdomains_read_proc},
  587. {NULL,}
  588. };
  589. for (p = simple_ones; p->name; p++)
  590. create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL);
  591. proc_symlink("mounts", NULL, "self/mounts");
  592. /* And now for trickier ones */
  593. #ifdef CONFIG_PRINTK
  594. proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
  595. #endif
  596. #ifdef CONFIG_FILE_LOCKING
  597. proc_create("locks", 0, NULL, &proc_locks_operations);
  598. #endif
  599. proc_create("devices", 0, NULL, &proc_devinfo_operations);
  600. proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
  601. #ifdef CONFIG_BLOCK
  602. proc_create("partitions", 0, NULL, &proc_partitions_operations);
  603. #endif
  604. proc_create("stat", 0, NULL, &proc_stat_operations);
  605. proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
  606. #ifdef CONFIG_SLABINFO
  607. proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
  608. #ifdef CONFIG_DEBUG_SLAB_LEAK
  609. proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
  610. #endif
  611. #endif
  612. #ifdef CONFIG_MMU
  613. proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
  614. #endif
  615. proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
  616. proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
  617. proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
  618. proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
  619. #ifdef CONFIG_BLOCK
  620. proc_create("diskstats", 0, NULL, &proc_diskstats_operations);
  621. #endif
  622. #ifdef CONFIG_MODULES
  623. proc_create("modules", 0, NULL, &proc_modules_operations);
  624. #endif
  625. #ifdef CONFIG_SCHEDSTATS
  626. proc_create("schedstat", 0, NULL, &proc_schedstat_operations);
  627. #endif
  628. #ifdef CONFIG_PROC_KCORE
  629. proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations);
  630. if (proc_root_kcore)
  631. proc_root_kcore->size =
  632. (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE;
  633. #endif
  634. #ifdef CONFIG_PROC_PAGE_MONITOR
  635. proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations);
  636. proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations);
  637. #endif
  638. #ifdef CONFIG_PROC_VMCORE
  639. proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations);
  640. #endif
  641. }