all: simplify handling of Errno values
This commit is contained in:
parent
9c605df692
commit
34914eccb0
58 changed files with 443 additions and 464 deletions
|
|
@ -1,13 +1,16 @@
|
|||
use {crate::utils::oserror::OsError, uapi::c};
|
||||
use {
|
||||
crate::utils::oserror::{OsError, OsErrorExt},
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
pub fn set_nonblock(fd: c::c_int) -> Result<(), OsError> {
|
||||
let fl = uapi::fcntl_getfl(fd)?;
|
||||
uapi::fcntl_setfl(fd, fl | c::O_NONBLOCK)?;
|
||||
let fl = uapi::fcntl_getfl(fd).to_os_error()?;
|
||||
uapi::fcntl_setfl(fd, fl | c::O_NONBLOCK).to_os_error()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_block(fd: c::c_int) -> Result<(), OsError> {
|
||||
let fl = uapi::fcntl_getfl(fd)?;
|
||||
uapi::fcntl_setfl(fd, fl & !c::O_NONBLOCK)?;
|
||||
let fl = uapi::fcntl_getfl(fd).to_os_error()?;
|
||||
uapi::fcntl_setfl(fd, fl & !c::O_NONBLOCK).to_os_error()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue