Implement deletion of SysV IPC message queues
As usual also the readme and the man page are updated.
This commit is contained in:
parent
4d200bb5f3
commit
cc19087195
6 changed files with 103 additions and 6 deletions
|
@ -25,6 +25,7 @@ enum PosixCommand {
|
|||
#[derive(Clap, Debug)]
|
||||
enum SysvCommand {
|
||||
Create(sysv::Create),
|
||||
Unlink(sysv::Unlink),
|
||||
}
|
||||
|
||||
#[derive(Clap, Debug)]
|
||||
|
@ -68,6 +69,7 @@ fn main() -> Result<()> {
|
|||
},
|
||||
Backend::Sysv(s) => match s {
|
||||
SysvCommand::Create(c) => c.run()?,
|
||||
SysvCommand::Unlink(u) => u.run()?,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
mod create;
|
||||
mod unlink;
|
||||
|
||||
pub use create::Create;
|
||||
pub use unlink::Unlink;
|
||||
|
|
35
src/sysv/unlink.rs
Normal file
35
src/sysv/unlink.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use anyhow::Result;
|
||||
use clap::Clap;
|
||||
use log::info;
|
||||
|
||||
/// Delete a message queue
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Unlink {
|
||||
/// Id of the queue
|
||||
#[clap(
|
||||
long,
|
||||
short,
|
||||
required_unless_present_any = &["key"],
|
||||
conflicts_with = "key"
|
||||
)]
|
||||
pub id: Option<i32>,
|
||||
/// Key of the queue
|
||||
#[clap(long, short, required_unless_present_any = &["id"], conflicts_with = "id")]
|
||||
pub key: Option<i32>,
|
||||
}
|
||||
|
||||
impl Unlink {
|
||||
pub fn run(&self) -> Result<()> {
|
||||
if let Some(id) = self.id {
|
||||
sysvmq::unlink_id(id)?;
|
||||
|
||||
info!("Removed message queue with id: {}", id);
|
||||
} else if let Some(key) = self.key {
|
||||
sysvmq::unlink_key(key)?;
|
||||
|
||||
info!("Removed message queue key: {}", key);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue