From patchwork Sun May 6 22:47:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 10383065 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 3156F60467 for ; Sun, 6 May 2018 22:49:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 188C528A48 for ; Sun, 6 May 2018 22:49:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0946928A55; Sun, 6 May 2018 22:49:21 +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=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 8F94928A48 for ; Sun, 6 May 2018 22:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbeEFWsz (ORCPT ); Sun, 6 May 2018 18:48:55 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38359 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079AbeEFWsM (ORCPT ); Sun, 6 May 2018 18:48:12 -0400 Received: by mail-wr0-f194.google.com with SMTP id 94-v6so25105248wrf.5; Sun, 06 May 2018 15:48:11 -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=NdrY/TbRiUdFOwAfMmo/ShZ8KpaVNRlY8PcscI7GjUM=; b=aQhVOejMzZmDYOMJl0zq0IWLt7tXB1GyN4iCRbh5K8iSci9M7z8YwOZrmaFHeezEuE 5VI1TbYssHxnClAJ8ZzK+VqS/3FW3QvruolC2w4UFB/pxPZbaXYw1s9k+sORXccTZgCT GeiOaMyjCKAgpMC+FcVtX6XrKSd1TlavWl2SGw1WASGgMAycWkxKkTDoC1DgJzXx6s12 155m92s0ihI1Qv+ezqSshJ41o+RZJvVb4k8S3FBfMG/n9jva5FthzPQFIgtnnxxVXS1q Jxk+lfOANaZDBOznaMx4P6SlVQfj53DYlWzpjTTVogFK9oWZTJo6Hho2Oyz2iBqGmApG cGSg== X-Gm-Message-State: ALQs6tAtNx/lp0tcqzA1UVgtEOmda4z9qwMAfE4iw0jL8t4CbgRtIrgt N1OZKTneWGH2fQuBXW5Vkxenj2q9TEM= X-Google-Smtp-Source: AB8JxZptn+ZHMy9dSdfTjOXe3MMUnH/MIWhvqHEBEPq0Uib30Z50QCzkuHbssASn+XLRic4IAnGGcg== X-Received: by 2002:adf:9162:: with SMTP id j89-v6mr27358105wrj.196.1525646890697; Sun, 06 May 2018 15:48:10 -0700 (PDT) Received: from localhost.localdomain ([2a02:8070:8895:9700:b0c9:237:9998:dabc]) by smtp.gmail.com with ESMTPSA id h133sm7619902wmf.47.2018.05.06.15.48.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 May 2018 15:48:10 -0700 (PDT) From: Christian Brauner To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: torvalds@linux-foundation.org, tglx@linutronix.de, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, linux-api@vger.kernel.org, Christian Brauner Subject: [PATCH 3/6 v1] statfs: add ST_UNBINDABLE Date: Mon, 7 May 2018 00:47:01 +0200 Message-Id: <20180506224704.14669-4-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180506224704.14669-1-christian.brauner@ubuntu.com> References: <20180506224704.14669-1-christian.brauner@ubuntu.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 Currently userspace can only determine whether a mountpoint is unbindable by parsing /proc//mountinfo. It would be convenient to simply retrieve this property with a statvfs() call. This let's userspace avoid costly parsing, supports cases where /proc is not mounted, and supports usecases where file descriptors to mountpoints are passed between processes that are inspected via fstatvfs(). Signed-off-by: Christian Brauner --- v0->v1: * non-functional changes: extend commit message --- fs/statfs.c | 2 ++ include/linux/statfs.h | 1 + 2 files changed, 3 insertions(+) diff --git a/fs/statfs.c b/fs/statfs.c index 5b2a24f0f263..61b3063d3921 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -29,6 +29,8 @@ static int flags_by_mnt(int mnt_flags) flags |= ST_NODIRATIME; if (mnt_flags & MNT_RELATIME) flags |= ST_RELATIME; + if (mnt_flags & MNT_UNBINDABLE) + flags |= ST_UNBINDABLE; return flags; } diff --git a/include/linux/statfs.h b/include/linux/statfs.h index b336c04e793c..e1b84d0388c1 100644 --- a/include/linux/statfs.h +++ b/include/linux/statfs.h @@ -40,5 +40,6 @@ struct kstatfs { #define ST_NOATIME (1<<10) /* do not update access times */ #define ST_NODIRATIME (1<<11) /* do not update directory access times */ #define ST_RELATIME (1<<12) /* update atime relative to mtime/ctime */ +#define ST_UNBINDABLE (1<<17) /* change to unbindable */ #endif