mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 10/11] open_tree_attr.2, open_tree.2: document new open_tree_attr() api
Date: Thu, 07 Aug 2025 03:44:44 +1000	[thread overview]
Message-ID: <20250807-new-mount-api-v2-10-558a27b8068c@cyphar.com> (raw)
In-Reply-To: <20250807-new-mount-api-v2-0-558a27b8068c@cyphar.com>

This is a new API added in Linux 6.15, and is effectively just a minor
expansion of open_tree(2) in order to allow for MOUNT_ATTR_IDMAP to be
changed for an existing ID-mapped mount.  Glibc does not yet have a
wrapper for this.

Cc: Christian Brauner <brauner@kernel.org>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
---
 man/man2/open_tree.2      | 74 +++++++++++++++++++++++++++++++++++++++++++++++
 man/man2/open_tree_attr.2 |  1 +
 2 files changed, 75 insertions(+)

diff --git a/man/man2/open_tree.2 b/man/man2/open_tree.2
index 3d38e27b5254..6e7ec4998d42 100644
--- a/man/man2/open_tree.2
+++ b/man/man2/open_tree.2
@@ -15,7 +15,19 @@ .SH SYNOPSIS
 .BR "#include <sys/mount.h>"
 .P
 .BI "int open_tree(int " dirfd ", const char *" path ", unsigned int " flags ");"
+.P
+.BR "#include <sys/syscall.h>" "    /* Definition of " SYS_* " constants */"
+.P
+.BI "int syscall(SYS_open_tree_attr, int " dirfd ", const char *" path ","
+.BI "            unsigned int " flags ", struct mount_attr *" attr ", \
+size_t " size ");"
 .fi
+.P
+.IR Note :
+glibc provides no wrapper for
+.BR open_tree_attr (),
+necessitating the use of
+.BR syscall (2).
 .SH DESCRIPTION
 The
 .BR open_tree ()
@@ -222,6 +234,64 @@ .SH DESCRIPTION
 and attach it to the file descriptor.
 This flag is only permitted in conjunction with
 .BR \%OPEN_TREE_CLONE .
+.SS open_tree_attr()
+The
+.BR open_tree_attr ()
+system call operates in exactly the same way as
+.BR open_tree (),
+except for the differences described here.
+.P
+After performing the same operation as with
+.BR open_tree (),
+(before returning the resulting file descriptor)
+.BR open_tree_attr ()
+will apply the mount attributes requested in
+.I attr
+to the mount object.
+(See
+.BR mount_attr (2type)
+for a description of the
+.I mount_attr
+structure.
+As described in
+.BR mount_setattr (2),
+.I size
+must be set to
+.I sizeof(struct mount_attr)
+in order to support future extensions.)
+.P
+For the most part, the application of
+.I attr
+has identical semantics to
+.BR mount_setattr (2),
+except that it is possible to change the
+.B \%MOUNT_ATTR_IDMAP
+attribute for a mount object
+that is already configured as an ID-mapped mount.
+This is usually forbidden by
+.BR mount_setattr (2)
+and thus
+.BR open_tree_attr ()
+is currently the only permitted mechanism to change this attribute.
+Changing an ID-mapped mount is only permitted
+if a new detached mount object is being created with
+.I flags
+including
+.BR \%OPEN_TREE_CLONE .
+.P
+If
+.I flags
+contains
+.BR \%AT_RECURSIVE ,
+then the attributes are applied recursively
+(just as when
+.BR mount_setattr (2)
+is called with
+.BR \%AT_RECURSIVE ).
+This applies in addition to the
+.BR open_tree ()-specific
+behaviour regarding
+.BR \%AT_RECURSIVE .
 .SH RETURN VALUE
 On success, a new file descriptor is returned.
 On error, \-1 is returned, and
@@ -316,9 +386,13 @@ .SH ERRORS
 .SH STANDARDS
 Linux.
 .SH HISTORY
+.SS open_tree()
 Linux 5.2.
 .\" commit a07b20004793d8926f78d63eb5980559f7813404
 glibc 2.36.
+.SS open_tree_attr()
+Linux 6.15.
+.\" commit c4a16820d90199409c9bf01c4f794e1e9e8d8fd8
 .SH NOTES
 .SS Anonymous mount namespaces
 The bind-mount mount objects created by
diff --git a/man/man2/open_tree_attr.2 b/man/man2/open_tree_attr.2
new file mode 100644
index 000000000000..e57269bbd269
--- /dev/null
+++ b/man/man2/open_tree_attr.2
@@ -0,0 +1 @@
+.so man2/open_tree.2

-- 
2.50.1


  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 ` [PATCH v2 01/11] mount_setattr.2: document glibc >= 2.36 syscall wrappers Aleksa Sarai
2025-08-07 10:39   ` 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 ` Aleksa Sarai [this message]
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-10-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

all inboxes | Powered by JetHome®