From patchwork Thu Oct 18 13:11:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10647183 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 1A54517D4 for ; Thu, 18 Oct 2018 13:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05A2F288C6 for ; Thu, 18 Oct 2018 13:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBB59288DC; Thu, 18 Oct 2018 13:11:52 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 88D3E288C6 for ; Thu, 18 Oct 2018 13:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727550AbeJRVMt (ORCPT ); Thu, 18 Oct 2018 17:12:49 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38004 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727567AbeJRVMd (ORCPT ); Thu, 18 Oct 2018 17:12:33 -0400 Received: by mail-wr1-f65.google.com with SMTP id a13-v6so33650304wrt.5 for ; Thu, 18 Oct 2018 06:11:34 -0700 (PDT) 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=OtkmpEPbA/uDUjnzZb7wK0E7hpxNB+LznWScKZ/Q3fg=; b=KIpkCJwpv55kwPrP/fxJDP58dWDSdqFenNJjpjgMUANJvkhG7r/oHHQiurc6o7fnVk PF4RFI+6nCc2OsaNOfRUXT34ShhfVgAbBp1f/xi6coE4p3SCD+4qrBRxUeL0CcTejtPG 1zvD2TdFftZ2Ttkc5vADJlhOUwu6pCEi959KwyYGv7k1BxkfOi9OTVTKVqX18ja9W0Gb Slcp2CLAkNVz1N7k04wOo76NSObB7KIKN391YHnzE5aLHgws9Jzm698RqO79QBW4mT1k bB+fH6HGAmdOjVqlUcAsbA2nLp+w/6dFEyIogsVUyLMl833lwnLNpKOtTV4SJcXv5tCG 9OCw== X-Gm-Message-State: ABuFfohLdE3AkkwDJjFZSA06ly9q24DEFQ7jn+2jYKeNsEJNla7HU2yw oCEkGZt8QibJlj7PwOSIILJajq5tc60= X-Google-Smtp-Source: ACcGV63MdVp0Ch+GYIZzSyLP1v25GFOerViqQPcunER/yuj6bcxIZK32VFsRZSrw7vUVAxikIa5yFA== X-Received: by 2002:a5d:4292:: with SMTP id k18-v6mr27993795wrq.225.1539868293844; Thu, 18 Oct 2018 06:11:33 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id u5-v6sm22246965wru.16.2018.10.18.06.11.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 06:11:33 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Michael Kerrisk , Andreas Dilger , Florian Weimer , Amir Goldstein Subject: [PATCH 3/3] statx: add STATX_ATTRIBUTES flag Date: Thu, 18 Oct 2018 15:11:25 +0200 Message-Id: <20181018131125.6303-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181018131125.6303-1-mszeredi@redhat.com> References: <20181018131125.6303-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP FUSE will want to know if stx_attributes is interesting or not, because there's a non-zero cost of retreiving it. This is more of a "want" flag, since stx_attributes_mask already indicates whether we "got" stx_attributes or not. So for now we can just deal with this flag in the generic code. Signed-off-by: Miklos Szeredi Cc: David Howells Cc: Michael Kerrisk Reviewed-by: Andreas Dilger --- fs/stat.c | 3 +++ include/uapi/linux/stat.h | 1 + samples/statx/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/stat.c b/fs/stat.c index 8d297a279991..6bf86d57e2e3 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -535,6 +535,9 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_size = stat->size; tmp.stx_blocks = stat->blocks; tmp.stx_attributes_mask = stat->attributes_mask; + /* Having anything in attributes_mask means attributes are valid. */ + if (tmp.stx_attributes_mask) + tmp.stx_mask |= STATX_ATTRIBUTES; tmp.stx_atime.tv_sec = stat->atime.tv_sec; tmp.stx_atime.tv_nsec = stat->atime.tv_nsec; tmp.stx_btime.tv_sec = stat->btime.tv_sec; diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 370f09d92fa6..aef0aba5dfe7 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -148,6 +148,7 @@ 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_ATTRIBUTES 0x00001000U /* Want/got stx_attributes */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ diff --git a/samples/statx/test-statx.c b/samples/statx/test-statx.c index e354048dea3c..deef9a68ff68 100644 --- a/samples/statx/test-statx.c +++ b/samples/statx/test-statx.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) struct statx stx; int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW; - unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; + unsigned int mask = STATX_BASIC_STATS | STATX_BTIME | STATX_ATTRIBUTES; for (argv++; *argv; argv++) { if (strcmp(*argv, "-F") == 0) { diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 370f09d92fa6..aef0aba5dfe7 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -148,6 +148,7 @@ 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_ATTRIBUTES 0x00001000U /* Want/got stx_attributes */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */