Implement creation of SysV IPC message queues
This adds the `sysvmq` package which handles SysV IPC message queues. For consistency the parameter for `permissions` is renamed to `mode` also for POSIX message queues.
This commit is contained in:
parent
a468c5d7bb
commit
4d200bb5f3
11 changed files with 271 additions and 10 deletions
31
src/sysv/create.rs
Normal file
31
src/sysv/create.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use anyhow::Result;
|
||||
use clap::Clap;
|
||||
use log::info;
|
||||
use sysvmq::SysvMq;
|
||||
|
||||
/// Create a SysV message queue
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Create {
|
||||
/// Permissions (octal) to create the queue with (default: 0644)
|
||||
#[clap(short, long)]
|
||||
mode: Option<String>,
|
||||
/// Key of the new queue
|
||||
#[clap(value_name = "KEY")]
|
||||
key: i32,
|
||||
}
|
||||
|
||||
impl Create {
|
||||
pub fn run(&self) -> Result<()> {
|
||||
let mut mq = SysvMq::<String>::new();
|
||||
|
||||
if let Some(m) = &self.mode {
|
||||
mq.mode(i32::from_str_radix(&m, 8)?);
|
||||
}
|
||||
|
||||
mq.create(self.key)?;
|
||||
|
||||
info!("SysV message queue created, key: {}, id: {}", mq.key, mq.id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue