From be6837878142c7cdb0d3a5378c0e66e77cd24850 Mon Sep 17 00:00:00 2001 From: Suleiman Souhlal Date: Wed, 6 Dec 2006 20:32:28 -0800 Subject: [PATCH] --- yaml --- r: 42666 b: refs/heads/master c: 881e4aabe4c6b3fce93674b67c6adc646fe2683b h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/mm/swapfile.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index e8cc4e677273..62ed2d590f47 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b43a57bb4dae72e8f7232e7c821a8799eda30022 +refs/heads/master: 881e4aabe4c6b3fce93674b67c6adc646fe2683b diff --git a/trunk/mm/swapfile.c b/trunk/mm/swapfile.c index a15def63f28f..8e206cea0f5e 100644 --- a/trunk/mm/swapfile.c +++ b/trunk/mm/swapfile.c @@ -1274,10 +1274,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos) mutex_lock(&swapon_mutex); + if (!l) + return SEQ_START_TOKEN; + for (i = 0; i < nr_swapfiles; i++, ptr++) { if (!(ptr->flags & SWP_USED) || !ptr->swap_map) continue; - if (!l--) + if (!--l) return ptr; } @@ -1286,10 +1289,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos) static void *swap_next(struct seq_file *swap, void *v, loff_t *pos) { - struct swap_info_struct *ptr = v; + struct swap_info_struct *ptr; struct swap_info_struct *endptr = swap_info + nr_swapfiles; - for (++ptr; ptr < endptr; ptr++) { + if (v == SEQ_START_TOKEN) + ptr = swap_info; + else { + ptr = v; + ptr++; + } + + for (; ptr < endptr; ptr++) { if (!(ptr->flags & SWP_USED) || !ptr->swap_map) continue; ++*pos; @@ -1310,8 +1320,10 @@ static int swap_show(struct seq_file *swap, void *v) struct file *file; int len; - if (v == swap_info) - seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); + if (ptr == SEQ_START_TOKEN) { + seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); + return 0; + } file = ptr->swap_file; len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");