From patchwork Tue Mar 6 08:35:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10260945 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 5066160211 for ; Tue, 6 Mar 2018 08:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 414B828E9D for ; Tue, 6 Mar 2018 08:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3639728EA5; Tue, 6 Mar 2018 08:35:42 +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.9 required=2.0 tests=BAYES_00,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 96FC828E9D for ; Tue, 6 Mar 2018 08:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753330AbeCFIfj (ORCPT ); Tue, 6 Mar 2018 03:35:39 -0500 Received: from mgwym01.jp.fujitsu.com ([211.128.242.40]:43432 "EHLO mgwym01.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbeCFIfi (ORCPT ); Tue, 6 Mar 2018 03:35:38 -0500 Received: from yt-mxauth.gw.nic.fujitsu.com (unknown [192.168.229.68]) by mgwym01.jp.fujitsu.com with smtp id 3b2f_3f3c_1d536a96_61df_489c_9cbb_617cf67fae65; Tue, 06 Mar 2018 17:35:35 +0900 Received: from g01jpfmpwkw02.exch.g01.fujitsu.local (g01jpfmpwkw02.exch.g01.fujitsu.local [10.0.193.56]) by yt-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id D0A7AAC00CB for ; Tue, 6 Mar 2018 17:35:34 +0900 (JST) Received: from g01jpexchkw38.g01.fujitsu.local (unknown [10.0.193.4]) by g01jpfmpwkw02.exch.g01.fujitsu.local (Postfix) with ESMTP id 090FB3286F9 for ; Tue, 6 Mar 2018 17:35:34 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: c75f34b3d65d448b884dbe25209b5708 Subject: [RFC PATCH 4/7] btrfs-progs: fallback to open without O_NOATIME flag in, find_mount_root() From: "Misono, Tomohiro" To: linux-btrfs References: <94a0bad6-d696-a72e-ba7b-287d1d442997@jp.fujitsu.com> Message-ID: <18bb819b-ada1-d0cc-c32d-4a7be63fd306@jp.fujitsu.com> Date: Tue, 6 Mar 2018 17:35:30 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <94a0bad6-d696-a72e-ba7b-287d1d442997@jp.fujitsu.com> Content-Language: en-US X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP O_NOATIME flag requires effective UID of process matches file's owner or has CAP_FOWNER capabilities. Fallback to open without O_NOATIME flag so that normal user can also call find_mount_root(). This is a preparation work to allow normal user to call "subvolume show". Signed-off-by: Tomohiro Misono --- utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.c b/utils.c index 81c54faa..acea70a5 100644 --- a/utils.c +++ b/utils.c @@ -2045,6 +2045,9 @@ int find_mount_root(const char *path, char **mount_root) char *longest_match = NULL; fd = open(path, O_RDONLY | O_NOATIME); + if (fd < 0 && errno == EPERM) + fd = open(path, O_RDONLY); + if (fd < 0) return -errno; close(fd);