Commit 881e4aab authored by Suleiman Souhlal's avatar Suleiman Souhlal Committed by Linus Torvalds

[PATCH] Always print out the header line in /proc/swaps

It would be possible for /proc/swaps to not always print out the header:

swapon /dev/hdc2
swapon /dev/hde2
swapoff /dev/hdc2

At this point /proc/swaps would not have a header.
Signed-off-by: default avatarSuleiman Souhlal <suleiman@google.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b43a57bb
...@@ -1274,10 +1274,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos) ...@@ -1274,10 +1274,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
mutex_lock(&swapon_mutex); mutex_lock(&swapon_mutex);
if (!l)
return SEQ_START_TOKEN;
for (i = 0; i < nr_swapfiles; i++, ptr++) { for (i = 0; i < nr_swapfiles; i++, ptr++) {
if (!(ptr->flags & SWP_USED) || !ptr->swap_map) if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
continue; continue;
if (!l--) if (!--l)
return ptr; return ptr;
} }
...@@ -1286,10 +1289,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos) ...@@ -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) 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; 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) if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
continue; continue;
++*pos; ++*pos;
...@@ -1310,8 +1320,10 @@ static int swap_show(struct seq_file *swap, void *v) ...@@ -1310,8 +1320,10 @@ static int swap_show(struct seq_file *swap, void *v)
struct file *file; struct file *file;
int len; int len;
if (v == swap_info) if (ptr == SEQ_START_TOKEN) {
seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
return 0;
}
file = ptr->swap_file; file = ptr->swap_file;
len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\"); len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment