From patchwork Fri May 15 21:23:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach Brown X-Patchwork-Id: 6416711 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 09DC79F318 for ; Fri, 15 May 2015 21:29:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EB882056E for ; Fri, 15 May 2015 21:29:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0071220306 for ; Fri, 15 May 2015 21:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946375AbbEOV12 (ORCPT ); Fri, 15 May 2015 17:27:28 -0400 Received: from mail-ie0-f176.google.com ([209.85.223.176]:34721 "EHLO mail-ie0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946155AbbEOVYA (ORCPT ); Fri, 15 May 2015 17:24:00 -0400 Received: by ieczm2 with SMTP id zm2so58973945iec.1 for ; Fri, 15 May 2015 14:23:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=dda/P3+nP54h5WLfUAwxDxhFEIo23DT1PNbn3I1sKYA=; b=UNT0vKKT1jwbaYQRTZnZK6oHrctviOSI79mNk+dPd/Jd7iGGP9CGRwBuqNHi7wRstL MygsPmIGTyB9R8RTvFQWNUKpAu3eCxVz+J18y9Emd2FrUPc/J/XbOQf4VCL+k3z5vlWw suFHZ19qL1SAqH/dug4edww76cQUUmTTTXhcJXyBYzNEh9hJ37/cX656VbN115+cpaet yoDmSGcVwn+cJWar7/RrXCxttzGuNbV0tyx4QFr7PZLFvOI+8Xb2/27LPGg7b+I8t95A RcXJqJNxLOiFrYGIrwtiU4ecwVhl0JEjx4ZEuYWcuWS/HkQcTFcJVRlsEnKs+lKrbiVV HQAA== X-Gm-Message-State: ALoCoQkNpV53SgkhMIlJpUNdEu57t6xWkfg20vVqTbgn2YSnnoE3fPutk9/qG2aaCDMdJ3yH/AYz X-Received: by 10.50.41.8 with SMTP id b8mr829771igl.38.1431725039624; Fri, 15 May 2015 14:23:59 -0700 (PDT) Received: from lenny.home.zabbo.net (c-24-22-122-160.hsd1.or.comcast.net. [24.22.122.160]) by mx.google.com with ESMTPSA id 35sm1977810ior.34.2015.05.15.14.23.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 May 2015 14:23:59 -0700 (PDT) From: Zach Brown To: Sage Weil , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Subject: [PATCH RFC v2 1/2] vfs: add generic nocmtime mount flag Date: Fri, 15 May 2015 14:23:47 -0700 Message-Id: <1431725028-24071-2-git-send-email-zab@zabbo.net> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431725028-24071-1-git-send-email-zab@zabbo.net> References: <1431725028-24071-1-git-send-email-zab@zabbo.net> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the infrastructure to support a generic nocmtime mount flag. Like MS_NOATIME/MNT_NOATIME this can be used to support the mount option in file systems without having to touch each file system. This will be used to provide a priviledged indication that unpriviledged apps can safely use O_NOCMTIME to prevent cmtime updates without harm. Signed-off-by: Zach Brown --- fs/namespace.c | 2 ++ fs/proc_namespace.c | 1 + fs/statfs.c | 2 ++ include/linux/mount.h | 1 + include/linux/statfs.h | 1 + include/uapi/linux/fs.h | 1 + 6 files changed, 8 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index 1b9e111..48be1f9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2652,6 +2652,8 @@ long do_mount(const char *dev_name, const char __user *dir_name, mnt_flags |= MNT_NOEXEC; if (flags & MS_NOATIME) mnt_flags |= MNT_NOATIME; + if (flags & MS_NOCMTIME) + mnt_flags |= MNT_NOCMTIME; if (flags & MS_NODIRATIME) mnt_flags |= MNT_NODIRATIME; if (flags & MS_STRICTATIME) diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 8db932d..49d7839 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -64,6 +64,7 @@ static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt) { MNT_NODEV, ",nodev" }, { MNT_NOEXEC, ",noexec" }, { MNT_NOATIME, ",noatime" }, + { MNT_NOCMTIME, ",nocmtime" }, { MNT_NODIRATIME, ",nodiratime" }, { MNT_RELATIME, ",relatime" }, { 0, NULL } diff --git a/fs/statfs.c b/fs/statfs.c index 083dc0a..43d3de2 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -23,6 +23,8 @@ static int flags_by_mnt(int mnt_flags) flags |= ST_NOEXEC; if (mnt_flags & MNT_NOATIME) flags |= ST_NOATIME; + if (mnt_flags & MNT_NOCMTIME) + flags |= ST_NOCMTIME; if (mnt_flags & MNT_NODIRATIME) flags |= ST_NODIRATIME; if (mnt_flags & MNT_RELATIME) diff --git a/include/linux/mount.h b/include/linux/mount.h index f822c3c..deb458f 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -28,6 +28,7 @@ struct mnt_namespace; #define MNT_NODIRATIME 0x10 #define MNT_RELATIME 0x20 #define MNT_READONLY 0x40 /* does the user want this to be r/o? */ +#define MNT_NOCMTIME 0x80 /* allow O_NOCMTIME to stop cmtime updates */ #define MNT_SHRINKABLE 0x100 #define MNT_WRITE_HOLD 0x200 diff --git a/include/linux/statfs.h b/include/linux/statfs.h index 0166d32..bde224e 100644 --- a/include/linux/statfs.h +++ b/include/linux/statfs.h @@ -39,5 +39,6 @@ struct kstatfs { #define ST_NOATIME 0x0400 /* do not update access times */ #define ST_NODIRATIME 0x0800 /* do not update directory access times */ #define ST_RELATIME 0x1000 /* update atime relative to mtime/ctime */ +#define ST_NOCMTIME 0x2000 /* allow O_NOCMTIME to stop cmtime updates */ #endif diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 9b964a5..af1131e 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -91,6 +91,7 @@ struct inodes_stat_t { #define MS_I_VERSION (1<<23) /* Update inode I_version field */ #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ #define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ +#define MS_NOCMTIME (1<<26) /* allow O_NOCMTIME to stop cmtime updates */ /* These sb flags are internal to the kernel */ #define MS_NOSEC (1<<28)