aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs/proc.c
diff options
context:
space:
mode:
authorPavel Emelianov <xemul@sw.ru>2007-07-16 02:39:52 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:41 -0400
commita6a8bd6d2839f7134f191c6e13e2fd2e9e8c91a6 (patch)
tree21714dcd131324d7032a5411b0af58c0451d4430 /fs/afs/proc.c
parentb4ef0296f214a1e0e65f161f88663b0ca1acca31 (diff)
Make AFS use seq_list_xxx helpers
These proc files show some header before dumping the list, so the seq_list_start_head() is used. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/afs/proc.c')
-rw-r--r--fs/afs/proc.c81
1 files changed, 11 insertions, 70 deletions
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 13df512aea9e..6edb56683b9a 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -201,23 +201,9 @@ static int afs_proc_cells_open(struct inode *inode, struct file *file)
201 */ 201 */
202static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos) 202static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
203{ 203{
204 struct list_head *_p;
205 loff_t pos = *_pos;
206
207 /* lock the list against modification */ 204 /* lock the list against modification */
208 down_read(&afs_proc_cells_sem); 205 down_read(&afs_proc_cells_sem);
209 206 return seq_list_start_head(&afs_proc_cells, *_pos);
210 /* allow for the header line */
211 if (!pos)
212 return (void *) 1;
213 pos--;
214
215 /* find the n'th element in the list */
216 list_for_each(_p, &afs_proc_cells)
217 if (!pos--)
218 break;
219
220 return _p != &afs_proc_cells ? _p : NULL;
221} 207}
222 208
223/* 209/*
@@ -225,14 +211,7 @@ static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
225 */ 211 */
226static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos) 212static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos)
227{ 213{
228 struct list_head *_p; 214 return seq_list_next(v, &afs_proc_cells, pos);
229
230 (*pos)++;
231
232 _p = v;
233 _p = v == (void *) 1 ? afs_proc_cells.next : _p->next;
234
235 return _p != &afs_proc_cells ? _p : NULL;
236} 215}
237 216
238/* 217/*
@@ -250,7 +229,7 @@ static int afs_proc_cells_show(struct seq_file *m, void *v)
250{ 229{
251 struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link); 230 struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link);
252 231
253 if (v == (void *) 1) { 232 if (v == &afs_proc_cells) {
254 /* display header on line 1 */ 233 /* display header on line 1 */
255 seq_puts(m, "USE NAME\n"); 234 seq_puts(m, "USE NAME\n");
256 return 0; 235 return 0;
@@ -503,26 +482,13 @@ static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file)
503 */ 482 */
504static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos) 483static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
505{ 484{
506 struct list_head *_p;
507 struct afs_cell *cell = m->private; 485 struct afs_cell *cell = m->private;
508 loff_t pos = *_pos;
509 486
510 _enter("cell=%p pos=%Ld", cell, *_pos); 487 _enter("cell=%p pos=%Ld", cell, *_pos);
511 488
512 /* lock the list against modification */ 489 /* lock the list against modification */
513 down_read(&cell->vl_sem); 490 down_read(&cell->vl_sem);
514 491 return seq_list_start_head(&cell->vl_list, *_pos);
515 /* allow for the header line */
516 if (!pos)
517 return (void *) 1;
518 pos--;
519
520 /* find the n'th element in the list */
521 list_for_each(_p, &cell->vl_list)
522 if (!pos--)
523 break;
524
525 return _p != &cell->vl_list ? _p : NULL;
526} 492}
527 493
528/* 494/*
@@ -531,17 +497,10 @@ static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
531static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, 497static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
532 loff_t *_pos) 498 loff_t *_pos)
533{ 499{
534 struct list_head *_p;
535 struct afs_cell *cell = p->private; 500 struct afs_cell *cell = p->private;
536 501
537 _enter("cell=%p pos=%Ld", cell, *_pos); 502 _enter("cell=%p pos=%Ld", cell, *_pos);
538 503 return seq_list_next(v, &cell->vl_list, _pos);
539 (*_pos)++;
540
541 _p = v;
542 _p = (v == (void *) 1) ? cell->vl_list.next : _p->next;
543
544 return (_p != &cell->vl_list) ? _p : NULL;
545} 504}
546 505
547/* 506/*
@@ -569,11 +528,12 @@ const char afs_vlocation_states[][4] = {
569 */ 528 */
570static int afs_proc_cell_volumes_show(struct seq_file *m, void *v) 529static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
571{ 530{
531 struct afs_cell *cell = m->private;
572 struct afs_vlocation *vlocation = 532 struct afs_vlocation *vlocation =
573 list_entry(v, struct afs_vlocation, link); 533 list_entry(v, struct afs_vlocation, link);
574 534
575 /* display header on line 1 */ 535 /* display header on line 1 */
576 if (v == (void *) 1) { 536 if (v == &cell->vl_list) {
577 seq_puts(m, "USE STT VLID[0] VLID[1] VLID[2] NAME\n"); 537 seq_puts(m, "USE STT VLID[0] VLID[1] VLID[2] NAME\n");
578 return 0; 538 return 0;
579 } 539 }
@@ -734,26 +694,13 @@ static int afs_proc_cell_servers_release(struct inode *inode,
734static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos) 694static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos)
735 __acquires(m->private->servers_lock) 695 __acquires(m->private->servers_lock)
736{ 696{
737 struct list_head *_p;
738 struct afs_cell *cell = m->private; 697 struct afs_cell *cell = m->private;
739 loff_t pos = *_pos;
740 698
741 _enter("cell=%p pos=%Ld", cell, *_pos); 699 _enter("cell=%p pos=%Ld", cell, *_pos);
742 700
743 /* lock the list against modification */ 701 /* lock the list against modification */
744 read_lock(&cell->servers_lock); 702 read_lock(&cell->servers_lock);
745 703 return seq_list_start_head(&cell->servers, *_pos);
746 /* allow for the header line */
747 if (!pos)
748 return (void *) 1;
749 pos--;
750
751 /* find the n'th element in the list */
752 list_for_each(_p, &cell->servers)
753 if (!pos--)
754 break;
755
756 return _p != &cell->servers ? _p : NULL;
757} 704}
758 705
759/* 706/*
@@ -762,17 +709,10 @@ static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos)
762static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, 709static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
763 loff_t *_pos) 710 loff_t *_pos)
764{ 711{
765 struct list_head *_p;
766 struct afs_cell *cell = p->private; 712 struct afs_cell *cell = p->private;
767 713
768 _enter("cell=%p pos=%Ld", cell, *_pos); 714 _enter("cell=%p pos=%Ld", cell, *_pos);
769 715 return seq_list_next(v, &cell->servers, _pos);
770 (*_pos)++;
771
772 _p = v;
773 _p = v == (void *) 1 ? cell->servers.next : _p->next;
774
775 return _p != &cell->servers ? _p : NULL;
776} 716}
777 717
778/* 718/*
@@ -791,11 +731,12 @@ static void afs_proc_cell_servers_stop(struct seq_file *p, void *v)
791 */ 731 */
792static int afs_proc_cell_servers_show(struct seq_file *m, void *v) 732static int afs_proc_cell_servers_show(struct seq_file *m, void *v)
793{ 733{
734 struct afs_cell *cell = m->private;
794 struct afs_server *server = list_entry(v, struct afs_server, link); 735 struct afs_server *server = list_entry(v, struct afs_server, link);
795 char ipaddr[20]; 736 char ipaddr[20];
796 737
797 /* display header on line 1 */ 738 /* display header on line 1 */
798 if (v == (void *) 1) { 739 if (v == &cell->servers) {
799 seq_puts(m, "USE ADDR STATE\n"); 740 seq_puts(m, "USE ADDR STATE\n");
800 return 0; 741 return 0;
801 } 742 }