Compare commits
No commits in common. "ecd5ee5a36f9d1b5e0ded62bde3952dff52c157a" and "cc19087195e332ff7a30e2d909db6c7062b773d3" have entirely different histories.
ecd5ee5a36
...
cc19087195
12 changed files with 44 additions and 237 deletions
17
README.md
17
README.md
|
@ -1,6 +1,5 @@
|
||||||
# mqrs
|
# mqrs
|
||||||
`mqrs` is a small cli application to handle different kinds of message
|
`mqrs` is a small cli application to handle POSIX message queues.
|
||||||
queues.
|
|
||||||
|
|
||||||
## Install `mqrs`
|
## Install `mqrs`
|
||||||
For information about how to build, install and run `mqrs` please see
|
For information about how to build, install and run `mqrs` please see
|
||||||
|
@ -9,8 +8,8 @@ For information about how to build, install and run `mqrs` please see
|
||||||
## Using `mqrs`
|
## Using `mqrs`
|
||||||
Depending on which backend you want to use there are different subsets
|
Depending on which backend you want to use there are different subsets
|
||||||
of subcommands. Following backends are supported:
|
of subcommands. Following backends are supported:
|
||||||
- `posix`: Use POSIX message queues
|
- `posix`: Uses POSIX message queues
|
||||||
- `sysv`: Use SysV IPC message queues
|
- `sysv`: Uses SysV IPC message queues
|
||||||
|
|
||||||
If a command is clearly distinguishable from all the others,
|
If a command is clearly distinguishable from all the others,
|
||||||
it does not have to be completed further.
|
it does not have to be completed further.
|
||||||
|
@ -67,16 +66,6 @@ queue. Following optional arguments are supported:
|
||||||
- `-m`, `--mode`: Permissions (octal) to create the queue
|
- `-m`, `--mode`: Permissions (octal) to create the queue
|
||||||
with. Default: 0644.
|
with. Default: 0644.
|
||||||
|
|
||||||
#### Print information about a message queue
|
|
||||||
Use the `info` command to print further information about a message
|
|
||||||
queue. Exactly of the following arguments is mandatory:
|
|
||||||
- `-i`, `--id id`: Id of the queue
|
|
||||||
- `-k`, `--key key`: Key of the queue
|
|
||||||
|
|
||||||
#### List all message queues
|
|
||||||
Use the `list` command to print a list of all message queues. No
|
|
||||||
further arguments are supported.
|
|
||||||
|
|
||||||
#### Delete a message queue
|
#### Delete a message queue
|
||||||
Use the `unlink` command to delete a message queue. This can either be
|
Use the `unlink` command to delete a message queue. This can either be
|
||||||
done by providing a `key` or an `id` of the queue:
|
done by providing a `key` or an `id` of the queue:
|
||||||
|
|
68
mqrs.1
68
mqrs.1
|
@ -41,7 +41,7 @@ The POSIX backend supports six commands:
|
||||||
and
|
and
|
||||||
.B recv
|
.B recv
|
||||||
.
|
.
|
||||||
.SS posix create [FLAGS] [OPTIONS] \fI<QUEUE>\fP
|
.SS create [FLAGS] [OPTIONS] \fI<QUEUE>\fP
|
||||||
Create a new POSIX message queue.
|
Create a new POSIX message queue.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -72,7 +72,7 @@ Message size in bytes
|
||||||
.B \-m, \-\-mode \fI<mode>\fP
|
.B \-m, \-\-mode \fI<mode>\fP
|
||||||
Permissions (octal) to create the queue with
|
Permissions (octal) to create the queue with
|
||||||
.RE
|
.RE
|
||||||
.SS posix help [SUBCOMMAND]
|
.SS help [SUBCOMMAND]
|
||||||
Prints this message or the help of the given subcommand.
|
Prints this message or the help of the given subcommand.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -81,7 +81,7 @@ Prints this message or the help of the given subcommand.
|
||||||
.B \fI<SUBCOMMAND>\fP
|
.B \fI<SUBCOMMAND>\fP
|
||||||
Show help for \fISUBCOMMAND\fP
|
Show help for \fISUBCOMMAND\fP
|
||||||
.RE
|
.RE
|
||||||
.SS posix info [FLAGS] \fI<QUEUE>\fP
|
.SS info [FLAGS] \fI<QUEUE>\fP
|
||||||
Print further information about an existing message queue.
|
Print further information about an existing message queue.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -100,7 +100,7 @@ Prints help information
|
||||||
.B \-v, \-\-verbose
|
.B \-v, \-\-verbose
|
||||||
Produce verbose output
|
Produce verbose output
|
||||||
.RE
|
.RE
|
||||||
.SS posix list [FLAGS]
|
.SS list [FLAGS]
|
||||||
Print a list of all existing POSIX message queues.
|
Print a list of all existing POSIX message queues.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS FLAGS
|
.SS FLAGS
|
||||||
|
@ -115,7 +115,7 @@ Produce verbose output
|
||||||
.B \-a, \-\-all
|
.B \-a, \-\-all
|
||||||
Print all available information
|
Print all available information
|
||||||
.RE
|
.RE
|
||||||
.SS posix recv [FLAGS] [OPTIONS] \fI<QUEUE>\fP
|
.SS recv [FLAGS] [OPTIONS] \fI<QUEUE>\fP
|
||||||
Receive and print one or more messages message from a message queue.
|
Receive and print one or more messages message from a message queue.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -153,7 +153,7 @@ Deadline until messages are received (format: "%Y-%m-%d %H:%M:%S")
|
||||||
.B \-o, \-\-timeout \fI<timeout>\fP
|
.B \-o, \-\-timeout \fI<timeout>\fP
|
||||||
Timeout as for example in "5h 23min 42ms"
|
Timeout as for example in "5h 23min 42ms"
|
||||||
.RE
|
.RE
|
||||||
.SS posix send [FLAGS] [OPTIONS] \fI<QUEUE>\fP \fI<MESSAGE>\fP
|
.SS send [FLAGS] [OPTIONS] \fI<QUEUE>\fP \fI<MESSAGE>\fP
|
||||||
Send a message to a message queue.
|
Send a message to a message queue.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -191,7 +191,7 @@ Set a different priority than default, priority >= 0 [default: 0]
|
||||||
.B \-o, \-\-timeout \fI<timeout>\fP
|
.B \-o, \-\-timeout \fI<timeout>\fP
|
||||||
Timeout as for example in "5h 23min 42ms"
|
Timeout as for example in "5h 23min 42ms"
|
||||||
.RE
|
.RE
|
||||||
.SS posix unlink [FLAGS] \fI<QUEUE>\fP
|
.SS unlink [FLAGS] \fI<QUEUE>\fP
|
||||||
Delete an existing POSIX message queue.
|
Delete an existing POSIX message queue.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -211,16 +211,12 @@ Prints help information
|
||||||
Produce verbose output
|
Produce verbose output
|
||||||
.RE
|
.RE
|
||||||
.SH SYSV IPC MESSAGE QUEUE SUBCOMMANDS
|
.SH SYSV IPC MESSAGE QUEUE SUBCOMMANDS
|
||||||
The SysV IPC backend supports four commands:
|
The SysV IPC backend supports two commands:
|
||||||
.B create\
|
.B create\
|
||||||
,
|
|
||||||
.B info\
|
|
||||||
,
|
|
||||||
.B list
|
|
||||||
and
|
and
|
||||||
.B unlink\
|
.B unlink\
|
||||||
.
|
.
|
||||||
.SS sysv create [FLAGS] [OPTIONS] \fI<KEY>\fP
|
.SS create [FLAGS] [OPTIONS] \fI<KEY>\fP
|
||||||
Create a new SysV IPC message queue.
|
Create a new SysV IPC message queue.
|
||||||
.TP 8
|
.TP 8
|
||||||
.SS ARGS
|
.SS ARGS
|
||||||
|
@ -245,51 +241,7 @@ Produce verbose output
|
||||||
.B \-m, \-\-mode \fI<mode>\fP
|
.B \-m, \-\-mode \fI<mode>\fP
|
||||||
Permissions (octal) to create the queue with (default: 0644)
|
Permissions (octal) to create the queue with (default: 0644)
|
||||||
.RE
|
.RE
|
||||||
.SS sysv help [SUBCOMMAND]
|
.SS unlink [FLAGS] [OPTIONS]
|
||||||
Prints this message or the help of the given subcommand.
|
|
||||||
.TP 8
|
|
||||||
.SS ARGS
|
|
||||||
.RS
|
|
||||||
.TP 8
|
|
||||||
.B \fI<SUBCOMMAND>\fP
|
|
||||||
Show help for \fISUBCOMMAND\fP
|
|
||||||
.RE
|
|
||||||
.SS sysv info [FLAGS] [OPTIONS]
|
|
||||||
Print further information about an existing message queue. Exactly of
|
|
||||||
the OPTION arguments is mandatory.
|
|
||||||
.TP 8
|
|
||||||
.SS FLAGS
|
|
||||||
.RS
|
|
||||||
.TP 8
|
|
||||||
.B \-h, \-\-help
|
|
||||||
Prints help information
|
|
||||||
.TP 8
|
|
||||||
.B \-v, \-\-verbose
|
|
||||||
Produce verbose output
|
|
||||||
.RE
|
|
||||||
.TP 8
|
|
||||||
.SS OPTIONS
|
|
||||||
.RS
|
|
||||||
.TP 8
|
|
||||||
.B \-i, \-\-id \fI<id>\fP
|
|
||||||
Id of the queue
|
|
||||||
.TP 8
|
|
||||||
.B \-k, \-\-key \fI<key>\fP
|
|
||||||
Key of the queue
|
|
||||||
.RE
|
|
||||||
.SS sysv list [FLAGS]
|
|
||||||
Print a list of all existing SysV IPC message queues.
|
|
||||||
.TP 8
|
|
||||||
.SS FLAGS
|
|
||||||
.RS
|
|
||||||
.TP 8
|
|
||||||
.B \-h, \-\-help
|
|
||||||
Prints help information
|
|
||||||
.TP 8
|
|
||||||
.B \-v, \-\-verbose
|
|
||||||
Produce verbose output
|
|
||||||
.RE
|
|
||||||
.SS sysv unlink [FLAGS] [OPTIONS]
|
|
||||||
Delete an existing SysV IPC message queue. It is mandatory to pass
|
Delete an existing SysV IPC message queue. It is mandatory to pass
|
||||||
exactly one OPTION.
|
exactly one OPTION.
|
||||||
.TP 8
|
.TP 8
|
||||||
|
|
|
@ -25,8 +25,6 @@ enum PosixCommand {
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
enum SysvCommand {
|
enum SysvCommand {
|
||||||
Create(sysv::Create),
|
Create(sysv::Create),
|
||||||
Info(sysv::Info),
|
|
||||||
List(sysv::List),
|
|
||||||
Unlink(sysv::Unlink),
|
Unlink(sysv::Unlink),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +69,6 @@ fn main() -> Result<()> {
|
||||||
},
|
},
|
||||||
Backend::Sysv(s) => match s {
|
Backend::Sysv(s) => match s {
|
||||||
SysvCommand::Create(c) => c.run()?,
|
SysvCommand::Create(c) => c.run()?,
|
||||||
SysvCommand::Info(i) => i.run()?,
|
|
||||||
SysvCommand::List(l) => l.run()?,
|
|
||||||
SysvCommand::Unlink(u) => u.run()?,
|
SysvCommand::Unlink(u) => u.run()?,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use posixmq::PosixMq;
|
||||||
pub struct Info {
|
pub struct Info {
|
||||||
/// Name of the queue
|
/// Name of the queue
|
||||||
#[clap(value_name = "QUEUE")]
|
#[clap(value_name = "QUEUE")]
|
||||||
queue: String,
|
pub queue: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Info {
|
impl Info {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use clap::Clap;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use std::{fs, os::unix::fs::PermissionsExt};
|
use std::{fs, os::unix::fs::PermissionsExt};
|
||||||
|
|
||||||
/// Print a list of existing message queues
|
/// Print information about an existing message queue
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
pub struct List {
|
pub struct List {
|
||||||
/// Show all parameters
|
/// Show all parameters
|
||||||
|
|
|
@ -11,22 +11,22 @@ use std::str;
|
||||||
pub struct Recv {
|
pub struct Recv {
|
||||||
/// Do not block
|
/// Do not block
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
non_blocking: bool,
|
pub non_blocking: bool,
|
||||||
/// Print messages as they are received
|
/// Print messages as they are received
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
follow: bool,
|
pub follow: bool,
|
||||||
/// Print a timestamp before each message
|
/// Print a timestamp before each message
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
timestamp: bool,
|
pub timestamp: bool,
|
||||||
/// Timeout, example "5h 23min 42ms"
|
/// Timeout, example "5h 23min 42ms"
|
||||||
#[clap(short = 'o', long, conflicts_with = "deadline")]
|
#[clap(short = 'o', long, conflicts_with = "deadline")]
|
||||||
timeout: Option<String>,
|
pub timeout: Option<String>,
|
||||||
/// Deadline until messages are received (format: "%Y-%m-%d %H:%M:%S")
|
/// Deadline until messages are received (format: "%Y-%m-%d %H:%M:%S")
|
||||||
#[clap(short, long, conflicts_with = "timeout")]
|
#[clap(short, long, conflicts_with = "timeout")]
|
||||||
deadline: Option<String>,
|
pub deadline: Option<String>,
|
||||||
/// Name of the queue
|
/// Name of the queue
|
||||||
#[clap(value_name = "QUEUE")]
|
#[clap(value_name = "QUEUE")]
|
||||||
queue: String,
|
pub queue: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_message(priority: u32, length: usize, timestamp: bool, msg: &str) {
|
fn print_message(priority: u32, length: usize, timestamp: bool, msg: &str) {
|
||||||
|
|
|
@ -9,22 +9,22 @@ use log::info;
|
||||||
pub struct Send {
|
pub struct Send {
|
||||||
/// Set a different priority, priority >= 0
|
/// Set a different priority, priority >= 0
|
||||||
#[clap(short, long, default_value = "0")]
|
#[clap(short, long, default_value = "0")]
|
||||||
priority: u32,
|
pub priority: u32,
|
||||||
/// Do not block
|
/// Do not block
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
non_blocking: bool,
|
pub non_blocking: bool,
|
||||||
/// Timeout, example "5h 23min 42ms"
|
/// Timeout, example "5h 23min 42ms"
|
||||||
#[clap(short = 'o', long, conflicts_with = "deadline")]
|
#[clap(short = 'o', long, conflicts_with = "deadline")]
|
||||||
timeout: Option<String>,
|
pub timeout: Option<String>,
|
||||||
/// Deadline until messages are sent (format: "%Y-%m-%d %H:%M:%S")
|
/// Deadline until messages are sent (format: "%Y-%m-%d %H:%M:%S")
|
||||||
#[clap(short, long, conflicts_with = "timeout")]
|
#[clap(short, long, conflicts_with = "timeout")]
|
||||||
deadline: Option<String>,
|
pub deadline: Option<String>,
|
||||||
/// Name of the queue
|
/// Name of the queue
|
||||||
#[clap(value_name = "QUEUE")]
|
#[clap(value_name = "QUEUE")]
|
||||||
queue: String,
|
pub queue: String,
|
||||||
/// Message to be sent to the queue
|
/// Message to be sent to the queue
|
||||||
#[clap(value_name = "MESSAGE")]
|
#[clap(value_name = "MESSAGE")]
|
||||||
msg: String,
|
pub msg: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Send {
|
impl Send {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
mod create;
|
mod create;
|
||||||
mod info;
|
|
||||||
mod list;
|
|
||||||
mod unlink;
|
mod unlink;
|
||||||
|
|
||||||
pub use create::Create;
|
pub use create::Create;
|
||||||
pub use info::Info;
|
|
||||||
pub use list::List;
|
|
||||||
pub use unlink::Unlink;
|
pub use unlink::Unlink;
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
use anyhow::Result;
|
|
||||||
use clap::Clap;
|
|
||||||
use std::{
|
|
||||||
fs::File,
|
|
||||||
io::{BufRead, BufReader},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Print information about an existing message queue
|
|
||||||
#[derive(Clap, Debug)]
|
|
||||||
pub struct Info {
|
|
||||||
/// Id of the queue
|
|
||||||
#[clap(short, long, required_unless_present_any = &["key"], conflicts_with = "key")]
|
|
||||||
id: Option<i32>,
|
|
||||||
/// Key of the queue
|
|
||||||
#[clap(short, long, required_unless_present_any = &["id"], conflicts_with = "id")]
|
|
||||||
key: Option<i32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn print_line(line: &str) {
|
|
||||||
for field in line.split_whitespace().collect::<Vec<&str>>() {
|
|
||||||
print!("{0: <10}", field);
|
|
||||||
}
|
|
||||||
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Info {
|
|
||||||
pub fn run(&self) -> Result<()> {
|
|
||||||
let mut lines = BufReader::new(File::open("/proc/sysvipc/msg")?).lines();
|
|
||||||
|
|
||||||
print_line(&lines.nth(0).unwrap_or(Ok(String::new()))?);
|
|
||||||
|
|
||||||
for line in lines {
|
|
||||||
let line = line?;
|
|
||||||
|
|
||||||
if let Some(id) = self.id {
|
|
||||||
if id == line.split_whitespace().collect::<Vec<&str>>()[1].parse::<i32>()? {
|
|
||||||
print_line(&line);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if let Some(key) = self.key {
|
|
||||||
if key == line.split_whitespace().collect::<Vec<&str>>()[0].parse::<i32>()? {
|
|
||||||
print_line(&line);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
use anyhow::Result;
|
|
||||||
use clap::Clap;
|
|
||||||
use std::{
|
|
||||||
fs::File,
|
|
||||||
io::{BufRead, BufReader},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Print a list of existing message queues
|
|
||||||
#[derive(Clap, Debug)]
|
|
||||||
pub struct List {}
|
|
||||||
|
|
||||||
impl List {
|
|
||||||
pub fn run(&self) -> Result<()> {
|
|
||||||
for line in BufReader::new(File::open("/proc/sysvipc/msg")?).lines() {
|
|
||||||
for field in line?.split_whitespace().collect::<Vec<&str>>() {
|
|
||||||
print!("{0: <10}", field);
|
|
||||||
}
|
|
||||||
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,15 +7,15 @@ use log::info;
|
||||||
pub struct Unlink {
|
pub struct Unlink {
|
||||||
/// Id of the queue
|
/// Id of the queue
|
||||||
#[clap(
|
#[clap(
|
||||||
short,
|
|
||||||
long,
|
long,
|
||||||
|
short,
|
||||||
required_unless_present_any = &["key"],
|
required_unless_present_any = &["key"],
|
||||||
conflicts_with = "key"
|
conflicts_with = "key"
|
||||||
)]
|
)]
|
||||||
id: Option<i32>,
|
pub id: Option<i32>,
|
||||||
/// Key of the queue
|
/// Key of the queue
|
||||||
#[clap(short, long, required_unless_present_any = &["id"], conflicts_with = "id")]
|
#[clap(long, short, required_unless_present_any = &["id"], conflicts_with = "id")]
|
||||||
key: Option<i32>,
|
pub key: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Unlink {
|
impl Unlink {
|
||||||
|
@ -25,11 +25,9 @@ impl Unlink {
|
||||||
|
|
||||||
info!("Removed message queue with id: {}", id);
|
info!("Removed message queue with id: {}", id);
|
||||||
} else if let Some(key) = self.key {
|
} else if let Some(key) = self.key {
|
||||||
let id = sysvmq::id_from_key(key)?;
|
sysvmq::unlink_key(key)?;
|
||||||
|
|
||||||
sysvmq::unlink_id(id)?;
|
info!("Removed message queue key: {}", key);
|
||||||
|
|
||||||
info!("Removed message queue key: {} (id: {})", key, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
use libc::{
|
use libc::{
|
||||||
msgctl, msgget, msginfo, msqid_ds, IPC_CREAT, IPC_EXCL, IPC_INFO, IPC_NOWAIT, IPC_PRIVATE,
|
msgctl, msgget, msqid_ds, IPC_CREAT, IPC_EXCL, IPC_INFO, IPC_NOWAIT, IPC_PRIVATE, IPC_RMID,
|
||||||
IPC_RMID, IPC_SET, IPC_STAT, MSG_COPY, MSG_EXCEPT, MSG_INFO, MSG_NOERROR, MSG_STAT,
|
IPC_SET, IPC_STAT, MSG_COPY, MSG_EXCEPT, MSG_INFO, MSG_NOERROR, MSG_STAT,
|
||||||
};
|
};
|
||||||
use nix::errno::{errno, Errno};
|
use nix::errno::{errno, Errno};
|
||||||
use std::{marker::PhantomData, mem::MaybeUninit, ptr};
|
use std::{marker::PhantomData, num::ParseIntError, ptr};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum SysvMqError {
|
pub enum SysvMqError {
|
||||||
#[error("SysV message queue: {0}")]
|
#[error("SysV message queue: {0}")]
|
||||||
ErrnoError(&'static str),
|
ErrnoError(&'static str),
|
||||||
|
#[error("No message queue found with key {0}")]
|
||||||
|
KeyNotFound(i32),
|
||||||
|
#[error("IO Error: {0}")]
|
||||||
|
IoError(#[from] std::io::Error),
|
||||||
|
#[error("Parse Error: {0}")]
|
||||||
|
ParserError(#[from] ParseIntError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// IPC bit flags
|
/// IPC bit flags
|
||||||
|
@ -63,63 +69,10 @@ pub fn unlink_id(id: i32) -> Result<(), SysvMqError> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id_from_key(key: i32) -> Result<i32, SysvMqError> {
|
pub fn unlink_key(key: i32) -> Result<(), SysvMqError> {
|
||||||
let id = unsafe { msgget(key, 0) };
|
let id = unsafe { msgget(key, 0) };
|
||||||
|
|
||||||
match id {
|
unlink_id(id)
|
||||||
-1 => Err(SysvMqError::ErrnoError(Errno::from_i32(errno()).desc())),
|
|
||||||
id => Ok(id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn ipc_info(id: i32) -> Result<(), SysvMqError> {
|
|
||||||
let mut msginfo = MaybeUninit::<msginfo>::uninit();
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
msgctl(
|
|
||||||
id,
|
|
||||||
ControlCommands::IpcInfo as i32,
|
|
||||||
msginfo.as_mut_ptr() as *mut msqid_ds,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let msginfo = unsafe { msginfo.assume_init() };
|
|
||||||
|
|
||||||
println!("info: {:?}", msginfo);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn stat_info(id: i32) -> Result<(), SysvMqError> {
|
|
||||||
let mut msginfo = MaybeUninit::<msqid_ds>::uninit();
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
msgctl(id, ControlCommands::Stat as i32, msginfo.as_mut_ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
let msginfo = unsafe { msginfo.assume_init() };
|
|
||||||
|
|
||||||
println!("info: {:?}", msginfo);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn msg_info(id: i32) -> Result<(), SysvMqError> {
|
|
||||||
let mut msginfo = MaybeUninit::<msginfo>::uninit();
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
msgctl(
|
|
||||||
id,
|
|
||||||
ControlCommands::MsgInfo as i32,
|
|
||||||
msginfo.as_mut_ptr() as *mut msqid_ds,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let msginfo = unsafe { msginfo.assume_init() };
|
|
||||||
|
|
||||||
println!("info: {:?}", msginfo);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SysvMq<T> {
|
pub struct SysvMq<T> {
|
||||||
|
|
Loading…
Reference in a new issue