Skip to content

Commit

Permalink
Update to bitflags 2.2.1.
Browse files Browse the repository at this point in the history
This is a new major version and requires some code changes.
  • Loading branch information
qwandor committed Apr 26, 2023
1 parent 388a14c commit 3fcf44b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = [

[dependencies]
libc = { git = "https://github.com/rust-lang/libc", rev = "60bf6d7fa9d561820ea562751ee455ccf67d3015", features = [ "extra_traits" ] }
bitflags = "1.1"
bitflags = "2.2.1"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }
static_assertions = "1"
Expand Down
1 change: 1 addition & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ macro_rules! libc_bitflags {
}
) => {
::bitflags::bitflags! {
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
$(#[$outer])*
pub struct $BitFlags: $T {
$(
Expand Down
4 changes: 2 additions & 2 deletions src/mount/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<'a> Nmount<'a> {

let niov = self.iov.len() as c_uint;
let iovp = self.iov.as_mut_ptr() as *mut libc::iovec;
let res = unsafe { libc::nmount(iovp, niov, flags.bits) };
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
match Errno::result(res) {
Ok(_) => Ok(()),
Err(error) => {
Expand Down Expand Up @@ -446,7 +446,7 @@ where
P: ?Sized + NixPath,
{
let res = mountpoint.with_nix_path(|cstr| unsafe {
libc::unmount(cstr.as_ptr(), flags.bits)
libc::unmount(cstr.as_ptr(), flags.bits())
})?;

Errno::result(res).map(drop)
Expand Down
4 changes: 2 additions & 2 deletions src/mount/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn mount<
s,
t.as_ptr(),
ty,
flags.bits,
flags.bits(),
d as *const libc::c_void,
)
})
Expand All @@ -156,7 +156,7 @@ pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {
/// See also [`umount`](https://man7.org/linux/man-pages/man2/umount.2.html)
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
let res = target.with_nix_path(|cstr| unsafe {
libc::umount2(cstr.as_ptr(), flags.bits)
libc::umount2(cstr.as_ptr(), flags.bits())
})?;

Errno::result(res).map(drop)
Expand Down
2 changes: 1 addition & 1 deletion src/mqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl MqAttr {
/// Open a message queue
///
/// See also [`mq_open(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html)
// The mode.bits cast is only lossless on some OSes
// The mode.bits() cast is only lossless on some OSes
#[allow(clippy::cast_lossless)]
pub fn mq_open(
name: &CStr,
Expand Down
4 changes: 2 additions & 2 deletions src/sys/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn mknod<P: ?Sized + NixPath>(
dev: dev_t,
) -> Result<()> {
let res = path.with_nix_path(|cstr| unsafe {
libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev)
libc::mknod(cstr.as_ptr(), kind.bits() | perm.bits() as mode_t, dev)
})?;

Errno::result(res).map(drop)
Expand All @@ -202,7 +202,7 @@ pub fn mknodat<P: ?Sized + NixPath>(
libc::mknodat(
dirfd,
cstr.as_ptr(),
kind.bits | perm.bits() as mode_t,
kind.bits() | perm.bits() as mode_t,
dev,
)
})?;
Expand Down
2 changes: 2 additions & 0 deletions src/sys/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub(crate) mod timer {
#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
/// Flags that are used for arming the timer.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerSetTimeFlags: libc::c_int {
const TFD_TIMER_ABSTIME = libc::TFD_TIMER_ABSTIME;
}
Expand All @@ -103,6 +104,7 @@ pub(crate) mod timer {
))]
bitflags! {
/// Flags that are used for arming the timer.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerSetTimeFlags: libc::c_int {
const TFD_TIMER_ABSTIME = libc::TIMER_ABSTIME;
}
Expand Down
4 changes: 2 additions & 2 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,7 @@ feature! {
/// See [access(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html)
pub fn access<P: ?Sized + NixPath>(path: &P, amode: AccessFlags) -> Result<()> {
let res = path.with_nix_path(|cstr| unsafe {
libc::access(cstr.as_ptr(), amode.bits)
libc::access(cstr.as_ptr(), amode.bits())
})?;
Errno::result(res).map(drop)
}
Expand Down Expand Up @@ -3422,7 +3422,7 @@ pub fn faccessat<P: ?Sized + NixPath>(
))]
pub fn eaccess<P: ?Sized + NixPath>(path: &P, mode: AccessFlags) -> Result<()> {
let res = path.with_nix_path(|cstr| unsafe {
libc::eaccess(cstr.as_ptr(), mode.bits)
libc::eaccess(cstr.as_ptr(), mode.bits())
})?;
Errno::result(res).map(drop)
}
Expand Down

0 comments on commit 3fcf44b

Please sign in to comment.