about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-24 08:12:57 +0200
committerGitHub <noreply@github.com>2025-04-24 08:12:57 +0200
commit10732e14f4ee6e462170f883c79fb90acf3ddc2c (patch)
tree20bf51cfeed98589dab5f1b6f56c3c56b65ff3a5 /library/std/src/sys
parentcb3c5d773ce76e3fa869402db87429bed637cc54 (diff)
parent780f95dd182b1a432159430add57e9ab7cb45dd6 (diff)
downloadrust-10732e14f4ee6e462170f883c79fb90acf3ddc2c.tar.gz
rust-10732e14f4ee6e462170f883c79fb90acf3ddc2c.zip
Rollup merge of #139450 - NobodyXu:new-api/make-fifo, r=tgross35
Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`

Tracking issue #139324
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/fs/mod.rs2
-rw-r--r--library/std/src/sys/fs/unix.rs6
2 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/sys/fs/mod.rs b/library/std/src/sys/fs/mod.rs
index 4c5e36ce67a..d55e28074fe 100644
--- a/library/std/src/sys/fs/mod.rs
+++ b/library/std/src/sys/fs/mod.rs
@@ -9,7 +9,7 @@ cfg_if::cfg_if! {
     if #[cfg(target_family = "unix")] {
         mod unix;
         use unix as imp;
-        pub use unix::{chown, fchown, lchown};
+        pub use unix::{chown, fchown, lchown, mkfifo};
         #[cfg(not(target_os = "fuchsia"))]
         pub use unix::chroot;
         pub(crate) use unix::debug_assert_fd_is_open;
diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs
index bc8817bac70..351a9f9413f 100644
--- a/library/std/src/sys/fs/unix.rs
+++ b/library/std/src/sys/fs/unix.rs
@@ -2137,6 +2137,12 @@ pub fn chroot(dir: &Path) -> io::Result<()> {
     Err(io::const_error!(io::ErrorKind::Unsupported, "chroot not supported by vxworks"))
 }
 
+pub fn mkfifo(path: &Path, mode: u32) -> io::Result<()> {
+    run_path_with_cstr(path, &|path| {
+        cvt(unsafe { libc::mkfifo(path.as_ptr(), mode.try_into().unwrap()) }).map(|_| ())
+    })
+}
+
 pub use remove_dir_impl::remove_dir_all;
 
 // Fallback for REDOX, ESP-ID, Horizon, Vita, Vxworks and Miri