From: Aleksa Sarai <cyphar@cyphar.com>
To: Alejandro Colomar <alx@kernel.org>
Cc: "Michael T. Kerrisk" <mtk.manpages@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>, Askar Safin <safinaskar@zohomail.com>,
"G. Branden Robinson" <g.branden.robinson@gmail.com>,
linux-man@vger.kernel.org, linux-api@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
David Howells <dhowells@redhat.com>,
Christian Brauner <brauner@kernel.org>,
Aleksa Sarai <cyphar@cyphar.com>
Subject: [PATCH v2 01/11] mount_setattr.2: document glibc >= 2.36 syscall wrappers
Date: Thu, 07 Aug 2025 03:44:35 +1000 [thread overview]
Message-ID: <20250807-new-mount-api-v2-1-558a27b8068c@cyphar.com> (raw)
In-Reply-To: <20250807-new-mount-api-v2-0-558a27b8068c@cyphar.com>
Glibc 2.36 added syscall wrappers for the entire family of fd-based
mount syscalls, including mount_setattr(2). Thus it's no longer
necessary to instruct users to do raw syscall(2) operations.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
---
man/man2/mount_setattr.2 | 45 +++++++--------------------------------------
1 file changed, 7 insertions(+), 38 deletions(-)
diff --git a/man/man2/mount_setattr.2 b/man/man2/mount_setattr.2
index 60d9cf9de8aa..c96f0657f046 100644
--- a/man/man2/mount_setattr.2
+++ b/man/man2/mount_setattr.2
@@ -10,21 +10,12 @@ .SH LIBRARY
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
-.BR "#include <linux/fcntl.h>" " /* Definition of " AT_* " constants */"
-.BR "#include <linux/mount.h>" " /* Definition of " MOUNT_ATTR_* " constants */"
-.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
-.B #include <unistd.h>
+.BR "#include <fcntl.h>" " /* Definition of " AT_* " constants */"
+.B #include <sys/mount.h>
.P
-.BI "int syscall(SYS_mount_setattr, int " dirfd ", const char *" path ,
-.BI " unsigned int " flags ", struct mount_attr *" attr \
-", size_t " size );
+.BI "int mount_setattr(int " dirfd ", const char *" path ", unsigned int " flags ","
+.BI " struct mount_attr *" attr ", size_t " size );"
.fi
-.P
-.IR Note :
-glibc provides no wrapper for
-.BR mount_setattr (),
-necessitating the use of
-.BR syscall (2).
.SH DESCRIPTION
The
.BR mount_setattr ()
@@ -586,6 +577,7 @@ .SH HISTORY
.\" commit 7d6beb71da3cc033649d641e1e608713b8220290
.\" commit 2a1867219c7b27f928e2545782b86daaf9ad50bd
.\" commit 9caccd41541a6f7d6279928d9f971f6642c361af
+glibc 2.36.
.SH NOTES
.SS ID-mapped mounts
Creating an ID-mapped mount makes it possible to
@@ -914,37 +906,14 @@ .SH EXAMPLES
#include <err.h>
#include <fcntl.h>
#include <getopt.h>
-#include <linux/mount.h>
-#include <linux/types.h>
+#include <sys/mount.h>
+#include <sys/types.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/syscall.h>
#include <unistd.h>
\&
-static inline int
-mount_setattr(int dirfd, const char *path, unsigned int flags,
- struct mount_attr *attr, size_t size)
-{
- return syscall(SYS_mount_setattr, dirfd, path, flags,
- attr, size);
-}
-\&
-static inline int
-open_tree(int dirfd, const char *filename, unsigned int flags)
-{
- return syscall(SYS_open_tree, dirfd, filename, flags);
-}
-\&
-static inline int
-move_mount(int from_dirfd, const char *from_path,
- int to_dirfd, const char *to_path, unsigned int flags)
-{
- return syscall(SYS_move_mount, from_dirfd, from_path,
- to_dirfd, to_path, flags);
-}
-\&
static const struct option longopts[] = {
{"map\-mount", required_argument, NULL, \[aq]a\[aq]},
{"recursive", no_argument, NULL, \[aq]b\[aq]},
--
2.50.1
next prev parent reply other threads:[~2025-08-06 17:45 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 17:44 [PATCH v2 00/11] man2: add man pages for 'new' mount API Aleksa Sarai
2025-08-06 17:44 ` Aleksa Sarai [this message]
2025-08-07 10:39 ` [PATCH v2 01/11] mount_setattr.2: document glibc >= 2.36 syscall wrappers Alejandro Colomar
2025-08-08 9:23 ` Askar Safin
2025-08-08 11:55 ` Aleksa Sarai
2025-08-09 10:42 ` Alejandro Colomar
2025-08-09 10:44 ` Alejandro Colomar
2025-08-06 17:44 ` [PATCH v2 02/11] mount_setattr.2: move mount_attr struct to mount_attr.2type Aleksa Sarai
2025-08-07 11:11 ` Alejandro Colomar
2025-08-07 12:38 ` Aleksa Sarai
2025-08-07 13:33 ` Alejandro Colomar
2025-08-06 17:44 ` [PATCH v2 03/11] fsopen.2: document 'new' mount api Aleksa Sarai
2025-08-07 11:38 ` Alejandro Colomar
2025-08-07 12:50 ` Aleksa Sarai
2025-08-07 13:42 ` Alejandro Colomar
2025-08-07 13:27 ` Aleksa Sarai
2025-08-07 13:52 ` Alejandro Colomar
2025-08-07 14:26 ` Aleksa Sarai
2025-08-07 19:27 ` Konstantin Ryabitsev
2025-08-07 19:39 ` Aleksa Sarai
2025-08-08 9:07 ` Askar Safin
2025-08-08 11:57 ` Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 04/11] fspick.2: " Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 05/11] fsconfig.2: " Aleksa Sarai
2025-08-08 14:00 ` Askar Safin
2025-08-08 15:22 ` Aleksa Sarai
2025-08-08 19:07 ` Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 06/11] fsmount.2: " Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 07/11] move_mount.2: " Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 08/11] open_tree.2: " Aleksa Sarai
2025-08-08 12:32 ` Askar Safin
2025-08-08 13:26 ` Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 09/11] mount_setattr.2: mirror opening sentence from fsopen(2) Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 10/11] open_tree_attr.2, open_tree.2: document new open_tree_attr() api Aleksa Sarai
2025-08-06 17:44 ` [PATCH v2 11/11] fsconfig.2, mount_setattr.2: add note about attribute-parameter distinction Aleksa Sarai
2025-08-08 12:53 ` [PATCH v2 00/11] man2: add man pages for 'new' mount API Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250807-new-mount-api-v2-1-558a27b8068c@cyphar.com \
--to=cyphar@cyphar.com \
--cc=alx@kernel.org \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=g.branden.robinson@gmail.com \
--cc=jack@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=safinaskar@zohomail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).