From: Kinglong Mee <kinglongmee@gmail.com>
To: houlinfei <hou.linfei@h3c.com>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Cc: bfields@fieldses.org, neilb@suse.com, SteveD@redhat.com,
zhengbin.08747@h3c.com, Kinglong Mee <kinglongmee@gmail.com>
Subject: Re: some problems about permission of subdirectory
Date: Thu, 23 Feb 2017 16:18:25 +0800 [thread overview]
Message-ID: <080b9f95-a3c7-7df1-246f-83093db532e2@gmail.com> (raw)
In-Reply-To: <7c4bbc9f.5827.15a691a3e04.Coremail.hou.linfei@h3c.com>
Cc Bruce, Steven,
On 2/23/2017 11:53, houlinfei wrote:
> hi Kinglong,
> I try again, it's okay. but we want to modify the code, till now we are not familiar with nfs, can you tell us where should we modify?
The logic is set a mark on the exported dir when exporting dir,
nfsd kernel checks the mark when finding export entry.
There are two patches I have a little test,
fs/nfsd/vfs.c is the kernel source, and
utils/exportfs/exportfs.c is the nfs-utils source.
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 26c6fdb..c03566c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -456,6 +456,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
* NFS junction information is stored in an extended attribute.
*/
#define NFSD_JUNCTION_XATTR_NAME XATTR_TRUSTED_PREFIX "junction.nfs"
+#define NFSD_EXPORTED_XATTR_NAME NFSD_JUNCTION_XATTR_NAME ".exported"
/**
* nfsd4_is_junction - Test if an object could be an NFS junction
@@ -471,6 +472,8 @@ int nfsd4_is_junction(struct dentry *dentry)
if (inode == NULL)
return 0;
+ if (vfs_getxattr(dentry, NFSD_EXPORTED_XATTR_NAME, NULL, 0) > 0)
+ return 1;
if (inode->i_mode & S_IXUGO)
return 0;
if (!(inode->i_mode & S_ISVTX))
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 02d5b6d..3c6e36b 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <limits.h>
#include <time.h>
+#include <linux/xattr.h>
#define INT_TO_LONG_THRESHOLD_SECS (INT_MAX - (60 * 60 * 24))
@@ -556,6 +557,9 @@ validate_export(nfs_export *exp)
return;
}
+
+#define NFSD_EXPORTED_XATTR_NAME XATTR_TRUSTED_PREFIX "junction.nfs.exported"
+ setxattr(path, NFSD_EXPORTED_XATTR_NAME, "exported", 8, 0);
}
static _Bool
thanks,
Kinglong Mee
next prev parent reply other threads:[~2017-02-23 8:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 3:53 some problems about permission of subdirectory houlinfei
2017-02-23 8:18 ` Kinglong Mee [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-02-25 13:26 houlinfei
2017-02-26 0:23 ` Kinglong Mee
2017-02-25 9:44 houlinfei
2017-02-25 10:51 ` Kinglong Mee
2017-02-23 15:21 houlinfei
2017-02-22 7:16 houlinfei
2017-02-22 8:00 ` Kinglong Mee
2017-02-21 8:52 houlinfei
2017-02-21 13:50 ` Kinglong Mee
2017-02-24 19:14 ` J. Bruce Fields
2017-02-25 10:45 ` Kinglong Mee
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=080b9f95-a3c7-7df1-246f-83093db532e2@gmail.com \
--to=kinglongmee@gmail.com \
--cc=SteveD@redhat.com \
--cc=bfields@fieldses.org \
--cc=hou.linfei@h3c.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.com \
--cc=zhengbin.08747@h3c.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).