From patchwork Fri May 25 12:48:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 10427345 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 D51D1602D6 for ; Fri, 25 May 2018 12:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFD4F293DF for ; Fri, 25 May 2018 12:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B29222940D; Fri, 25 May 2018 12:51:45 +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 40BC6293DF for ; Fri, 25 May 2018 12:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935837AbeEYMvC (ORCPT ); Fri, 25 May 2018 08:51:02 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40405 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752581AbeEYMtq (ORCPT ); Fri, 25 May 2018 08:49:46 -0400 Received: by mail-wm0-f68.google.com with SMTP id x2-v6so6949410wmh.5; Fri, 25 May 2018 05:49:45 -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=7JVwvFWZuueVWlRBd9dObjBlgncP6GG6XEvMO/VqAws=; b=X9M9VBFolux0gaKjKfUP8oAlAIF91mvgy5bsmNHsrgzepmUk2qgyGDuVdTUSA/ed2x lisqlOJ4rFNxicCoQgGg9P7NomlAp8m9s/OCedUIvT0glg3u0aPLvfZpbzuRjNc5dGWe GYnM5fzM2AFNqVxjs4b8/kKIpt9MHIDvANfZVTyuwXIsJdT6dLQpgd20cQELSqTcTmaE zFoSQSlJF8iYaszXNd4Pl90JnrRglqr0FNJTm2gX4KpD+in0jmHxVDynE+COHejnAOEx LhJg4ycBwy5l2cQ3CuAP9v7gUKCjtZXV+wFAugSsBNLce4gPrl7rsY041A+vezM3sYaM FxRA== X-Gm-Message-State: ALKqPwf7CqIrPGxP0zezq28XgQaUG6LcKVu2ym3Kzv5/mix1N+xz3t2X VP4cXQUAIBjoNMqIr54fuczrThPBQhg= X-Google-Smtp-Source: ADUXVKLn4nx/90446Lv2G7vGeY20SdOSITkFMKVaJjxNQ/yMXxiNGCu9k38Av/JzLOFZoXXg50XkGA== X-Received: by 2002:a1c:a95:: with SMTP id 143-v6mr1635087wmk.134.1527252584758; Fri, 25 May 2018 05:49:44 -0700 (PDT) Received: from localhost.localdomain ([2a02:8070:8895:9700:c80a:973d:8254:7f55]) by smtp.gmail.com with ESMTPSA id u8-v6sm6053292wmc.40.2018.05.25.05.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 05:49:44 -0700 (PDT) From: Christian Brauner To: 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, ebiederm@xmission.com, seth.forshee@canonical.com, viro@zeniv.linux.org.uk, Christian Brauner Subject: [PATCH 3/6 v1 resend] statfs: add ST_UNBINDABLE Date: Fri, 25 May 2018 14:48:22 +0200 Message-Id: <20180525124825.23875-4-christian@brauner.io> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180525124825.23875-1-christian@brauner.io> References: <20180525124825.23875-1-christian@brauner.io> 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