From patchwork Fri May 11 07:29:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10393385 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 0C53A602B1 for ; Fri, 11 May 2018 07:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD6BA28A4C for ; Fri, 11 May 2018 07:27:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F64128A57; Fri, 11 May 2018 07:27: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=-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 478F428A4C for ; Fri, 11 May 2018 07:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620AbeEKH1n (ORCPT ); Fri, 11 May 2018 03:27:43 -0400 Received: from mgwkm03.jp.fujitsu.com ([202.219.69.170]:62728 "EHLO mgwkm03.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752612AbeEKH1m (ORCPT ); Fri, 11 May 2018 03:27:42 -0400 Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm03.jp.fujitsu.com with smtp id 43ce_0b9d_f442df8b_e7c4_41ef_91f2_4e6257030e1d; Fri, 11 May 2018 16:27:37 +0900 Received: from g01jpfmpwkw02.exch.g01.fujitsu.local (g01jpfmpwkw02.exch.g01.fujitsu.local [10.0.193.56]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 5CE0EAC0133 for ; Fri, 11 May 2018 16:27:37 +0900 (JST) Received: from g01jpexchkw35.g01.fujitsu.local (unknown [10.0.193.4]) by g01jpfmpwkw02.exch.g01.fujitsu.local (Postfix) with ESMTP id 5C06A32881C for ; Fri, 11 May 2018 16:27:36 +0900 (JST) Received: from luna3.soft.fujitsu.com (10.124.196.199) by g01jpexchkw35.g01.fujitsu.local (10.0.193.50) with Microsoft SMTP Server id 14.3.352.0; Fri, 11 May 2018 16:27:35 +0900 From: Tomohiro Misono To: Subject: [PATCH 08/11] btrfs-progs: utils: Fallback to open without O_NOATIME flag in find_mount_root(): Date: Fri, 11 May 2018 16:29:46 +0900 Message-ID: <20180511072949.15269-9-misono.tomohiro@jp.fujitsu.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180511072949.15269-1-misono.tomohiro@jp.fujitsu.com> References: <20180511072949.15269-1-misono.tomohiro@jp.fujitsu.com> MIME-Version: 1.0 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 non-privileged user can also call find_mount_root(). This is a preparation work to allow non-privileged 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 d81d4980..84b81311 100644 --- a/utils.c +++ b/utils.c @@ -2048,6 +2048,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);