2003-05-21 22:47:20

by Ren

[permalink] [raw]
Subject: [PATCH] Convert fs/nfsd to seq_path()

Hi all,

this patch makes the Kernel NFS server code use seq_path() which Al
wrote recently.

Ren?



diff -ur linux-2.5.69-bk/fs/nfsd/export.c~ linux-2.5.69-bk/fs/nfsd/export.c
--- linux-2.5.69-bk/fs/nfsd/export.c~ 2003-05-22 00:43:16.000000000 +0200
+++ linux-2.5.69-bk/fs/nfsd/export.c 2003-05-22 00:14:46.000000000 +0200
@@ -972,17 +972,11 @@
seq_printf(m, "%sanongid=%d", first++?",":"", anong);
}

-static inline void mangle(struct seq_file *m, const char *s)
-{
- seq_escape(m, s, " \t\n\\");
-}
-
static int e_show(struct seq_file *m, void *p)
{
struct cache_head *cp = p;
struct svc_export *exp = container_of(cp, struct svc_export, h);
svc_client *clp;
- char *pbuf;

if (p == (void *)1) {
seq_puts(m, "# Version 1.1\n");
@@ -995,12 +989,10 @@
if (cache_check(&svc_export_cache, &exp->h, NULL))
return 0;
if (cache_put(&exp->h, &svc_export_cache)) BUG();
- pbuf = m->private;
- mangle(m, d_path(exp->ex_dentry, exp->ex_mnt,
- pbuf, PAGE_SIZE));
+ seq_path(m, exp->ex_mnt, exp->ex_dentry, " \t\n\\");

seq_putc(m, '\t');
- mangle(m, clp->name);
+ seq_escape(m, clp->name, " \t\n\\");
seq_putc(m, '(');
exp_flags(m, exp->ex_flags, exp->ex_fsid,
exp->ex_anon_uid, exp->ex_anon_gid);
diff -ur linux-2.5.69-bk/fs/nfsd/nfsctl.c~ linux-2.5.69-bk/fs/nfsd/nfsctl.c
--- linux-2.5.69-bk/fs/nfsd/nfsctl.c~ 2003-05-22 00:43:16.000000000 +0200
+++ linux-2.5.69-bk/fs/nfsd/nfsctl.c 2003-05-22 00:39:17.000000000 +0200
@@ -175,32 +175,13 @@
extern struct seq_operations nfs_exports_op;
static int exports_open(struct inode *inode, struct file *file)
{
- int res;
- char *namebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- if (namebuf == NULL)
- return -ENOMEM;
-
- res = seq_open(file, &nfs_exports_op);
- if (res)
- kfree(namebuf);
- else
- ((struct seq_file *)file->private_data)->private = namebuf;
-
- return res;
-}
-static int exports_release(struct inode *inode, struct file *file)
-{
- struct seq_file *m = (struct seq_file *)file->private_data;
- kfree(m->private);
- m->private = NULL;
- return seq_release(inode, file);
+ return seq_open(file, &nfs_exports_op);
}
-
static struct file_operations exports_operations = {
.open = exports_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = exports_release,
+ .release = seq_release,
};

/*----------------------------------------------------------------------------*/