From patchwork Fri Mar 1 14:05:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E59F1880 for ; Fri, 1 Mar 2019 14:06:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F6262F1EB for ; Fri, 1 Mar 2019 14:06:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03D972F25A; Fri, 1 Mar 2019 14:06:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 210252F245 for ; Fri, 1 Mar 2019 14:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387869AbfCAOGG (ORCPT ); Fri, 1 Mar 2019 09:06:06 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37739 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOGG (ORCPT ); Fri, 1 Mar 2019 09:06:06 -0500 Received: by mail-pg1-f193.google.com with SMTP id q206so11506265pgq.4; Fri, 01 Mar 2019 06:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=csWCm9wcihuFFL4oUEGmYUPt6om3ctC29q/OFYjhErk=; b=bwMkidqD6m5h/zOFkwkGPoK7AvAU84RKMKIz7CKeP2TRDv3BdjKH8nnRl0SVBmIFGR cjHWcbAMH8vCKY/SpvhD2TFi2r5/32QH4oIJgK2IxnamqlNkaqmLa2mcF4wg+5kdEeAt QCpbjkmDsR0LQhuYbY3CycDzsSKv04bnIQHp+TBHLuDRs55mE6nwd3Ioor3XAHR62+3e 3ZmMEnA1QRZ01x2TPzFO8Q5JJm9NxCkEqSvjprkSzGftQAkVCXZK8VFLstIrrz1KXzOX zquVBGre5Qf+JK545vfw4Uvq3bBmnnG9T9cJzyP5NRCs2vrOcQOUQ5WevFiERGRjhQja cKtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=csWCm9wcihuFFL4oUEGmYUPt6om3ctC29q/OFYjhErk=; b=YdgUE+ot128CYbWJQaEIiCYYcSTT0zOjsO2T+vcfFxyuWqU6gEkmPN4oqLy53oEmRD OGgmTE0uQyFq2o72ntTsyEa/YVsIBkiW/bu6Ko/psw3OUWmSdEAAn6Z+oER9IEjKEwnF SSkktNqlqXeQTLB894LnddDxY0XXKnIHYRP2ZQ5+anwrfzB1PloTdzWOQEWg3upjYzkH L6F9jms6LWElMwZrdnTCZBVAPK4lwsvjlSe+RofzGq2CD1LXqNyuri0YyLoAS2YGVnSI 1vCeRPS7qCOItuVcunu3eJSSJ1y2yeuWaWM2UdSbujxNZbvldvWlQvWO985hDKK5KvXn a3CA== X-Gm-Message-State: AHQUAubhlX+rem6fcXvM0iIyZxzPjaQ4iU7vTMk6pzuOemHRTm2bP4Zk F4VKWXI/yWMRJDm26bNPFJcPb4P/ X-Google-Smtp-Source: AHgI3IboBpcdD5M0lYdeSrL6Z5y9WAduUlI23iLXpgtGfPDBkrRvf+2Oz1kj+RJzL4YffpHKwpp9Kg== X-Received: by 2002:a62:6d81:: with SMTP id i123mr5647563pfc.235.1551449164026; Fri, 01 Mar 2019 06:06:04 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.06.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:06:03 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 5/8] fs: add project support to statx Date: Fri, 1 Mar 2019 23:05:38 +0900 Message-Id: <1551449141-7884-6-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Extend statx to support project ID and inherit attribute. Signed-off-by: Wang Shilong --- fs/stat.c | 1 + include/linux/stat.h | 2 ++ include/uapi/linux/stat.h | 8 ++++++-- tools/include/uapi/linux/stat.h | 8 ++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index adbfcd86c81b..82d855c4647c 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -551,6 +551,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_rdev_minor = MINOR(stat->rdev); tmp.stx_dev_major = MAJOR(stat->dev); tmp.stx_dev_minor = MINOR(stat->dev); + tmp.stx_projid = (u32)from_kprojid(&init_user_ns, stat->projid); return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; } diff --git a/include/linux/stat.h b/include/linux/stat.h index 765573dc17d6..72c9d2ab5343 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -18,6 +18,7 @@ #include #include #include +#include #define KSTAT_QUERY_FLAGS (AT_STATX_SYNC_TYPE) @@ -40,6 +41,7 @@ struct kstat { dev_t rdev; kuid_t uid; kgid_t gid; + kprojid_t projid; loff_t size; struct timespec64 atime; struct timespec64 mtime; diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 7b35e98d3c58..56d35a2cbd0c 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -123,7 +123,9 @@ struct statx { __u32 stx_dev_major; /* ID of device containing file [uncond] */ __u32 stx_dev_minor; /* 0x90 */ - __u64 __spare2[14]; /* Spare space for future expansion */ + __u32 stx_projid; /* Project ID of file */ + __u32 __spare1[1]; + __u64 __spare2[13]; /* Spare space for future expansion */ /* 0x100 */ }; @@ -148,7 +150,8 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ +#define STATX_PROJID 0x00001000U /* Want/Got stx_projid */ +#define STATX_ALL 0x00001fffU /* All currently supported flags */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* @@ -170,5 +173,6 @@ struct statx { #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ +#define STATX_ATTR_PROJINHERIT 0x00002000 /* [I] File project inherit is set */ #endif /* _UAPI_LINUX_STAT_H */ diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 7b35e98d3c58..21b542b3b061 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -123,7 +123,9 @@ struct statx { __u32 stx_dev_major; /* ID of device containing file [uncond] */ __u32 stx_dev_minor; /* 0x90 */ - __u64 __spare2[14]; /* Spare space for future expansion */ + __u32 stx_projid; /* Project ID of file */ + __u32 __spare1[1]; + __u64 __spare2[13]; /* Spare space for future expansion */ /* 0x100 */ }; @@ -148,7 +150,8 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ +#define STATX_PROJID 0x00001000U /* Want/Got stx_projid */ +#define STATX_ALL 0x00001fffU /* All currently supported flags */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* @@ -170,5 +173,6 @@ struct statx { #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ +#define STATX_ATTR_PROJINHERIT 0x00002000 /* [I] File project inherit is set */ #endif /* _UAPI_LINUX_STAT_H */