diff options
author | J. Bruce Fields <bfields@redhat.com> | 2019-04-09 15:56:57 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2019-07-03 17:52:50 -0400 |
commit | 97ad4031e29521894fc28765f14247e79b0ef263 (patch) | |
tree | daec545c5697807abc3b7182f15b2c8086fd71a2 /fs/nfsd/nfs4state.c | |
parent | bf5ed3e3bb84c39d70ad10b2f8e47ec62f4c63b1 (diff) | |
download | linux-97ad4031e29521894fc28765f14247e79b0ef263.tar.gz linux-97ad4031e29521894fc28765f14247e79b0ef263.tar.bz2 linux-97ad4031e29521894fc28765f14247e79b0ef263.zip |
nfsd4: add a client info file
Add a new nfsd/clients/#/info file with some basic information about
each NFSv4 client.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8f9747d84525..a6c722dc7e5e 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2214,6 +2214,41 @@ find_stateid_by_type(struct nfs4_client *cl, stateid_t *t, char typemask) return s; } +static int client_info_show(struct seq_file *m, void *v) +{ + struct inode *inode = m->private; + struct nfsdfs_client *nc; + struct nfs4_client *clp; + u64 clid; + + nc = get_nfsdfs_client(inode); + if (!nc) + return -ENXIO; + clp = container_of(nc, struct nfs4_client, cl_nfsdfs); + memcpy(&clid, &clp->cl_clientid, sizeof(clid)); + seq_printf(m, "clientid: 0x%llx\n", clid); + drop_client(clp); + + return 0; +} + +static int client_info_open(struct inode *inode, struct file *file) +{ + return single_open(file, client_info_show, inode); +} + +static const struct file_operations client_info_fops = { + .open = client_info_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static const struct tree_descr client_files[] = { + [0] = {"info", &client_info_fops, S_IRUSR}, + [1] = {""}, +}; + static struct nfs4_client *create_client(struct xdr_netobj name, struct svc_rqst *rqstp, nfs4_verifier *verf) { @@ -2242,7 +2277,8 @@ static struct nfs4_client *create_client(struct xdr_netobj name, clp->cl_cb_session = NULL; clp->net = net; clp->cl_nfsd_dentry = nfsd_client_mkdir(nn, &clp->cl_nfsdfs, - clp->cl_clientid.cl_id - nn->clientid_base); + clp->cl_clientid.cl_id - nn->clientid_base, + client_files); if (!clp->cl_nfsd_dentry) { free_client(clp); return NULL; |