Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2953228imm; Thu, 24 May 2018 19:47:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqG/shGwHT8luquPywjPq3uFQuSaz948QTKpmTeIT6Sh3t8BQ7TUadznE69ZqDFSUw1TG4q X-Received: by 2002:a62:8d51:: with SMTP id z78-v6mr595337pfd.69.1527216473291; Thu, 24 May 2018 19:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216473; cv=none; d=google.com; s=arc-20160816; b=H6erk74HG0Lwf0spvnEHeI9XH8UOBwef4UQk3el6LpYFzEmeTupzIrhMjYuTfboROQ lqCnQvmZfqYGa8NqiWPsyJ6eGKKzPk6QTZCbFA5hjVEXZKTwnyCZ99UawKobAJgJD4MW nnnIdjOwy/CWSRbC6ELUvgKtFEOsVffHfaOmGW5d8GiiE8sazmD3di5jsIg+73BNVIsk LME25xn2qmzVh+afEUmuF8vMXt1/sCL/q89vpq9lv+YroGdFxlf57X1m4py78mexGLXG e1vFEnLfiePQQJf+9Tr8S9aZdYZZvaAX2xKDh8yb7TXszgkSUMJTj8D39IRU5kfGGVJb VK7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:arc-authentication-results; bh=1vPSjLeCG9qnFL5V7V7kMlQfa4TCf1M6W7ReI4f3n3M=; b=a0I2hEthnpGGe061l8HtBVL/aEb5sATyWDsO1pdpkOqBECrArbp1g2oEAutXo98vYK eFNN8j9fM8VG2eLaCGcYjaGsmigLFZkBNkURxVuTbyko0B6tsOV3MYmAsHaptjFZZsbX z3juvZZJMBXQUUfhxrgc24F9wbN5GCfjcStCD/uFVuhoQ6YxNdkPOQRJWdM0wIaOxNvG MfJ8PYnPezzC/TdZ1ZCZpalrJsmvhBulQQ/nwR3sMY047TIz135pyA64w91xJi369a5/ AOFum2pOi4lI8sp/UShRj747FXk/vbE+iVsN3Yl3r6b6g7I2ct3HqBPjYWbM/D/X7i9c 95gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si11681374pgs.404.2018.05.24.19.47.38; Thu, 24 May 2018 19:47:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971774AbeEYAGH (ORCPT + 99 others); Thu, 24 May 2018 20:06:07 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58524 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S970097AbeEYAFp (ORCPT ); Thu, 24 May 2018 20:05:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AEE4F80825A5; Fri, 25 May 2018 00:05:44 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-255.rdu2.redhat.com [10.10.120.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB94120290D5; Fri, 25 May 2018 00:05:43 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 03/32] VFS: Introduce the basic header for the new mount API's filesystem context [ver #8] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 25 May 2018 01:05:43 +0100 Message-ID: <152720674345.9073.7664682296580266598.stgit@warthog.procyon.org.uk> In-Reply-To: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> References: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 25 May 2018 00:05:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 25 May 2018 00:05:44 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a filesystem context concept to be used during superblock creation for mount and superblock reconfiguration for remount. This is allocated at the beginning of the mount procedure and into it is placed: (1) Filesystem type. (2) Namespaces. (3) Source/Device names (there may be multiple). (4) Superblock flags (SB_*). (5) Security details. (6) Filesystem-specific data, as set by the mount options. Signed-off-by: David Howells --- include/linux/fs_context.h | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 include/linux/fs_context.h diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h new file mode 100644 index 000000000000..04783814632c --- /dev/null +++ b/include/linux/fs_context.h @@ -0,0 +1,75 @@ +/* Filesystem superblock creation and reconfiguration context. + * + * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public Licence + * as published by the Free Software Foundation; either version + * 2 of the Licence, or (at your option) any later version. + */ + +#ifndef _LINUX_FS_CONTEXT_H +#define _LINUX_FS_CONTEXT_H + +#include +#include + +struct cred; +struct dentry; +struct file_operations; +struct file_system_type; +struct mnt_namespace; +struct net; +struct pid_namespace; +struct super_block; +struct user_namespace; +struct vfsmount; + +enum fs_context_purpose { + FS_CONTEXT_FOR_USER_MOUNT, /* New superblock for user-specified mount */ + FS_CONTEXT_FOR_KERNEL_MOUNT, /* New superblock for kernel-internal mount */ + FS_CONTEXT_FOR_SUBMOUNT, /* New superblock for automatic submount */ + FS_CONTEXT_FOR_RECONFIGURE, /* Superblock reconfiguration (remount) */ +}; + +/* + * Filesystem context for holding the parameters used in the creation or + * reconfiguration of a superblock. + * + * Superblock creation fills in ->root whereas reconfiguration begins with this + * already set. + * + * See Documentation/filesystems/mounting.txt + */ +struct fs_context { + const struct fs_context_operations *ops; + struct file_system_type *fs_type; + void *fs_private; /* The filesystem's context */ + struct dentry *root; /* The root and superblock */ + struct user_namespace *user_ns; /* The user namespace for this mount */ + struct net *net_ns; /* The network namespace for this mount */ + const struct cred *cred; /* The mounter's credentials */ + char *source; /* The source name (eg. dev path) */ + char *subtype; /* The subtype to set on the superblock */ + void *security; /* The LSM context */ + void *s_fs_info; /* Proposed s_fs_info */ + unsigned int sb_flags; /* Proposed superblock flags (SB_*) */ + bool sloppy:1; /* T if unrecognised options are okay */ + bool silent:1; /* T if "o silent" specified */ + bool drop_sb:1; /* T if need to drop an SB reference */ + bool source_is_dev:1; /* T if source is local device/file */ + enum fs_context_purpose purpose : 8; +}; + +struct fs_context_operations { + void (*free)(struct fs_context *fc); + int (*dup)(struct fs_context *fc, struct fs_context *src_fc); + int (*parse_source)(struct fs_context *fc, char *source); + int (*parse_option)(struct fs_context *fc, char *opt, size_t len); + int (*parse_monolithic)(struct fs_context *fc, void *data); + int (*validate)(struct fs_context *fc); + int (*get_tree)(struct fs_context *fc); +}; + +#endif /* _LINUX_FS_CONTEXT_H */