Skip to content

Commit

Permalink
Migrate more bitflags to use libc_bitflags!
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryant Mairs committed Dec 6, 2017
1 parent a055e9a commit ed79cfb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 42 deletions.
69 changes: 40 additions & 29 deletions src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,47 @@ use libc;
use {Result, NixPath};
use errno::Errno;

bitflags!(
libc_bitflags!(
pub struct MsFlags: c_ulong {
const MS_RDONLY = libc::MS_RDONLY; // Mount read-only
const MS_NOSUID = libc::MS_NOSUID; // Ignore suid and sgid bits
const MS_NODEV = libc::MS_NODEV; // Disallow access to device special files
const MS_NOEXEC = libc::MS_NOEXEC; // Disallow program execution
const MS_SYNCHRONOUS = libc::MS_SYNCHRONOUS; // Writes are synced at once
const MS_REMOUNT = libc::MS_REMOUNT; // Alter flags of a mounted FS
const MS_MANDLOCK = libc::MS_MANDLOCK; // Allow mandatory locks on a FS
const MS_DIRSYNC = libc::MS_DIRSYNC; // Directory modifications are synchronous
const MS_NOATIME = libc::MS_NOATIME; // Do not update access times
const MS_NODIRATIME = libc::MS_NODIRATIME; // Do not update directory access times
const MS_BIND = libc::MS_BIND; // Linux 2.4.0 - Bind directory at different place
const MS_MOVE = libc::MS_MOVE;
const MS_REC = libc::MS_REC;
const MS_SILENT = libc::MS_SILENT;
const MS_POSIXACL = libc::MS_POSIXACL;
const MS_UNBINDABLE = libc::MS_UNBINDABLE;
const MS_PRIVATE = libc::MS_PRIVATE;
const MS_SLAVE = libc::MS_SLAVE;
const MS_SHARED = libc::MS_SHARED;
const MS_RELATIME = libc::MS_RELATIME;
const MS_KERNMOUNT = libc::MS_KERNMOUNT;
const MS_I_VERSION = libc::MS_I_VERSION;
const MS_STRICTATIME = libc::MS_STRICTATIME;
const MS_ACTIVE = libc::MS_ACTIVE;
const MS_NOUSER = libc::MS_NOUSER;
const MS_RMT_MASK = libc::MS_RMT_MASK;
const MS_MGC_VAL = libc::MS_MGC_VAL;
const MS_MGC_MSK = libc::MS_MGC_MSK;
/// Mount read-only
MS_RDONLY;
/// Ignore suid and sgid bits
MS_NOSUID;
/// Disallow access to device special files
MS_NODEV;
/// Disallow program execution
MS_NOEXEC;
/// Writes are synced at once
MS_SYNCHRONOUS;
/// Alter flags of a mounted FS
MS_REMOUNT;
/// Allow mandatory locks on a FS
MS_MANDLOCK;
/// Directory modifications are synchronous
MS_DIRSYNC;
/// Do not update access times
MS_NOATIME;
/// Do not update directory access times
MS_NODIRATIME;
/// Linux 2.4.0 - Bind directory at different place
MS_BIND;
MS_MOVE;
MS_REC;
MS_SILENT;
MS_POSIXACL;
MS_UNBINDABLE;
MS_PRIVATE;
MS_SLAVE;
MS_SHARED;
MS_RELATIME;
MS_KERNMOUNT;
MS_I_VERSION;
MS_STRICTATIME;
MS_ACTIVE;
MS_NOUSER;
MS_RMT_MASK;
MS_MGC_VAL;
MS_MGC_MSK;
}
);

Expand Down
26 changes: 13 additions & 13 deletions src/sys/statvfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ use libc::{self, c_ulong};
use {Result, NixPath};
use errno::Errno;

bitflags!(
libc_bitflags!(
/// File system mount Flags
#[repr(C)]
#[derive(Default)]
pub struct FsFlags: c_ulong {
/// Read Only
const RDONLY = libc::ST_RDONLY;
ST_RDONLY;
/// Do not allow the set-uid bits to have an effect
const NOSUID = libc::ST_NOSUID;
ST_NOSUID;
/// Do not interpret character or block-special devices
#[cfg(any(target_os = "android", target_os = "linux"))]
const NODEV = libc::ST_NODEV;
ST_NODEV;
/// Do not allow execution of binaries on the filesystem
#[cfg(any(target_os = "android", target_os = "linux"))]
const NOEXEC = libc::ST_NOEXEC;
ST_NOEXEC;
/// All IO should be done synchronously
#[cfg(any(target_os = "android", target_os = "linux"))]
const SYNCHRONOUS = libc::ST_SYNCHRONOUS;
ST_SYNCHRONOUS;
/// Allow mandatory locks on the filesystem
#[cfg(any(target_os = "android", target_os = "linux"))]
const MANDLOCK = libc::ST_MANDLOCK;
ST_MANDLOCK;
/// Write on file/directory/symlink
#[cfg(any(target_os = "android", target_os = "linux"))]
const WRITE = libc::ST_WRITE;
ST_WRITE;
/// Append-only file
#[cfg(any(target_os = "android", target_os = "linux"))]
const APPEND = libc::ST_APPEND;
ST_APPEND;
/// Immutable file
#[cfg(any(target_os = "android", target_os = "linux"))]
const IMMUTABLE = libc::ST_IMMUTABLE;
ST_IMMUTABLE;
/// Do not update access times on files
#[cfg(any(target_os = "android", target_os = "linux"))]
const NOATIME = libc::ST_NOATIME;
ST_NOATIME;
/// Do not update access times on files
#[cfg(any(target_os = "android", target_os = "linux"))]
const NODIRATIME = libc::ST_NODIRATIME;
ST_NODIRATIME;
/// Update access time relative to modify/change time
#[cfg(any(target_os = "android", all(target_os = "linux", not(target_env = "musl"))))]
const RELATIME = libc::ST_RELATIME;
ST_RELATIME;
}
);

Expand Down

0 comments on commit ed79cfb

Please sign in to comment.