Skip to content

Commit 237b8ac

Browse files
authored
Add FSCONFIG_CMD_CREATE_EXCL (#1139)
Introduced by Linux 6.6
1 parent b77cbc8 commit 237b8ac

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

src/backend/libc/mount/syscalls.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,17 @@ pub(crate) fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
270270
))
271271
}
272272
}
273+
274+
#[cfg(linux_kernel)]
275+
#[cfg(feature = "mount")]
276+
pub(crate) fn fsconfig_create_excl(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
277+
unsafe {
278+
ret(fsconfig(
279+
borrowed_fd(fs_fd),
280+
super::types::FsConfigCmd::CreateExclusive as _,
281+
null(),
282+
null(),
283+
0,
284+
))
285+
}
286+
}

src/backend/libc/mount/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ pub(crate) enum FsConfigCmd {
146146

147147
/// `FSCONFIG_CMD_RECONFIGURE`
148148
Reconfigure = 7,
149+
150+
/// `FSCONFIG_CMD_CREATE_EXCL`
151+
CreateExclusive = 8,
149152
}
150153

151154
#[cfg(feature = "mount")]

src/backend/linux_raw/mount/syscalls.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,18 @@ pub(crate) fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
237237
))
238238
}
239239
}
240+
241+
#[cfg(feature = "mount")]
242+
#[inline]
243+
pub(crate) fn fsconfig_create_excl(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
244+
unsafe {
245+
ret(syscall_readonly!(
246+
__NR_fsconfig,
247+
fs_fd,
248+
super::types::FsConfigCmd::CreateExclusive,
249+
zero(),
250+
zero(),
251+
zero()
252+
))
253+
}
254+
}

src/backend/linux_raw/mount/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ pub(crate) enum FsConfigCmd {
144144

145145
/// `FSCONFIG_CMD_RECONFIGURE`
146146
Reconfigure = linux_raw_sys::general::fsconfig_command::FSCONFIG_CMD_RECONFIGURE as u32,
147+
148+
/// `FSCONFIG_CMD_CREATE_EXCL`
149+
CreateExclusive = linux_raw_sys::general::fsconfig_command::FSCONFIG_CMD_CREATE_EXCL as u32,
147150
}
148151

149152
#[cfg(feature = "mount")]

src/mount/fsopen.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,15 @@ pub fn fsconfig_create(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
217217
pub fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
218218
backend::mount::syscalls::fsconfig_reconfigure(fs_fd)
219219
}
220+
221+
/// `fsconfig(fs_fd, FSCONFIG_CMD_CREATE_EXCL, key, NULL, 0)`
222+
///
223+
/// # References
224+
/// - [Unfinished draft]
225+
///
226+
/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
227+
#[inline]
228+
#[doc(alias = "fsconfig")]
229+
pub fn fsconfig_create_exclusive(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
230+
backend::mount::syscalls::fsconfig_create_excl(fs_fd)
231+
}

0 commit comments

Comments
 (0)