docs: filesystems: convert mount_api.txt to ReST
- Add a SPDX header; - Adjust document and section titles; - Some whitespace fixes and new line breaks; - Mark literal blocks as such; - Add table markups; - Add lists markups; - Add it to filesystems/index.rst. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/32332c1659a28c22561cb5e64162c959856066b4.1588021877.git.mchehab+huawei@kernel.org Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
parent
a02dcdf65b
commit
791a17ee19
@ -30,6 +30,7 @@ algorithms work.
|
|||||||
files
|
files
|
||||||
locks
|
locks
|
||||||
mandatory-locking
|
mandatory-locking
|
||||||
|
mount_api
|
||||||
|
|
||||||
automount-support
|
automount-support
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
.. SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
====================
|
====================
|
||||||
FILESYSTEM MOUNT API
|
fILESYSTEM Mount API
|
||||||
====================
|
====================
|
||||||
|
|
||||||
CONTENTS
|
.. CONTENTS
|
||||||
|
|
||||||
(1) Overview.
|
(1) Overview.
|
||||||
|
|
||||||
@ -21,8 +23,7 @@ CONTENTS
|
|||||||
(8) Parameter helper functions.
|
(8) Parameter helper functions.
|
||||||
|
|
||||||
|
|
||||||
========
|
Overview
|
||||||
OVERVIEW
|
|
||||||
========
|
========
|
||||||
|
|
||||||
The creation of new mounts is now to be done in a multistep process:
|
The creation of new mounts is now to be done in a multistep process:
|
||||||
@ -43,7 +44,7 @@ The creation of new mounts is now to be done in a multistep process:
|
|||||||
|
|
||||||
(7) Destroy the context.
|
(7) Destroy the context.
|
||||||
|
|
||||||
To support this, the file_system_type struct gains two new fields:
|
To support this, the file_system_type struct gains two new fields::
|
||||||
|
|
||||||
int (*init_fs_context)(struct fs_context *fc);
|
int (*init_fs_context)(struct fs_context *fc);
|
||||||
const struct fs_parameter_description *parameters;
|
const struct fs_parameter_description *parameters;
|
||||||
@ -57,12 +58,11 @@ Note that security initialisation is done *after* the filesystem is called so
|
|||||||
that the namespaces may be adjusted first.
|
that the namespaces may be adjusted first.
|
||||||
|
|
||||||
|
|
||||||
======================
|
The Filesystem context
|
||||||
THE FILESYSTEM CONTEXT
|
|
||||||
======================
|
======================
|
||||||
|
|
||||||
The creation and reconfiguration of a superblock is governed by a filesystem
|
The creation and reconfiguration of a superblock is governed by a filesystem
|
||||||
context. This is represented by the fs_context structure:
|
context. This is represented by the fs_context structure::
|
||||||
|
|
||||||
struct fs_context {
|
struct fs_context {
|
||||||
const struct fs_context_operations *ops;
|
const struct fs_context_operations *ops;
|
||||||
@ -86,78 +86,106 @@ context. This is represented by the fs_context structure:
|
|||||||
|
|
||||||
The fs_context fields are as follows:
|
The fs_context fields are as follows:
|
||||||
|
|
||||||
(*) const struct fs_context_operations *ops
|
* ::
|
||||||
|
|
||||||
|
const struct fs_context_operations *ops
|
||||||
|
|
||||||
These are operations that can be done on a filesystem context (see
|
These are operations that can be done on a filesystem context (see
|
||||||
below). This must be set by the ->init_fs_context() file_system_type
|
below). This must be set by the ->init_fs_context() file_system_type
|
||||||
operation.
|
operation.
|
||||||
|
|
||||||
(*) struct file_system_type *fs_type
|
* ::
|
||||||
|
|
||||||
|
struct file_system_type *fs_type
|
||||||
|
|
||||||
A pointer to the file_system_type of the filesystem that is being
|
A pointer to the file_system_type of the filesystem that is being
|
||||||
constructed or reconfigured. This retains a reference on the type owner.
|
constructed or reconfigured. This retains a reference on the type owner.
|
||||||
|
|
||||||
(*) void *fs_private
|
* ::
|
||||||
|
|
||||||
|
void *fs_private
|
||||||
|
|
||||||
A pointer to the file system's private data. This is where the filesystem
|
A pointer to the file system's private data. This is where the filesystem
|
||||||
will need to store any options it parses.
|
will need to store any options it parses.
|
||||||
|
|
||||||
(*) struct dentry *root
|
* ::
|
||||||
|
|
||||||
|
struct dentry *root
|
||||||
|
|
||||||
A pointer to the root of the mountable tree (and indirectly, the
|
A pointer to the root of the mountable tree (and indirectly, the
|
||||||
superblock thereof). This is filled in by the ->get_tree() op. If this
|
superblock thereof). This is filled in by the ->get_tree() op. If this
|
||||||
is set, an active reference on root->d_sb must also be held.
|
is set, an active reference on root->d_sb must also be held.
|
||||||
|
|
||||||
(*) struct user_namespace *user_ns
|
* ::
|
||||||
(*) struct net *net_ns
|
|
||||||
|
struct user_namespace *user_ns
|
||||||
|
struct net *net_ns
|
||||||
|
|
||||||
There are a subset of the namespaces in use by the invoking process. They
|
There are a subset of the namespaces in use by the invoking process. They
|
||||||
retain references on each namespace. The subscribed namespaces may be
|
retain references on each namespace. The subscribed namespaces may be
|
||||||
replaced by the filesystem to reflect other sources, such as the parent
|
replaced by the filesystem to reflect other sources, such as the parent
|
||||||
mount superblock on an automount.
|
mount superblock on an automount.
|
||||||
|
|
||||||
(*) const struct cred *cred
|
* ::
|
||||||
|
|
||||||
|
const struct cred *cred
|
||||||
|
|
||||||
The mounter's credentials. This retains a reference on the credentials.
|
The mounter's credentials. This retains a reference on the credentials.
|
||||||
|
|
||||||
(*) char *source
|
* ::
|
||||||
|
|
||||||
|
char *source
|
||||||
|
|
||||||
This specifies the source. It may be a block device (e.g. /dev/sda1) or
|
This specifies the source. It may be a block device (e.g. /dev/sda1) or
|
||||||
something more exotic, such as the "host:/path" that NFS desires.
|
something more exotic, such as the "host:/path" that NFS desires.
|
||||||
|
|
||||||
(*) char *subtype
|
* ::
|
||||||
|
|
||||||
|
char *subtype
|
||||||
|
|
||||||
This is a string to be added to the type displayed in /proc/mounts to
|
This is a string to be added to the type displayed in /proc/mounts to
|
||||||
qualify it (used by FUSE). This is available for the filesystem to set if
|
qualify it (used by FUSE). This is available for the filesystem to set if
|
||||||
desired.
|
desired.
|
||||||
|
|
||||||
(*) void *security
|
* ::
|
||||||
|
|
||||||
|
void *security
|
||||||
|
|
||||||
A place for the LSMs to hang their security data for the superblock. The
|
A place for the LSMs to hang their security data for the superblock. The
|
||||||
relevant security operations are described below.
|
relevant security operations are described below.
|
||||||
|
|
||||||
(*) void *s_fs_info
|
* ::
|
||||||
|
|
||||||
|
void *s_fs_info
|
||||||
|
|
||||||
The proposed s_fs_info for a new superblock, set in the superblock by
|
The proposed s_fs_info for a new superblock, set in the superblock by
|
||||||
sget_fc(). This can be used to distinguish superblocks.
|
sget_fc(). This can be used to distinguish superblocks.
|
||||||
|
|
||||||
(*) unsigned int sb_flags
|
* ::
|
||||||
(*) unsigned int sb_flags_mask
|
|
||||||
|
unsigned int sb_flags
|
||||||
|
unsigned int sb_flags_mask
|
||||||
|
|
||||||
Which bits SB_* flags are to be set/cleared in super_block::s_flags.
|
Which bits SB_* flags are to be set/cleared in super_block::s_flags.
|
||||||
|
|
||||||
(*) unsigned int s_iflags
|
* ::
|
||||||
|
|
||||||
|
unsigned int s_iflags
|
||||||
|
|
||||||
These will be bitwise-OR'd with s->s_iflags when a superblock is created.
|
These will be bitwise-OR'd with s->s_iflags when a superblock is created.
|
||||||
|
|
||||||
(*) enum fs_context_purpose
|
* ::
|
||||||
|
|
||||||
|
enum fs_context_purpose
|
||||||
|
|
||||||
This indicates the purpose for which the context is intended. The
|
This indicates the purpose for which the context is intended. The
|
||||||
available values are:
|
available values are:
|
||||||
|
|
||||||
FS_CONTEXT_FOR_MOUNT, -- New superblock for explicit mount
|
========================== ======================================
|
||||||
FS_CONTEXT_FOR_SUBMOUNT -- New automatic submount of extant mount
|
FS_CONTEXT_FOR_MOUNT, New superblock for explicit mount
|
||||||
FS_CONTEXT_FOR_RECONFIGURE -- Change an existing mount
|
FS_CONTEXT_FOR_SUBMOUNT New automatic submount of extant mount
|
||||||
|
FS_CONTEXT_FOR_RECONFIGURE Change an existing mount
|
||||||
|
========================== ======================================
|
||||||
|
|
||||||
The mount context is created by calling vfs_new_fs_context() or
|
The mount context is created by calling vfs_new_fs_context() or
|
||||||
vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the
|
vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the
|
||||||
@ -176,11 +204,10 @@ mount context. For instance, NFS might pin the appropriate protocol version
|
|||||||
module.
|
module.
|
||||||
|
|
||||||
|
|
||||||
=================================
|
The Filesystem Context Operations
|
||||||
THE FILESYSTEM CONTEXT OPERATIONS
|
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
The filesystem context points to a table of operations:
|
The filesystem context points to a table of operations::
|
||||||
|
|
||||||
struct fs_context_operations {
|
struct fs_context_operations {
|
||||||
void (*free)(struct fs_context *fc);
|
void (*free)(struct fs_context *fc);
|
||||||
@ -195,23 +222,31 @@ The filesystem context points to a table of operations:
|
|||||||
These operations are invoked by the various stages of the mount procedure to
|
These operations are invoked by the various stages of the mount procedure to
|
||||||
manage the filesystem context. They are as follows:
|
manage the filesystem context. They are as follows:
|
||||||
|
|
||||||
(*) void (*free)(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
void (*free)(struct fs_context *fc);
|
||||||
|
|
||||||
Called to clean up the filesystem-specific part of the filesystem context
|
Called to clean up the filesystem-specific part of the filesystem context
|
||||||
when the context is destroyed. It should be aware that parts of the
|
when the context is destroyed. It should be aware that parts of the
|
||||||
context may have been removed and NULL'd out by ->get_tree().
|
context may have been removed and NULL'd out by ->get_tree().
|
||||||
|
|
||||||
(*) int (*dup)(struct fs_context *fc, struct fs_context *src_fc);
|
* ::
|
||||||
|
|
||||||
|
int (*dup)(struct fs_context *fc, struct fs_context *src_fc);
|
||||||
|
|
||||||
Called when a filesystem context has been duplicated to duplicate the
|
Called when a filesystem context has been duplicated to duplicate the
|
||||||
filesystem-private data. An error may be returned to indicate failure to
|
filesystem-private data. An error may be returned to indicate failure to
|
||||||
do this.
|
do this.
|
||||||
|
|
||||||
[!] Note that even if this fails, put_fs_context() will be called
|
.. Warning::
|
||||||
|
|
||||||
|
Note that even if this fails, put_fs_context() will be called
|
||||||
immediately thereafter, so ->dup() *must* make the
|
immediately thereafter, so ->dup() *must* make the
|
||||||
filesystem-private data safe for ->free().
|
filesystem-private data safe for ->free().
|
||||||
|
|
||||||
(*) int (*parse_param)(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int (*parse_param)(struct fs_context *fc,
|
||||||
struct struct fs_parameter *param);
|
struct struct fs_parameter *param);
|
||||||
|
|
||||||
Called when a parameter is being added to the filesystem context. param
|
Called when a parameter is being added to the filesystem context. param
|
||||||
@ -224,7 +259,9 @@ manage the filesystem context. They are as follows:
|
|||||||
|
|
||||||
If successful, 0 should be returned or a negative error code otherwise.
|
If successful, 0 should be returned or a negative error code otherwise.
|
||||||
|
|
||||||
(*) int (*parse_monolithic)(struct fs_context *fc, void *data);
|
* ::
|
||||||
|
|
||||||
|
int (*parse_monolithic)(struct fs_context *fc, void *data);
|
||||||
|
|
||||||
Called when the mount(2) system call is invoked to pass the entire data
|
Called when the mount(2) system call is invoked to pass the entire data
|
||||||
page in one go. If this is expected to be just a list of "key[=val]"
|
page in one go. If this is expected to be just a list of "key[=val]"
|
||||||
@ -236,7 +273,9 @@ manage the filesystem context. They are as follows:
|
|||||||
finds it's the standard key-val list then it may pass it off to
|
finds it's the standard key-val list then it may pass it off to
|
||||||
generic_parse_monolithic().
|
generic_parse_monolithic().
|
||||||
|
|
||||||
(*) int (*get_tree)(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
int (*get_tree)(struct fs_context *fc);
|
||||||
|
|
||||||
Called to get or create the mountable root and superblock, using the
|
Called to get or create the mountable root and superblock, using the
|
||||||
information stored in the filesystem context (reconfiguration goes via a
|
information stored in the filesystem context (reconfiguration goes via a
|
||||||
@ -249,7 +288,9 @@ manage the filesystem context. They are as follows:
|
|||||||
The phase on a userspace-driven context will be set to only allow this to
|
The phase on a userspace-driven context will be set to only allow this to
|
||||||
be called once on any particular context.
|
be called once on any particular context.
|
||||||
|
|
||||||
(*) int (*reconfigure)(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
int (*reconfigure)(struct fs_context *fc);
|
||||||
|
|
||||||
Called to effect reconfiguration of a superblock using information stored
|
Called to effect reconfiguration of a superblock using information stored
|
||||||
in the filesystem context. It may detach any resources it desires from
|
in the filesystem context. It may detach any resources it desires from
|
||||||
@ -259,18 +300,19 @@ manage the filesystem context. They are as follows:
|
|||||||
On success it should return 0. In the case of an error, it should return
|
On success it should return 0. In the case of an error, it should return
|
||||||
a negative error code.
|
a negative error code.
|
||||||
|
|
||||||
[NOTE] reconfigure is intended as a replacement for remount_fs.
|
.. Note:: reconfigure is intended as a replacement for remount_fs.
|
||||||
|
|
||||||
|
|
||||||
===========================
|
Filesystem context Security
|
||||||
FILESYSTEM CONTEXT SECURITY
|
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
The filesystem context contains a security pointer that the LSMs can use for
|
The filesystem context contains a security pointer that the LSMs can use for
|
||||||
building up a security context for the superblock to be mounted. There are a
|
building up a security context for the superblock to be mounted. There are a
|
||||||
number of operations used by the new mount code for this purpose:
|
number of operations used by the new mount code for this purpose:
|
||||||
|
|
||||||
(*) int security_fs_context_alloc(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int security_fs_context_alloc(struct fs_context *fc,
|
||||||
struct dentry *reference);
|
struct dentry *reference);
|
||||||
|
|
||||||
Called to initialise fc->security (which is preset to NULL) and allocate
|
Called to initialise fc->security (which is preset to NULL) and allocate
|
||||||
@ -283,7 +325,9 @@ number of operations used by the new mount code for this purpose:
|
|||||||
non-NULL in the case of a submount (FS_CONTEXT_FOR_SUBMOUNT) in which case
|
non-NULL in the case of a submount (FS_CONTEXT_FOR_SUBMOUNT) in which case
|
||||||
it indicates the automount point.
|
it indicates the automount point.
|
||||||
|
|
||||||
(*) int security_fs_context_dup(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int security_fs_context_dup(struct fs_context *fc,
|
||||||
struct fs_context *src_fc);
|
struct fs_context *src_fc);
|
||||||
|
|
||||||
Called to initialise fc->security (which is preset to NULL) and allocate
|
Called to initialise fc->security (which is preset to NULL) and allocate
|
||||||
@ -291,13 +335,17 @@ number of operations used by the new mount code for this purpose:
|
|||||||
src_fc and may be used for reference. It should return 0 on success or a
|
src_fc and may be used for reference. It should return 0 on success or a
|
||||||
negative error code on failure.
|
negative error code on failure.
|
||||||
|
|
||||||
(*) void security_fs_context_free(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
void security_fs_context_free(struct fs_context *fc);
|
||||||
|
|
||||||
Called to clean up anything attached to fc->security. Note that the
|
Called to clean up anything attached to fc->security. Note that the
|
||||||
contents may have been transferred to a superblock and the pointer cleared
|
contents may have been transferred to a superblock and the pointer cleared
|
||||||
during get_tree.
|
during get_tree.
|
||||||
|
|
||||||
(*) int security_fs_context_parse_param(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int security_fs_context_parse_param(struct fs_context *fc,
|
||||||
struct fs_parameter *param);
|
struct fs_parameter *param);
|
||||||
|
|
||||||
Called for each mount parameter, including the source. The arguments are
|
Called for each mount parameter, including the source. The arguments are
|
||||||
@ -310,7 +358,9 @@ number of operations used by the new mount code for this purpose:
|
|||||||
(provided the value pointer is NULL'd out). If it is stolen, 1 must be
|
(provided the value pointer is NULL'd out). If it is stolen, 1 must be
|
||||||
returned to prevent it being passed to the filesystem.
|
returned to prevent it being passed to the filesystem.
|
||||||
|
|
||||||
(*) int security_fs_context_validate(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
int security_fs_context_validate(struct fs_context *fc);
|
||||||
|
|
||||||
Called after all the options have been parsed to validate the collection
|
Called after all the options have been parsed to validate the collection
|
||||||
as a whole and to do any necessary allocation so that
|
as a whole and to do any necessary allocation so that
|
||||||
@ -320,19 +370,26 @@ number of operations used by the new mount code for this purpose:
|
|||||||
In the case of reconfiguration, the target superblock will be accessible
|
In the case of reconfiguration, the target superblock will be accessible
|
||||||
via fc->root.
|
via fc->root.
|
||||||
|
|
||||||
(*) int security_sb_get_tree(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
int security_sb_get_tree(struct fs_context *fc);
|
||||||
|
|
||||||
Called during the mount procedure to verify that the specified superblock
|
Called during the mount procedure to verify that the specified superblock
|
||||||
is allowed to be mounted and to transfer the security data there. It
|
is allowed to be mounted and to transfer the security data there. It
|
||||||
should return 0 or a negative error code.
|
should return 0 or a negative error code.
|
||||||
|
|
||||||
(*) void security_sb_reconfigure(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
void security_sb_reconfigure(struct fs_context *fc);
|
||||||
|
|
||||||
Called to apply any reconfiguration to an LSM's context. It must not
|
Called to apply any reconfiguration to an LSM's context. It must not
|
||||||
fail. Error checking and resource allocation must be done in advance by
|
fail. Error checking and resource allocation must be done in advance by
|
||||||
the parameter parsing and validation hooks.
|
the parameter parsing and validation hooks.
|
||||||
|
|
||||||
(*) int security_sb_mountpoint(struct fs_context *fc, struct path *mountpoint,
|
* ::
|
||||||
|
|
||||||
|
int security_sb_mountpoint(struct fs_context *fc,
|
||||||
|
struct path *mountpoint,
|
||||||
unsigned int mnt_flags);
|
unsigned int mnt_flags);
|
||||||
|
|
||||||
Called during the mount procedure to verify that the root dentry attached
|
Called during the mount procedure to verify that the root dentry attached
|
||||||
@ -340,15 +397,15 @@ number of operations used by the new mount code for this purpose:
|
|||||||
It should return 0 on success or a negative error code on failure.
|
It should return 0 on success or a negative error code on failure.
|
||||||
|
|
||||||
|
|
||||||
==========================
|
VFS Filesystem context API
|
||||||
VFS FILESYSTEM CONTEXT API
|
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
There are four operations for creating a filesystem context and one for
|
There are four operations for creating a filesystem context and one for
|
||||||
destroying a context:
|
destroying a context:
|
||||||
|
|
||||||
(*) struct fs_context *fs_context_for_mount(
|
* ::
|
||||||
struct file_system_type *fs_type,
|
|
||||||
|
struct fs_context *fs_context_for_mount(struct file_system_type *fs_type,
|
||||||
unsigned int sb_flags);
|
unsigned int sb_flags);
|
||||||
|
|
||||||
Allocate a filesystem context for the purpose of setting up a new mount,
|
Allocate a filesystem context for the purpose of setting up a new mount,
|
||||||
@ -359,7 +416,9 @@ destroying a context:
|
|||||||
fs_type specifies the filesystem type that will manage the context and
|
fs_type specifies the filesystem type that will manage the context and
|
||||||
sb_flags presets the superblock flags stored therein.
|
sb_flags presets the superblock flags stored therein.
|
||||||
|
|
||||||
(*) struct fs_context *fs_context_for_reconfigure(
|
* ::
|
||||||
|
|
||||||
|
struct fs_context *fs_context_for_reconfigure(
|
||||||
struct dentry *dentry,
|
struct dentry *dentry,
|
||||||
unsigned int sb_flags,
|
unsigned int sb_flags,
|
||||||
unsigned int sb_flags_mask);
|
unsigned int sb_flags_mask);
|
||||||
@ -369,7 +428,9 @@ destroying a context:
|
|||||||
configured. sb_flags and sb_flags_mask indicate which superblock flags
|
configured. sb_flags and sb_flags_mask indicate which superblock flags
|
||||||
need changing and to what.
|
need changing and to what.
|
||||||
|
|
||||||
(*) struct fs_context *fs_context_for_submount(
|
* ::
|
||||||
|
|
||||||
|
struct fs_context *fs_context_for_submount(
|
||||||
struct file_system_type *fs_type,
|
struct file_system_type *fs_type,
|
||||||
struct dentry *reference);
|
struct dentry *reference);
|
||||||
|
|
||||||
@ -382,7 +443,9 @@ destroying a context:
|
|||||||
Note that it's not a requirement that the reference dentry be of the same
|
Note that it's not a requirement that the reference dentry be of the same
|
||||||
filesystem type as fs_type.
|
filesystem type as fs_type.
|
||||||
|
|
||||||
(*) struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc);
|
* ::
|
||||||
|
|
||||||
|
struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc);
|
||||||
|
|
||||||
Duplicate a filesystem context, copying any options noted and duplicating
|
Duplicate a filesystem context, copying any options noted and duplicating
|
||||||
or additionally referencing any resources held therein. This is available
|
or additionally referencing any resources held therein. This is available
|
||||||
@ -392,13 +455,17 @@ destroying a context:
|
|||||||
|
|
||||||
The purpose in the new context is inherited from the old one.
|
The purpose in the new context is inherited from the old one.
|
||||||
|
|
||||||
(*) void put_fs_context(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
void put_fs_context(struct fs_context *fc);
|
||||||
|
|
||||||
Destroy a filesystem context, releasing any resources it holds. This
|
Destroy a filesystem context, releasing any resources it holds. This
|
||||||
calls the ->free() operation. This is intended to be called by anyone who
|
calls the ->free() operation. This is intended to be called by anyone who
|
||||||
created a filesystem context.
|
created a filesystem context.
|
||||||
|
|
||||||
[!] filesystem contexts are not refcounted, so this causes unconditional
|
.. Warning::
|
||||||
|
|
||||||
|
filesystem contexts are not refcounted, so this causes unconditional
|
||||||
destruction.
|
destruction.
|
||||||
|
|
||||||
In all the above operations, apart from the put op, the return is a mount
|
In all the above operations, apart from the put op, the return is a mount
|
||||||
@ -407,7 +474,9 @@ context pointer or a negative error code.
|
|||||||
For the remaining operations, if an error occurs, a negative error code will be
|
For the remaining operations, if an error occurs, a negative error code will be
|
||||||
returned.
|
returned.
|
||||||
|
|
||||||
(*) int vfs_parse_fs_param(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int vfs_parse_fs_param(struct fs_context *fc,
|
||||||
struct fs_parameter *param);
|
struct fs_parameter *param);
|
||||||
|
|
||||||
Supply a single mount parameter to the filesystem context. This include
|
Supply a single mount parameter to the filesystem context. This include
|
||||||
@ -423,50 +492,61 @@ returned.
|
|||||||
|
|
||||||
The parameter value is typed and can be one of:
|
The parameter value is typed and can be one of:
|
||||||
|
|
||||||
fs_value_is_flag, Parameter not given a value.
|
==================== =============================
|
||||||
fs_value_is_string, Value is a string
|
fs_value_is_flag Parameter not given a value
|
||||||
fs_value_is_blob, Value is a binary blob
|
fs_value_is_string Value is a string
|
||||||
fs_value_is_filename, Value is a filename* + dirfd
|
fs_value_is_blob Value is a binary blob
|
||||||
fs_value_is_file, Value is an open file (file*)
|
fs_value_is_filename Value is a filename* + dirfd
|
||||||
|
fs_value_is_file Value is an open file (file*)
|
||||||
|
==================== =============================
|
||||||
|
|
||||||
If there is a value, that value is stored in a union in the struct in one
|
If there is a value, that value is stored in a union in the struct in one
|
||||||
of param->{string,blob,name,file}. Note that the function may steal and
|
of param->{string,blob,name,file}. Note that the function may steal and
|
||||||
clear the pointer, but then becomes responsible for disposing of the
|
clear the pointer, but then becomes responsible for disposing of the
|
||||||
object.
|
object.
|
||||||
|
|
||||||
(*) int vfs_parse_fs_string(struct fs_context *fc, const char *key,
|
* ::
|
||||||
|
|
||||||
|
int vfs_parse_fs_string(struct fs_context *fc, const char *key,
|
||||||
const char *value, size_t v_size);
|
const char *value, size_t v_size);
|
||||||
|
|
||||||
A wrapper around vfs_parse_fs_param() that copies the value string it is
|
A wrapper around vfs_parse_fs_param() that copies the value string it is
|
||||||
passed.
|
passed.
|
||||||
|
|
||||||
(*) int generic_parse_monolithic(struct fs_context *fc, void *data);
|
* ::
|
||||||
|
|
||||||
|
int generic_parse_monolithic(struct fs_context *fc, void *data);
|
||||||
|
|
||||||
Parse a sys_mount() data page, assuming the form to be a text list
|
Parse a sys_mount() data page, assuming the form to be a text list
|
||||||
consisting of key[=val] options separated by commas. Each item in the
|
consisting of key[=val] options separated by commas. Each item in the
|
||||||
list is passed to vfs_mount_option(). This is the default when the
|
list is passed to vfs_mount_option(). This is the default when the
|
||||||
->parse_monolithic() method is NULL.
|
->parse_monolithic() method is NULL.
|
||||||
|
|
||||||
(*) int vfs_get_tree(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
int vfs_get_tree(struct fs_context *fc);
|
||||||
|
|
||||||
Get or create the mountable root and superblock, using the parameters in
|
Get or create the mountable root and superblock, using the parameters in
|
||||||
the filesystem context to select/configure the superblock. This invokes
|
the filesystem context to select/configure the superblock. This invokes
|
||||||
the ->get_tree() method.
|
the ->get_tree() method.
|
||||||
|
|
||||||
(*) struct vfsmount *vfs_create_mount(struct fs_context *fc);
|
* ::
|
||||||
|
|
||||||
|
struct vfsmount *vfs_create_mount(struct fs_context *fc);
|
||||||
|
|
||||||
Create a mount given the parameters in the specified filesystem context.
|
Create a mount given the parameters in the specified filesystem context.
|
||||||
Note that this does not attach the mount to anything.
|
Note that this does not attach the mount to anything.
|
||||||
|
|
||||||
|
|
||||||
===========================
|
Superblock Creation Helpers
|
||||||
SUPERBLOCK CREATION HELPERS
|
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
A number of VFS helpers are available for use by filesystems for the creation
|
A number of VFS helpers are available for use by filesystems for the creation
|
||||||
or looking up of superblocks.
|
or looking up of superblocks.
|
||||||
|
|
||||||
(*) struct super_block *
|
* ::
|
||||||
|
|
||||||
|
struct super_block *
|
||||||
sget_fc(struct fs_context *fc,
|
sget_fc(struct fs_context *fc,
|
||||||
int (*test)(struct super_block *sb, struct fs_context *fc),
|
int (*test)(struct super_block *sb, struct fs_context *fc),
|
||||||
int (*set)(struct super_block *sb, struct fs_context *fc));
|
int (*set)(struct super_block *sb, struct fs_context *fc));
|
||||||
@ -482,7 +562,9 @@ or looking up of superblocks.
|
|||||||
|
|
||||||
The following helpers all wrap sget_fc():
|
The following helpers all wrap sget_fc():
|
||||||
|
|
||||||
(*) int vfs_get_super(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int vfs_get_super(struct fs_context *fc,
|
||||||
enum vfs_get_super_keying keying,
|
enum vfs_get_super_keying keying,
|
||||||
int (*fill_super)(struct super_block *sb,
|
int (*fill_super)(struct super_block *sb,
|
||||||
struct fs_context *fc))
|
struct fs_context *fc))
|
||||||
@ -515,14 +597,14 @@ PARAMETER DESCRIPTION
|
|||||||
=====================
|
=====================
|
||||||
|
|
||||||
Parameters are described using structures defined in linux/fs_parser.h.
|
Parameters are described using structures defined in linux/fs_parser.h.
|
||||||
There's a core description struct that links everything together:
|
There's a core description struct that links everything together::
|
||||||
|
|
||||||
struct fs_parameter_description {
|
struct fs_parameter_description {
|
||||||
const struct fs_parameter_spec *specs;
|
const struct fs_parameter_spec *specs;
|
||||||
const struct fs_parameter_enum *enums;
|
const struct fs_parameter_enum *enums;
|
||||||
};
|
};
|
||||||
|
|
||||||
For example:
|
For example::
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Opt_autocell,
|
Opt_autocell,
|
||||||
@ -539,10 +621,12 @@ For example:
|
|||||||
|
|
||||||
The members are as follows:
|
The members are as follows:
|
||||||
|
|
||||||
(1) const struct fs_parameter_specification *specs;
|
(1) ::
|
||||||
|
|
||||||
|
const struct fs_parameter_specification *specs;
|
||||||
|
|
||||||
Table of parameter specifications, terminated with a null entry, where the
|
Table of parameter specifications, terminated with a null entry, where the
|
||||||
entries are of type:
|
entries are of type::
|
||||||
|
|
||||||
struct fs_parameter_spec {
|
struct fs_parameter_spec {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -558,6 +642,7 @@ The members are as follows:
|
|||||||
|
|
||||||
The 'type' field indicates the desired value type and must be one of:
|
The 'type' field indicates the desired value type and must be one of:
|
||||||
|
|
||||||
|
======================= ======================= =====================
|
||||||
TYPE NAME EXPECTED VALUE RESULT IN
|
TYPE NAME EXPECTED VALUE RESULT IN
|
||||||
======================= ======================= =====================
|
======================= ======================= =====================
|
||||||
fs_param_is_flag No value n/a
|
fs_param_is_flag No value n/a
|
||||||
@ -573,19 +658,23 @@ The members are as follows:
|
|||||||
fs_param_is_blockdev Blockdev path * Needs lookup
|
fs_param_is_blockdev Blockdev path * Needs lookup
|
||||||
fs_param_is_path Path * Needs lookup
|
fs_param_is_path Path * Needs lookup
|
||||||
fs_param_is_fd File descriptor result->int_32
|
fs_param_is_fd File descriptor result->int_32
|
||||||
|
======================= ======================= =====================
|
||||||
|
|
||||||
Note that if the value is of fs_param_is_bool type, fs_parse() will try
|
Note that if the value is of fs_param_is_bool type, fs_parse() will try
|
||||||
to match any string value against "0", "1", "no", "yes", "false", "true".
|
to match any string value against "0", "1", "no", "yes", "false", "true".
|
||||||
|
|
||||||
Each parameter can also be qualified with 'flags':
|
Each parameter can also be qualified with 'flags':
|
||||||
|
|
||||||
|
======================= ================================================
|
||||||
fs_param_v_optional The value is optional
|
fs_param_v_optional The value is optional
|
||||||
fs_param_neg_with_no result->negated set if key is prefixed with "no"
|
fs_param_neg_with_no result->negated set if key is prefixed with "no"
|
||||||
fs_param_neg_with_empty result->negated set if value is ""
|
fs_param_neg_with_empty result->negated set if value is ""
|
||||||
fs_param_deprecated The parameter is deprecated.
|
fs_param_deprecated The parameter is deprecated.
|
||||||
|
======================= ================================================
|
||||||
|
|
||||||
These are wrapped with a number of convenience wrappers:
|
These are wrapped with a number of convenience wrappers:
|
||||||
|
|
||||||
|
======================= ===============================================
|
||||||
MACRO SPECIFIES
|
MACRO SPECIFIES
|
||||||
======================= ===============================================
|
======================= ===============================================
|
||||||
fsparam_flag() fs_param_is_flag
|
fsparam_flag() fs_param_is_flag
|
||||||
@ -602,9 +691,10 @@ The members are as follows:
|
|||||||
fsparam_bdev() fs_param_is_blockdev
|
fsparam_bdev() fs_param_is_blockdev
|
||||||
fsparam_path() fs_param_is_path
|
fsparam_path() fs_param_is_path
|
||||||
fsparam_fd() fs_param_is_fd
|
fsparam_fd() fs_param_is_fd
|
||||||
|
======================= ===============================================
|
||||||
|
|
||||||
all of which take two arguments, name string and option number - for
|
all of which take two arguments, name string and option number - for
|
||||||
example:
|
example::
|
||||||
|
|
||||||
static const struct fs_parameter_spec afs_param_specs[] = {
|
static const struct fs_parameter_spec afs_param_specs[] = {
|
||||||
fsparam_flag ("autocell", Opt_autocell),
|
fsparam_flag ("autocell", Opt_autocell),
|
||||||
@ -618,10 +708,12 @@ The members are as follows:
|
|||||||
of arguments to specify the type and the flags for anything that doesn't
|
of arguments to specify the type and the flags for anything that doesn't
|
||||||
match one of the above macros.
|
match one of the above macros.
|
||||||
|
|
||||||
(2) const struct fs_parameter_enum *enums;
|
(2) ::
|
||||||
|
|
||||||
|
const struct fs_parameter_enum *enums;
|
||||||
|
|
||||||
Table of enum value names to integer mappings, terminated with a null
|
Table of enum value names to integer mappings, terminated with a null
|
||||||
entry. This is of type:
|
entry. This is of type::
|
||||||
|
|
||||||
struct fs_parameter_enum {
|
struct fs_parameter_enum {
|
||||||
u8 opt;
|
u8 opt;
|
||||||
@ -630,7 +722,7 @@ The members are as follows:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Where the array is an unsorted list of { parameter ID, name }-keyed
|
Where the array is an unsorted list of { parameter ID, name }-keyed
|
||||||
elements that indicate the value to map to, e.g.:
|
elements that indicate the value to map to, e.g.::
|
||||||
|
|
||||||
static const struct fs_parameter_enum afs_param_enums[] = {
|
static const struct fs_parameter_enum afs_param_enums[] = {
|
||||||
{ Opt_bar, "x", 1},
|
{ Opt_bar, "x", 1},
|
||||||
@ -648,18 +740,19 @@ CONFIG_VALIDATE_FS_PARSER=y) and will allow the description to be queried from
|
|||||||
userspace using the fsinfo() syscall.
|
userspace using the fsinfo() syscall.
|
||||||
|
|
||||||
|
|
||||||
==========================
|
Parameter Helper Functions
|
||||||
PARAMETER HELPER FUNCTIONS
|
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
A number of helper functions are provided to help a filesystem or an LSM
|
A number of helper functions are provided to help a filesystem or an LSM
|
||||||
process the parameters it is given.
|
process the parameters it is given.
|
||||||
|
|
||||||
(*) int lookup_constant(const struct constant_table tbl[],
|
* ::
|
||||||
|
|
||||||
|
int lookup_constant(const struct constant_table tbl[],
|
||||||
const char *name, int not_found);
|
const char *name, int not_found);
|
||||||
|
|
||||||
Look up a constant by name in a table of name -> integer mappings. The
|
Look up a constant by name in a table of name -> integer mappings. The
|
||||||
table is an array of elements of the following type:
|
table is an array of elements of the following type::
|
||||||
|
|
||||||
struct constant_table {
|
struct constant_table {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -669,7 +762,9 @@ process the parameters it is given.
|
|||||||
If a match is found, the corresponding value is returned. If a match
|
If a match is found, the corresponding value is returned. If a match
|
||||||
isn't found, the not_found value is returned instead.
|
isn't found, the not_found value is returned instead.
|
||||||
|
|
||||||
(*) bool validate_constant_table(const struct constant_table *tbl,
|
* ::
|
||||||
|
|
||||||
|
bool validate_constant_table(const struct constant_table *tbl,
|
||||||
size_t tbl_size,
|
size_t tbl_size,
|
||||||
int low, int high, int special);
|
int low, int high, int special);
|
||||||
|
|
||||||
@ -682,13 +777,17 @@ process the parameters it is given.
|
|||||||
If all is good, true is returned. If the table is invalid, errors are
|
If all is good, true is returned. If the table is invalid, errors are
|
||||||
logged to dmesg and false is returned.
|
logged to dmesg and false is returned.
|
||||||
|
|
||||||
(*) bool fs_validate_description(const struct fs_parameter_description *desc);
|
* ::
|
||||||
|
|
||||||
|
bool fs_validate_description(const struct fs_parameter_description *desc);
|
||||||
|
|
||||||
This performs some validation checks on a parameter description. It
|
This performs some validation checks on a parameter description. It
|
||||||
returns true if the description is good and false if it is not. It will
|
returns true if the description is good and false if it is not. It will
|
||||||
log errors to dmesg if validation fails.
|
log errors to dmesg if validation fails.
|
||||||
|
|
||||||
(*) int fs_parse(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int fs_parse(struct fs_context *fc,
|
||||||
const struct fs_parameter_description *desc,
|
const struct fs_parameter_description *desc,
|
||||||
struct fs_parameter *param,
|
struct fs_parameter *param,
|
||||||
struct fs_parse_result *result);
|
struct fs_parse_result *result);
|
||||||
@ -711,7 +810,9 @@ process the parameters it is given.
|
|||||||
parameter is matched, but the value is erroneous, -EINVAL will be
|
parameter is matched, but the value is erroneous, -EINVAL will be
|
||||||
returned; otherwise the parameter's option number will be returned.
|
returned; otherwise the parameter's option number will be returned.
|
||||||
|
|
||||||
(*) int fs_lookup_param(struct fs_context *fc,
|
* ::
|
||||||
|
|
||||||
|
int fs_lookup_param(struct fs_context *fc,
|
||||||
struct fs_parameter *value,
|
struct fs_parameter *value,
|
||||||
bool want_bdev,
|
bool want_bdev,
|
||||||
struct path *_path);
|
struct path *_path);
|
||||||
@ -720,5 +821,5 @@ process the parameters it is given.
|
|||||||
to do a path lookup on it. If the parameter expects a blockdev, a check
|
to do a path lookup on it. If the parameter expects a blockdev, a check
|
||||||
is made that the inode actually represents one.
|
is made that the inode actually represents one.
|
||||||
|
|
||||||
Returns 0 if successful and *_path will be set; returns a negative error
|
Returns 0 if successful and ``*_path`` will be set; returns a negative
|
||||||
code if not.
|
error code if not.
|
@ -85,7 +85,7 @@ struct p_log {
|
|||||||
* Superblock creation fills in ->root whereas reconfiguration begins with this
|
* Superblock creation fills in ->root whereas reconfiguration begins with this
|
||||||
* already set.
|
* already set.
|
||||||
*
|
*
|
||||||
* See Documentation/filesystems/mount_api.txt
|
* See Documentation/filesystems/mount_api.rst
|
||||||
*/
|
*/
|
||||||
struct fs_context {
|
struct fs_context {
|
||||||
const struct fs_context_operations *ops;
|
const struct fs_context_operations *ops;
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
* state. This is called immediately after commit_creds().
|
* state. This is called immediately after commit_creds().
|
||||||
*
|
*
|
||||||
* Security hooks for mount using fs_context.
|
* Security hooks for mount using fs_context.
|
||||||
* [See also Documentation/filesystems/mount_api.txt]
|
* [See also Documentation/filesystems/mount_api.rst]
|
||||||
*
|
*
|
||||||
* @fs_context_dup:
|
* @fs_context_dup:
|
||||||
* Allocate and attach a security structure to sc->security. This pointer
|
* Allocate and attach a security structure to sc->security. This pointer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user