proc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. /* /proc interface for AFS
  2. *
  3. * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/slab.h>
  12. #include <linux/module.h>
  13. #include <linux/proc_fs.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/sched.h>
  16. #include <asm/uaccess.h>
  17. #include "internal.h"
  18. static struct proc_dir_entry *proc_afs;
  19. static int afs_proc_cells_open(struct inode *inode, struct file *file);
  20. static void *afs_proc_cells_start(struct seq_file *p, loff_t *pos);
  21. static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos);
  22. static void afs_proc_cells_stop(struct seq_file *p, void *v);
  23. static int afs_proc_cells_show(struct seq_file *m, void *v);
  24. static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
  25. size_t size, loff_t *_pos);
  26. static const struct seq_operations afs_proc_cells_ops = {
  27. .start = afs_proc_cells_start,
  28. .next = afs_proc_cells_next,
  29. .stop = afs_proc_cells_stop,
  30. .show = afs_proc_cells_show,
  31. };
  32. static const struct file_operations afs_proc_cells_fops = {
  33. .open = afs_proc_cells_open,
  34. .read = seq_read,
  35. .write = afs_proc_cells_write,
  36. .llseek = seq_lseek,
  37. .release = seq_release,
  38. .owner = THIS_MODULE,
  39. };
  40. static int afs_proc_rootcell_open(struct inode *inode, struct file *file);
  41. static int afs_proc_rootcell_release(struct inode *inode, struct file *file);
  42. static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
  43. size_t size, loff_t *_pos);
  44. static ssize_t afs_proc_rootcell_write(struct file *file,
  45. const char __user *buf,
  46. size_t size, loff_t *_pos);
  47. static const struct file_operations afs_proc_rootcell_fops = {
  48. .open = afs_proc_rootcell_open,
  49. .read = afs_proc_rootcell_read,
  50. .write = afs_proc_rootcell_write,
  51. .llseek = no_llseek,
  52. .release = afs_proc_rootcell_release,
  53. .owner = THIS_MODULE,
  54. };
  55. static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file);
  56. static int afs_proc_cell_volumes_release(struct inode *inode,
  57. struct file *file);
  58. static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);
  59. static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
  60. loff_t *pos);
  61. static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v);
  62. static int afs_proc_cell_volumes_show(struct seq_file *m, void *v);
  63. static const struct seq_operations afs_proc_cell_volumes_ops = {
  64. .start = afs_proc_cell_volumes_start,
  65. .next = afs_proc_cell_volumes_next,
  66. .stop = afs_proc_cell_volumes_stop,
  67. .show = afs_proc_cell_volumes_show,
  68. };
  69. static const struct file_operations afs_proc_cell_volumes_fops = {
  70. .open = afs_proc_cell_volumes_open,
  71. .read = seq_read,
  72. .llseek = seq_lseek,
  73. .release = afs_proc_cell_volumes_release,
  74. .owner = THIS_MODULE,
  75. };
  76. static int afs_proc_cell_vlservers_open(struct inode *inode,
  77. struct file *file);
  78. static int afs_proc_cell_vlservers_release(struct inode *inode,
  79. struct file *file);
  80. static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);
  81. static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
  82. loff_t *pos);
  83. static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v);
  84. static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v);
  85. static const struct seq_operations afs_proc_cell_vlservers_ops = {
  86. .start = afs_proc_cell_vlservers_start,
  87. .next = afs_proc_cell_vlservers_next,
  88. .stop = afs_proc_cell_vlservers_stop,
  89. .show = afs_proc_cell_vlservers_show,
  90. };
  91. static const struct file_operations afs_proc_cell_vlservers_fops = {
  92. .open = afs_proc_cell_vlservers_open,
  93. .read = seq_read,
  94. .llseek = seq_lseek,
  95. .release = afs_proc_cell_vlservers_release,
  96. .owner = THIS_MODULE,
  97. };
  98. static int afs_proc_cell_servers_open(struct inode *inode, struct file *file);
  99. static int afs_proc_cell_servers_release(struct inode *inode,
  100. struct file *file);
  101. static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos);
  102. static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
  103. loff_t *pos);
  104. static void afs_proc_cell_servers_stop(struct seq_file *p, void *v);
  105. static int afs_proc_cell_servers_show(struct seq_file *m, void *v);
  106. static const struct seq_operations afs_proc_cell_servers_ops = {
  107. .start = afs_proc_cell_servers_start,
  108. .next = afs_proc_cell_servers_next,
  109. .stop = afs_proc_cell_servers_stop,
  110. .show = afs_proc_cell_servers_show,
  111. };
  112. static const struct file_operations afs_proc_cell_servers_fops = {
  113. .open = afs_proc_cell_servers_open,
  114. .read = seq_read,
  115. .llseek = seq_lseek,
  116. .release = afs_proc_cell_servers_release,
  117. .owner = THIS_MODULE,
  118. };
  119. /*
  120. * initialise the /proc/fs/afs/ directory
  121. */
  122. int afs_proc_init(void)
  123. {
  124. struct proc_dir_entry *p;
  125. _enter("");
  126. proc_afs = proc_mkdir("fs/afs", NULL);
  127. if (!proc_afs)
  128. goto error_dir;
  129. p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
  130. if (!p)
  131. goto error_cells;
  132. p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
  133. if (!p)
  134. goto error_rootcell;
  135. _leave(" = 0");
  136. return 0;
  137. error_rootcell:
  138. remove_proc_entry("cells", proc_afs);
  139. error_cells:
  140. remove_proc_entry("fs/afs", NULL);
  141. error_dir:
  142. _leave(" = -ENOMEM");
  143. return -ENOMEM;
  144. }
  145. /*
  146. * clean up the /proc/fs/afs/ directory
  147. */
  148. void afs_proc_cleanup(void)
  149. {
  150. remove_proc_entry("rootcell", proc_afs);
  151. remove_proc_entry("cells", proc_afs);
  152. remove_proc_entry("fs/afs", NULL);
  153. }
  154. /*
  155. * open "/proc/fs/afs/cells" which provides a summary of extant cells
  156. */
  157. static int afs_proc_cells_open(struct inode *inode, struct file *file)
  158. {
  159. struct seq_file *m;
  160. int ret;
  161. ret = seq_open(file, &afs_proc_cells_ops);
  162. if (ret < 0)
  163. return ret;
  164. m = file->private_data;
  165. m->private = PDE(inode)->data;
  166. return 0;
  167. }
  168. /*
  169. * set up the iterator to start reading from the cells list and return the
  170. * first item
  171. */
  172. static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
  173. {
  174. /* lock the list against modification */
  175. down_read(&afs_proc_cells_sem);
  176. return seq_list_start_head(&afs_proc_cells, *_pos);
  177. }
  178. /*
  179. * move to next cell in cells list
  180. */
  181. static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos)
  182. {
  183. return seq_list_next(v, &afs_proc_cells, pos);
  184. }
  185. /*
  186. * clean up after reading from the cells list
  187. */
  188. static void afs_proc_cells_stop(struct seq_file *p, void *v)
  189. {
  190. up_read(&afs_proc_cells_sem);
  191. }
  192. /*
  193. * display a header line followed by a load of cell lines
  194. */
  195. static int afs_proc_cells_show(struct seq_file *m, void *v)
  196. {
  197. struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link);
  198. if (v == &afs_proc_cells) {
  199. /* display header on line 1 */
  200. seq_puts(m, "USE NAME\n");
  201. return 0;
  202. }
  203. /* display one cell per line on subsequent lines */
  204. seq_printf(m, "%3d %s\n",
  205. atomic_read(&cell->usage), cell->name);
  206. return 0;
  207. }
  208. /*
  209. * handle writes to /proc/fs/afs/cells
  210. * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]"
  211. */
  212. static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
  213. size_t size, loff_t *_pos)
  214. {
  215. char *kbuf, *name, *args;
  216. int ret;
  217. /* start by dragging the command into memory */
  218. if (size <= 1 || size >= PAGE_SIZE)
  219. return -EINVAL;
  220. kbuf = kmalloc(size + 1, GFP_KERNEL);
  221. if (!kbuf)
  222. return -ENOMEM;
  223. ret = -EFAULT;
  224. if (copy_from_user(kbuf, buf, size) != 0)
  225. goto done;
  226. kbuf[size] = 0;
  227. /* trim to first NL */
  228. name = memchr(kbuf, '\n', size);
  229. if (name)
  230. *name = 0;
  231. /* split into command, name and argslist */
  232. name = strchr(kbuf, ' ');
  233. if (!name)
  234. goto inval;
  235. do {
  236. *name++ = 0;
  237. } while(*name == ' ');
  238. if (!*name)
  239. goto inval;
  240. args = strchr(name, ' ');
  241. if (!args)
  242. goto inval;
  243. do {
  244. *args++ = 0;
  245. } while(*args == ' ');
  246. if (!*args)
  247. goto inval;
  248. /* determine command to perform */
  249. _debug("cmd=%s name=%s args=%s", kbuf, name, args);
  250. if (strcmp(kbuf, "add") == 0) {
  251. struct afs_cell *cell;
  252. cell = afs_cell_create(name, strlen(name), args, false);
  253. if (IS_ERR(cell)) {
  254. ret = PTR_ERR(cell);
  255. goto done;
  256. }
  257. afs_put_cell(cell);
  258. printk("kAFS: Added new cell '%s'\n", name);
  259. } else {
  260. goto inval;
  261. }
  262. ret = size;
  263. done:
  264. kfree(kbuf);
  265. _leave(" = %d", ret);
  266. return ret;
  267. inval:
  268. ret = -EINVAL;
  269. printk("kAFS: Invalid Command on /proc/fs/afs/cells file\n");
  270. goto done;
  271. }
  272. /*
  273. * Stubs for /proc/fs/afs/rootcell
  274. */
  275. static int afs_proc_rootcell_open(struct inode *inode, struct file *file)
  276. {
  277. return 0;
  278. }
  279. static int afs_proc_rootcell_release(struct inode *inode, struct file *file)
  280. {
  281. return 0;
  282. }
  283. static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
  284. size_t size, loff_t *_pos)
  285. {
  286. return 0;
  287. }
  288. /*
  289. * handle writes to /proc/fs/afs/rootcell
  290. * - to initialize rootcell: echo "cell.name:192.168.231.14"
  291. */
  292. static ssize_t afs_proc_rootcell_write(struct file *file,
  293. const char __user *buf,
  294. size_t size, loff_t *_pos)
  295. {
  296. char *kbuf, *s;
  297. int ret;
  298. /* start by dragging the command into memory */
  299. if (size <= 1 || size >= PAGE_SIZE)
  300. return -EINVAL;
  301. ret = -ENOMEM;
  302. kbuf = kmalloc(size + 1, GFP_KERNEL);
  303. if (!kbuf)
  304. goto nomem;
  305. ret = -EFAULT;
  306. if (copy_from_user(kbuf, buf, size) != 0)
  307. goto infault;
  308. kbuf[size] = 0;
  309. /* trim to first NL */
  310. s = memchr(kbuf, '\n', size);
  311. if (s)
  312. *s = 0;
  313. /* determine command to perform */
  314. _debug("rootcell=%s", kbuf);
  315. ret = afs_cell_init(kbuf);
  316. if (ret >= 0)
  317. ret = size; /* consume everything, always */
  318. infault:
  319. kfree(kbuf);
  320. nomem:
  321. _leave(" = %d", ret);
  322. return ret;
  323. }
  324. /*
  325. * initialise /proc/fs/afs/<cell>/
  326. */
  327. int afs_proc_cell_setup(struct afs_cell *cell)
  328. {
  329. struct proc_dir_entry *p;
  330. _enter("%p{%s}", cell, cell->name);
  331. cell->proc_dir = proc_mkdir(cell->name, proc_afs);
  332. if (!cell->proc_dir)
  333. goto error_dir;
  334. p = proc_create_data("servers", 0, cell->proc_dir,
  335. &afs_proc_cell_servers_fops, cell);
  336. if (!p)
  337. goto error_servers;
  338. p = proc_create_data("vlservers", 0, cell->proc_dir,
  339. &afs_proc_cell_vlservers_fops, cell);
  340. if (!p)
  341. goto error_vlservers;
  342. p = proc_create_data("volumes", 0, cell->proc_dir,
  343. &afs_proc_cell_volumes_fops, cell);
  344. if (!p)
  345. goto error_volumes;
  346. _leave(" = 0");
  347. return 0;
  348. error_volumes:
  349. remove_proc_entry("vlservers", cell->proc_dir);
  350. error_vlservers:
  351. remove_proc_entry("servers", cell->proc_dir);
  352. error_servers:
  353. remove_proc_entry(cell->name, proc_afs);
  354. error_dir:
  355. _leave(" = -ENOMEM");
  356. return -ENOMEM;
  357. }
  358. /*
  359. * remove /proc/fs/afs/<cell>/
  360. */
  361. void afs_proc_cell_remove(struct afs_cell *cell)
  362. {
  363. _enter("");
  364. remove_proc_entry("volumes", cell->proc_dir);
  365. remove_proc_entry("vlservers", cell->proc_dir);
  366. remove_proc_entry("servers", cell->proc_dir);
  367. remove_proc_entry(cell->name, proc_afs);
  368. _leave("");
  369. }
  370. /*
  371. * open "/proc/fs/afs/<cell>/volumes" which provides a summary of extant cells
  372. */
  373. static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file)
  374. {
  375. struct afs_cell *cell;
  376. struct seq_file *m;
  377. int ret;
  378. cell = PDE(inode)->data;
  379. if (!cell)
  380. return -ENOENT;
  381. ret = seq_open(file, &afs_proc_cell_volumes_ops);
  382. if (ret < 0)
  383. return ret;
  384. m = file->private_data;
  385. m->private = cell;
  386. return 0;
  387. }
  388. /*
  389. * close the file and release the ref to the cell
  390. */
  391. static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file)
  392. {
  393. return seq_release(inode, file);
  394. }
  395. /*
  396. * set up the iterator to start reading from the cells list and return the
  397. * first item
  398. */
  399. static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
  400. {
  401. struct afs_cell *cell = m->private;
  402. _enter("cell=%p pos=%Ld", cell, *_pos);
  403. /* lock the list against modification */
  404. down_read(&cell->vl_sem);
  405. return seq_list_start_head(&cell->vl_list, *_pos);
  406. }
  407. /*
  408. * move to next cell in cells list
  409. */
  410. static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
  411. loff_t *_pos)
  412. {
  413. struct afs_cell *cell = p->private;
  414. _enter("cell=%p pos=%Ld", cell, *_pos);
  415. return seq_list_next(v, &cell->vl_list, _pos);
  416. }
  417. /*
  418. * clean up after reading from the cells list
  419. */
  420. static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v)
  421. {
  422. struct afs_cell *cell = p->private;
  423. up_read(&cell->vl_sem);
  424. }
  425. static const char afs_vlocation_states[][4] = {
  426. [AFS_VL_NEW] = "New",
  427. [AFS_VL_CREATING] = "Crt",
  428. [AFS_VL_VALID] = "Val",
  429. [AFS_VL_NO_VOLUME] = "NoV",
  430. [AFS_VL_UPDATING] = "Upd",
  431. [AFS_VL_VOLUME_DELETED] = "Del",
  432. [AFS_VL_UNCERTAIN] = "Unc",
  433. };
  434. /*
  435. * display a header line followed by a load of volume lines
  436. */
  437. static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
  438. {
  439. struct afs_cell *cell = m->private;
  440. struct afs_vlocation *vlocation =
  441. list_entry(v, struct afs_vlocation, link);
  442. /* display header on line 1 */
  443. if (v == &cell->vl_list) {
  444. seq_puts(m, "USE STT VLID[0] VLID[1] VLID[2] NAME\n");
  445. return 0;
  446. }
  447. /* display one cell per line on subsequent lines */
  448. seq_printf(m, "%3d %s %08x %08x %08x %s\n",
  449. atomic_read(&vlocation->usage),
  450. afs_vlocation_states[vlocation->state],
  451. vlocation->vldb.vid[0],
  452. vlocation->vldb.vid[1],
  453. vlocation->vldb.vid[2],
  454. vlocation->vldb.name);
  455. return 0;
  456. }
  457. /*
  458. * open "/proc/fs/afs/<cell>/vlservers" which provides a list of volume
  459. * location server
  460. */
  461. static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file)
  462. {
  463. struct afs_cell *cell;
  464. struct seq_file *m;
  465. int ret;
  466. cell = PDE(inode)->data;
  467. if (!cell)
  468. return -ENOENT;
  469. ret = seq_open(file, &afs_proc_cell_vlservers_ops);
  470. if (ret<0)
  471. return ret;
  472. m = file->private_data;
  473. m->private = cell;
  474. return 0;
  475. }
  476. /*
  477. * close the file and release the ref to the cell
  478. */
  479. static int afs_proc_cell_vlservers_release(struct inode *inode,
  480. struct file *file)
  481. {
  482. return seq_release(inode, file);
  483. }
  484. /*
  485. * set up the iterator to start reading from the cells list and return the
  486. * first item
  487. */
  488. static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos)
  489. {
  490. struct afs_cell *cell = m->private;
  491. loff_t pos = *_pos;
  492. _enter("cell=%p pos=%Ld", cell, *_pos);
  493. /* lock the list against modification */
  494. down_read(&cell->vl_sem);
  495. /* allow for the header line */
  496. if (!pos)
  497. return (void *) 1;
  498. pos--;
  499. if (pos >= cell->vl_naddrs)
  500. return NULL;
  501. return &cell->vl_addrs[pos];
  502. }
  503. /*
  504. * move to next cell in cells list
  505. */
  506. static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
  507. loff_t *_pos)
  508. {
  509. struct afs_cell *cell = p->private;
  510. loff_t pos;
  511. _enter("cell=%p{nad=%u} pos=%Ld", cell, cell->vl_naddrs, *_pos);
  512. pos = *_pos;
  513. (*_pos)++;
  514. if (pos >= cell->vl_naddrs)
  515. return NULL;
  516. return &cell->vl_addrs[pos];
  517. }
  518. /*
  519. * clean up after reading from the cells list
  520. */
  521. static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v)
  522. {
  523. struct afs_cell *cell = p->private;
  524. up_read(&cell->vl_sem);
  525. }
  526. /*
  527. * display a header line followed by a load of volume lines
  528. */
  529. static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
  530. {
  531. struct in_addr *addr = v;
  532. /* display header on line 1 */
  533. if (v == (struct in_addr *) 1) {
  534. seq_puts(m, "ADDRESS\n");
  535. return 0;
  536. }
  537. /* display one cell per line on subsequent lines */
  538. seq_printf(m, "%pI4\n", &addr->s_addr);
  539. return 0;
  540. }
  541. /*
  542. * open "/proc/fs/afs/<cell>/servers" which provides a summary of active
  543. * servers
  544. */
  545. static int afs_proc_cell_servers_open(struct inode *inode, struct file *file)
  546. {
  547. struct afs_cell *cell;
  548. struct seq_file *m;
  549. int ret;
  550. cell = PDE(inode)->data;
  551. if (!cell)
  552. return -ENOENT;
  553. ret = seq_open(file, &afs_proc_cell_servers_ops);
  554. if (ret < 0)
  555. return ret;
  556. m = file->private_data;
  557. m->private = cell;
  558. return 0;
  559. }
  560. /*
  561. * close the file and release the ref to the cell
  562. */
  563. static int afs_proc_cell_servers_release(struct inode *inode,
  564. struct file *file)
  565. {
  566. return seq_release(inode, file);
  567. }
  568. /*
  569. * set up the iterator to start reading from the cells list and return the
  570. * first item
  571. */
  572. static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos)
  573. __acquires(m->private->servers_lock)
  574. {
  575. struct afs_cell *cell = m->private;
  576. _enter("cell=%p pos=%Ld", cell, *_pos);
  577. /* lock the list against modification */
  578. read_lock(&cell->servers_lock);
  579. return seq_list_start_head(&cell->servers, *_pos);
  580. }
  581. /*
  582. * move to next cell in cells list
  583. */
  584. static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
  585. loff_t *_pos)
  586. {
  587. struct afs_cell *cell = p->private;
  588. _enter("cell=%p pos=%Ld", cell, *_pos);
  589. return seq_list_next(v, &cell->servers, _pos);
  590. }
  591. /*
  592. * clean up after reading from the cells list
  593. */
  594. static void afs_proc_cell_servers_stop(struct seq_file *p, void *v)
  595. __releases(p->private->servers_lock)
  596. {
  597. struct afs_cell *cell = p->private;
  598. read_unlock(&cell->servers_lock);
  599. }
  600. /*
  601. * display a header line followed by a load of volume lines
  602. */
  603. static int afs_proc_cell_servers_show(struct seq_file *m, void *v)
  604. {
  605. struct afs_cell *cell = m->private;
  606. struct afs_server *server = list_entry(v, struct afs_server, link);
  607. char ipaddr[20];
  608. /* display header on line 1 */
  609. if (v == &cell->servers) {
  610. seq_puts(m, "USE ADDR STATE\n");
  611. return 0;
  612. }
  613. /* display one cell per line on subsequent lines */
  614. sprintf(ipaddr, "%pI4", &server->addr);
  615. seq_printf(m, "%3d %-15.15s %5d\n",
  616. atomic_read(&server->usage), ipaddr, server->fs_state);
  617. return 0;
  618. }