fspick
select filesystem for reconfiguration
- Provided by: manpages-dev (Version: 6.17-1)
- Source: manpages
- Report a bug
select filesystem for reconfiguration
Standard C library (libc, -lc)
#include <fcntl.h> /* Definition of AT_* constants */ #include <sys/mount.h>
int fspick(int dirfd, const char *path, unsigned int flags);
The fspick() system call is part of the suite of file-descriptor-based mount facilities in Linux.
fspick() creates a new filesystem configuration context for the extant filesystem instance associated with the path described by dirfd and path, places it into reconfiguration mode (similar to mount(8) with the -o remount option). A new file descriptor associated with the filesystem configuration context is then returned. The calling process must have the CAP_SYS_ADMIN capability in order to create a new filesystem configuration context.
The resultant file descriptor can be used with fsconfig(2) to specify the desired set of changes to filesystem parameters of the filesystem instance. Once the desired set of changes have been configured, the changes can be effectuated by calling fsconfig(2) with the FSCONFIG_CMD_RECONFIGURE command. In contrast to the behavior of MS_REMOUNT with mount(2), fspick() instantiates the filesystem configuration context with a copy of the extant filesystem's filesystem parameters; thus, subsequent FSCONFIG_CMD_RECONFIGURE operations will only update filesystem parameters explicitly modified with fsconfig(2).
As with "*at()" system calls, fspick() uses the dirfd argument in conjunction with the path argument to determine the path to operate on, as follows:
See openat(2) for an explanation of why the dirfd argument is useful.
flags can be used to control aspects of how path is resolved and properties of the returned file descriptor. A value for flags is constructed by bitwise ORing zero or more of the following constants:
As with filesystem contexts created with fsopen(2), the file descriptor returned by fspick() may be queried for message strings at any time by calling read(2) on the file descriptor. (See the "Message retrieval interface" subsection in fsopen(2) for more details on the message format.)
On success, a new file descriptor is returned. On error, -1 is returned, and errno is set to indicate the error.
Linux.
Linux 5.2. glibc 2.36.
The following example sets the read-only flag on the filesystem instance referenced by the mount object attached at /tmp.
int fsfd = fspick(AT_FDCWD, "/tmp", FSPICK_CLOEXEC); fsconfig(fsfd, FSCONFIG_SET_FLAG, "ro", NULL, 0); fsconfig(fsfd, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, 0);
The above procedure is roughly equivalent to the following mount operation using mount(2):
mount(NULL, "/tmp", NULL, MS_REMOUNT | MS_RDONLY, NULL);
With the notable caveat that in this example, mount(2) will clear all other filesystem parameters (such as MS_DIRSYNC or MS_SYNCHRONOUS); fsconfig(2) will only modify the ro parameter.
fsconfig(2), fsmount(2), fsopen(2), mount(2), mount_setattr(2), move_mount(2), open_tree(2), mount_namespaces(7)