aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorSuleiman Souhlal <ssouhlal@FreeBSD.org>2006-12-06 23:32:28 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:22 -0500
commit881e4aabe4c6b3fce93674b67c6adc646fe2683b (patch)
treef5e429c01ca20c8bb8bd300e33013f056516b131 /mm/swapfile.c
parentb43a57bb4dae72e8f7232e7c821a8799eda30022 (diff)
[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: Suleiman Souhlal <suleiman@google.com> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a15def63f28f..8e206cea0f5e 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1274,10 +1274,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1274 1274
1275 mutex_lock(&swapon_mutex); 1275 mutex_lock(&swapon_mutex);
1276 1276
1277 if (!l)
1278 return SEQ_START_TOKEN;
1279
1277 for (i = 0; i < nr_swapfiles; i++, ptr++) { 1280 for (i = 0; i < nr_swapfiles; i++, ptr++) {
1278 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1281 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1279 continue; 1282 continue;
1280 if (!l--) 1283 if (!--l)
1281 return ptr; 1284 return ptr;
1282 } 1285 }
1283 1286
@@ -1286,10 +1289,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1286 1289
1287static void *swap_next(struct seq_file *swap, void *v, loff_t *pos) 1290static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
1288{ 1291{
1289 struct swap_info_struct *ptr = v; 1292 struct swap_info_struct *ptr;
1290 struct swap_info_struct *endptr = swap_info + nr_swapfiles; 1293 struct swap_info_struct *endptr = swap_info + nr_swapfiles;
1291 1294
1292 for (++ptr; ptr < endptr; ptr++) { 1295 if (v == SEQ_START_TOKEN)
1296 ptr = swap_info;
1297 else {
1298 ptr = v;
1299 ptr++;
1300 }
1301
1302 for (; ptr < endptr; ptr++) {
1293 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1303 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1294 continue; 1304 continue;
1295 ++*pos; 1305 ++*pos;
@@ -1310,8 +1320,10 @@ static int swap_show(struct seq_file *swap, void *v)
1310 struct file *file; 1320 struct file *file;
1311 int len; 1321 int len;
1312 1322
1313 if (v == swap_info) 1323 if (ptr == SEQ_START_TOKEN) {
1314 seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); 1324 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
1325 return 0;
1326 }
1315 1327
1316 file = ptr->swap_file; 1328 file = ptr->swap_file;
1317 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\"); 1329 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");