Skip to contentSkip to conversation

Convert fs/nfsd to seq_path()

PATCH New René Scharfe 1 participant 1 message May 21, 2003 NFS server

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Convert fs/nfsd to seq_path()

Hi all,

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

René

fs/nfsd/export.c renamed from fs/nfsd/export.c~ +2 -10
diff -ur linux-2.5.69-bk/fs/nfsd/export.c~ linux-2.5.69-bk/fs/nfsd/export.c
@@ -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);
fs/nfsd/nfsctl.c renamed from fs/nfsd/nfsctl.c~ +2 -21
diff -ur linux-2.5.69-bk/fs/nfsd/nfsctl.c~ linux-2.5.69-bk/fs/nfsd/nfsctl.c
@@ -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,
 };
 
 /*----------------------------------------------------------------------------*/