From 1b6a04ca5504955c571d1c97504fb45ea0befee4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 8 Jan 2024 01:21:28 +0400 Subject: Initial vendor packages Signed-off-by: Valentin Popov --- vendor/rustix/src/shm.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 vendor/rustix/src/shm.rs (limited to 'vendor/rustix/src/shm.rs') diff --git a/vendor/rustix/src/shm.rs b/vendor/rustix/src/shm.rs new file mode 100644 index 0000000..450b6fc --- /dev/null +++ b/vendor/rustix/src/shm.rs @@ -0,0 +1,40 @@ +//! POSIX shared memory + +use crate::fd::OwnedFd; +use crate::{backend, io, path}; + +pub use crate::backend::fs::types::Mode; +pub use crate::backend::shm::types::ShmOFlags; + +/// `shm_open(name, oflags, mode)`—Opens a shared memory object. +/// +/// For portability, `name` should begin with a slash, contain no other +/// slashes, and be no longer than an implementation-defined limit (255 on +/// Linux). +/// +/// Exactly one of [`ShmOFlags::RDONLY`] and [`ShmOFlags::RDWR`] should be +/// passed. The file descriptor will be opened with `FD_CLOEXEC` set. +/// +/// # References +/// - [POSIX] +/// - [Linux] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html +/// [Linux]: https://man7.org/linux/man-pages/man3/shm_open.3.html +#[inline] +pub fn shm_open(name: P, flags: ShmOFlags, mode: Mode) -> io::Result { + name.into_with_c_str(|name| backend::shm::syscalls::shm_open(name, flags, mode)) +} + +/// `shm_unlink(name)`—Unlinks a shared memory object. +/// +/// # References +/// - [POSIX] +/// - [Linux] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_unlink.html +/// [Linux]: https://man7.org/linux/man-pages/man3/shm_unlink.3.html +#[inline] +pub fn shm_unlink(name: P) -> io::Result<()> { + name.into_with_c_str(backend::shm::syscalls::shm_unlink) +} -- cgit v1.2.3