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