From: "G. Allen Morris III" <gam3-nfs@gam3.net>
To: nfs@lists.sourceforge.net
Subject: Making /proc/fs/nfs/exports human friendly
Date: Fri, 18 Mar 2005 08:55:50 -0500 [thread overview]
Message-ID: <20050318135550.GB27718@gam3.net> (raw)
In-Reply-To: <20050306173628.GA3918@gam3.net>
[-- Attachment #1: Type: text/plain, Size: 8167 bytes --]
On Sun, Mar 06, 2005 at 12:36:28PM -0500, G. Allen Morris III wrote:
> Neil,
>
> Neil the net rcp export cache should not be used directly for
> the /proc/nfs/exports output.
>
> I am pretty sure that all that needs to be done is to only display
> the rightmost element of the domain (client = strrchr(domain, ',')+1).
>
> I have a patch, but plan to clean it up before I send it to you.
>
> I just wanted to request comments on this problem for now.
Here is a patch. I don't expect this to be applied. I only wanted
feed back for now.
The last patch is to the nfs-utils to get the client name.
Rather than passing in the client name as a string it could be passed in
as an index to the correct entry in the domain.
===== fs/nfsd/export.c 1.95 vs edited =====
--- 1.95/fs/nfsd/export.c 2005-03-05 01:32:50 -05:00
+++ edited/fs/nfsd/export.c 2005-03-12 08:39:54 -05:00
@@ -95,6 +95,7 @@
}
static struct svc_expkey *svc_expkey_lookup(struct svc_expkey *, int);
+
static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
{
/* client fsidtype fsid [path] */
@@ -280,6 +281,8 @@
dput(exp->ex_dentry);
mntput(exp->ex_mnt);
auth_domain_put(exp->ex_client);
+ if (exp->ex_client_name)
+ kfree(exp->ex_client_name);
kfree(exp);
}
}
@@ -342,7 +345,7 @@
static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
{
- /* client path expiry [flags anonuid anongid fsid] */
+ /* domain path expiry [flags anonuid anongid fsid client] */
char *buf;
int len;
int err;
@@ -382,6 +385,7 @@
exp.ex_client = dom;
exp.ex_mnt = nd.mnt;
exp.ex_dentry = nd.dentry;
+ exp.ex_client_name = NULL;
/* expiry */
err = -EINVAL;
@@ -416,6 +420,10 @@
if (err) goto out;
}
+ len = qword_get(&mesg, buf, PAGE_SIZE);
+ if (len) {
+ exp.ex_client_name = buf;
+ }
expp = svc_export_lookup(&exp, 1);
if (expp)
exp_put(expp);
@@ -455,6 +463,7 @@
seq_puts(m, ")\n");
return 0;
}
+
struct cache_detail svc_export_cache = {
.hash_size = EXPORT_HASHMAX,
.hash_table = export_table,
@@ -477,6 +486,17 @@
new->ex_client = item->ex_client;
new->ex_dentry = dget(item->ex_dentry);
new->ex_mnt = mntget(item->ex_mnt);
+ new->ex_client_name = NULL;
+ if (item->ex_client_name) {
+ int len;
+ char *s;
+
+ len = strlen(item->ex_client_name);
+ s = kmalloc(len+1, GFP_KERNEL);
+ if (s)
+ strcpy(s, item->ex_client_name);
+ new->ex_client_name = s;
+ }
}
static inline void svc_export_update(struct svc_export *new, struct svc_export *item)
@@ -485,6 +505,13 @@
new->ex_anon_uid = item->ex_anon_uid;
new->ex_anon_gid = item->ex_anon_gid;
new->ex_fsid = item->ex_fsid;
+ if (new->ex_client_name && item->ex_client_name) {
+ if (strcmp(new->ex_client_name, item->ex_client_name)) {
+ printk("svc_export_update both %s ~= %s\n", new->ex_client_name, item->ex_client_name);
+ }
+ } else if (item->ex_client_name) {
+ printk("svc_export_update new %p item %p\n", new->ex_client_name, item->ex_client_name);
+ }
}
static DefineSimpleCacheLookup(svc_export,1) /* allow inplace updates */
@@ -1037,6 +1064,42 @@
seq_printf(m, "%sanongid=%d", first++?",":"", anong);
}
+static int svc_export_display(struct seq_file *m,
+ struct cache_detail *cd,
+ struct cache_head *h)
+{
+ struct svc_export *exp ;
+
+ if (h ==NULL) {
+ seq_puts(m, "#path domain(flags)\n");
+ return 0;
+ }
+ exp = container_of(h, struct svc_export, h);
+ seq_path(m, exp->ex_mnt, exp->ex_dentry, " \t\n\\");
+ seq_putc(m, '\t');
+ if (exp->ex_client_name) {
+ seq_escape(m, exp->ex_client_name, " \t\n\\");
+ } else {
+ seq_escape(m, exp->ex_client->name, " \t\n\\");
+ }
+ seq_putc(m, '(');
+ if (test_bit(CACHE_VALID, &h->flags) &&
+ !test_bit(CACHE_NEGATIVE, &h->flags))
+ exp_flags(m, exp->ex_flags, exp->ex_fsid,
+ exp->ex_anon_uid, exp->ex_anon_gid);
+ seq_puts(m, ") #");
+ {
+ struct auth_domain *dom;
+ dom = auth_domain_find(exp->ex_client->name);
+ if (dom) {
+ auth_unix_list(m, dom);
+ auth_domain_put(dom);
+ }
+ }
+ seq_putc(m, '\n');
+ return 0;
+}
+
static int e_show(struct seq_file *m, void *p)
{
struct cache_head *cp = p;
@@ -1054,7 +1117,7 @@
if (cache_check(&svc_export_cache, &exp->h, NULL))
return 0;
if (cache_put(&exp->h, &svc_export_cache)) BUG();
- return svc_export_show(m, &svc_export_cache, cp);
+ return svc_export_display(m, &svc_export_cache, cp);
}
struct seq_operations nfs_exports_op = {
===== net/sunrpc/sunrpc_syms.c 1.35 vs edited =====
--- 1.35/net/sunrpc/sunrpc_syms.c 2005-03-05 01:32:49 -05:00
+++ edited/net/sunrpc/sunrpc_syms.c 2005-03-09 19:02:17 -05:00
@@ -107,6 +107,7 @@
EXPORT_SYMBOL(auth_unix_add_addr);
EXPORT_SYMBOL(auth_unix_forget_old);
EXPORT_SYMBOL(auth_unix_lookup);
+EXPORT_SYMBOL(auth_unix_list);
EXPORT_SYMBOL(cache_check);
EXPORT_SYMBOL(cache_flush);
EXPORT_SYMBOL(cache_purge);
===== net/sunrpc/svcauth_unix.c 1.37 vs edited =====
--- 1.37/net/sunrpc/svcauth_unix.c 2005-03-05 01:32:49 -05:00
+++ edited/net/sunrpc/svcauth_unix.c 2005-03-11 02:28:57 -05:00
@@ -296,6 +296,38 @@
return 0;
}
+int auth_unix_list(struct seq_file *m, struct auth_domain *dom)
+{
+ int n;
+ struct in_addr addr;
+
+ if (dom->flavour != RPC_AUTH_UNIX)
+ return 1;
+ for (n = 0; n < ip_map_cache.hash_size; n++) {
+ if (ip_map_cache.hash_table[n]) {
+ struct cache_head *h;
+ struct ip_map *im;
+ char *udom = "";
+
+ h = ip_map_cache.hash_table[n];
+ im = container_of(h, struct ip_map, h);
+ if (test_bit(CACHE_VALID, &h->flags) &&
+ !test_bit(CACHE_NEGATIVE, &h->flags))
+ udom = im->m_client->h.name;
+ if (!strcmp(udom, dom->name)) {
+ addr = im->m_addr;
+ seq_printf(m, " %d.%d.%d.%d",
+ htonl(addr.s_addr) >> 24 & 0xff,
+ htonl(addr.s_addr) >> 16 & 0xff,
+ htonl(addr.s_addr) >> 8 & 0xff,
+ htonl(addr.s_addr) >> 0 & 0xff
+ );
+ }
+ }
+ }
+ return 0;
+}
+
struct auth_domain *auth_unix_lookup(struct in_addr addr)
{
struct ip_map key, *ipm;
Index: support/nfs/nfsexport.c
===================================================================
RCS file: /cvsroot/nfs/nfs-utils/support/nfs/nfsexport.c,v
retrieving revision 1.4
diff -u -r1.4 nfsexport.c
--- support/nfs/nfsexport.c 4 Aug 2003 03:14:50 -0000 1.4
+++ support/nfs/nfsexport.c 18 Mar 2005 13:44:05 -0000
@@ -48,6 +48,7 @@
qword_printint(f, exp->ex_anon_uid);
qword_printint(f, exp->ex_anon_gid);
qword_printint(f, exp->ex_dev);
+ qword_print(f, exp->ex_client);
} else
qword_printint(f, 1);
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2005-03-18 13:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-06 16:40 Segfault in mountd -- fixed G. Allen Morris III
2005-03-06 17:36 ` /proc/fs/nfs/exports Broken G. Allen Morris III
2005-03-06 20:30 ` G. Allen Morris III
2005-03-06 23:24 ` Neil Brown
2005-03-18 13:55 ` G. Allen Morris III [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050318135550.GB27718@gam3.net \
--to=gam3-nfs@gam3.net \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.