summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>2003-05-20 06:58:17 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2003-05-20 06:58:17 -0700
commit32ccd2b61dfd05401528b27770ab3cd22b143641 (patch)
tree01cd62e23876962215deb49c4ff7105a65bdddfd /mm
parentecdb306381de9308a484c29b28c03e2686aa00ae (diff)
[PATCH] seq_path(), /proc/mounts and /proc/swaps
This adds a new seq_...() helper: seq_path(seq_file, mnt, dentry, escape) It spits the pathname into seq_file, does octal escapes for given set of characters, returns the number of characters it'd produced or -1 in case of error. Long names are handled gracefully - you don't need anything to do, generic seq_file logics will do the right thing. /proc/mounts and /proc/swaps are converted to use of seq_path(), some junk removed. /proc/pid/maps will be converted next.
Diffstat (limited to 'mm')
-rw-r--r--mm/swapfile.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 55b2de7bca97..bdfd09be8d4c 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1118,14 +1118,9 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
struct swap_info_struct *ptr = swap_info;
int i;
loff_t l = *pos;
- char * page = (char *) __get_free_page(GFP_KERNEL);
- swap->private = page; /* save for swap_show */
swap_list_lock();
- if (!page)
- return ERR_PTR(-ENOMEM);
-
for (i = 0; i < nr_swapfiles; i++, ptr++) {
if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
continue;
@@ -1154,24 +1149,21 @@ static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
static void swap_stop(struct seq_file *swap, void *v)
{
swap_list_unlock();
- free_page((unsigned long) swap->private);
- swap->private = NULL;
}
static int swap_show(struct seq_file *swap, void *v)
{
struct swap_info_struct *ptr = v;
struct file *file;
- char *path;
+ int len;
if (v == swap_info)
seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
file = ptr->swap_file;
- path = d_path(file->f_dentry, file->f_vfsmnt, swap->private, PAGE_SIZE);
-
- seq_printf(swap, "%-39s %s\t%d\t%ld\t%d\n",
- path,
+ len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
+ seq_printf(swap, "%*s %s\t%d\t%ld\t%d\n",
+ len < 40 ? 40 - len : 1, " ",
S_ISBLK(file->f_dentry->d_inode->i_mode) ?
"partition" : "file\t",
ptr->pages << (PAGE_SHIFT - 10),