From patchwork Thu Feb 23 08:18:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9587929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16D9660578 for ; Thu, 23 Feb 2017 08:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26EF28338 for ; Thu, 23 Feb 2017 08:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E700D2866A; Thu, 23 Feb 2017 08:19:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74EFD28338 for ; Thu, 23 Feb 2017 08:19:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751191AbdBWITz (ORCPT ); Thu, 23 Feb 2017 03:19:55 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:34277 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119AbdBWITv (ORCPT ); Thu, 23 Feb 2017 03:19:51 -0500 Received: by mail-ot0-f196.google.com with SMTP id w44so2834642otw.1 for ; Thu, 23 Feb 2017 00:18:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=+hkBRhYhgJYkVjDH47K+HiMXJerRIPYj/Jet1GYgWlM=; b=ip2orl9PGi7f8AyTPkdnTT+sgfMnWKDWddiQh1gT50kxi62vgwelu7SMBVA133VDFI bGXYHZzuxzerdWghN9Xc39dsZSS3RvH06Hif+Tk/P5/jjkN4LCt24AQOULm+m8KinX76 0Spv0HardjkFJ8z4gSgZs3HJ3r0FtkQ73B/+jfmky+/lGDiFeKakdlS5ULSlBPDVEeDc o7T4VzzdVgOg7HWxCdERgMjnHf8zZsrbF7kPMIsZFOZBp7ihWB6ill3gN1oTI609kaT3 0kItSRJ+hKrBlrgQFeohknZu+YkBpikMFrn4X95ahH9ZYDHhSMFAhZdt+79S7JFPAtGi JL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=+hkBRhYhgJYkVjDH47K+HiMXJerRIPYj/Jet1GYgWlM=; b=tp08qv86KRTp7pdhAbiA0wulwEux9VD2gwSIVCd+Wq4cV0uGI/PHiIcqNl3+vfxUNE sSz0Qlno3CkvZwgiNF0rpsDArOViUny74FLsAoAbgOvIqw+m+xIVsyYjSS/T5Gcehsue noq9CpKePRd3c41BcCMoe3xIZoQX0aJo8aczIHMoi63CP323wPIqH+qG7kBGl7oP6maP YcgOSjjTgqAy2ZEazrtzLCsLc0W+qiT5q1CnpW8nCxi84tO+34BoYOoAyk76Wz01afXn niA8KqWZyLyS2eXRhOfh4/U7Pkssqfyfggsz0mn9R7XOIP8GSyuO5bN5jAdo/HegJaka qrSw== X-Gm-Message-State: AMke39nBPQY0iLaZWIBisFk/jbamdF00OWA0kxcsnzWQ8Em9ic5nTHVOKW3VXFDjuWGBtQ== X-Received: by 10.157.47.151 with SMTP id r23mr17335778otb.270.1487837915633; Thu, 23 Feb 2017 00:18:35 -0800 (PST) Received: from [192.168.0.102] ([183.228.30.113]) by smtp.gmail.com with ESMTPSA id r130sm1399232oif.20.2017.02.23.00.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Feb 2017 00:18:34 -0800 (PST) From: Kinglong Mee Subject: Re: some problems about permission of subdirectory To: houlinfei , "linux-nfs@vger.kernel.org" References: <7c4bbc9f.5827.15a691a3e04.Coremail.hou.linfei@h3c.com> Cc: bfields@fieldses.org, neilb@suse.com, SteveD@redhat.com, zhengbin.08747@h3c.com, Kinglong Mee Message-ID: <080b9f95-a3c7-7df1-246f-83093db532e2@gmail.com> Date: Thu, 23 Feb 2017 16:18:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <7c4bbc9f.5827.15a691a3e04.Coremail.hou.linfei@h3c.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. thanks, Kinglong Mee --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 #include #include +#include #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