[2.1.51] Cosmetic patch to /proc/swaps

Riccardo Facchetti (fizban@tin.it)
Wed, 27 Aug 1997 17:43:23 +0200 (MET DST)


Hello,

I was reading the /proc/swaps and I noticed that:

1) Filename of the swap device is displayed without the full path
2) Type of the swap device (file/partition) is displayed incorrectly

This little patch is only cosmetic for these two things.

Ciao,
Riccardo

--- /u/linux-2.1.51/mm/swapfile.c Wed Aug 13 16:10:30 1997
+++ linux/mm/swapfile.c Wed Aug 27 17:24:48 1997
@@ -21,6 +21,7 @@
#include <linux/malloc.h>
#include <linux/blkdev.h> /* for blk_size */
#include <linux/vmalloc.h>
+#include <linux/dcache.h> /* for d_path */

#include <asm/dma.h>
#include <asm/system.h> /* for cli()/sti() */
@@ -421,9 +422,14 @@
len += sprintf(buf, "Filename\t\t\tType\t\tSize\tUsed\tPriority\n");
for (i = 0 ; i < nr_swapfiles ; i++, ptr++)
if (ptr->flags & SWP_USED) {
- len += sprintf(buf + len, "%-31s ", ptr->swap_file->d_name.name);
+ char *path_buf, *full_path;

- if (ptr->swap_file)
+ path_buf = (char *)kmalloc(NAME_MAX+1, GFP_KERNEL);
+ full_path = d_path(ptr->swap_file, path_buf, NAME_MAX);
+ len += sprintf(buf + len, "%-31s ", full_path);
+ kfree(path_buf);
+
+ if (!ptr->swap_device)
len += sprintf(buf + len, "file\t\t");
else