Rename OFlag/AtFlag to OFlags/AtFlags. (#1951)

* Rename `OFlag`/`AtFlag` to `OFlags`/`AtFlags`.

This makes them consistent with `PollFlags` and common usage of
bitflags types in Rust code in general.

POSIX does tend to use names like `oflag` and `flag`, so this is in mild
disagreement with POSIX style, however I find this particular aspects of
POSIX confusing because these values hold multiple flags.

* rustfmt
This commit is contained in:
Dan Gohman
2020-07-01 11:53:16 -07:00
committed by GitHub
parent 4f16f0dc32
commit b37adbbe31
20 changed files with 132 additions and 128 deletions

View File

@@ -23,16 +23,16 @@ impl TryFrom<File> for OsDir {
}
fn get_rights(file: &File) -> io::Result<HandleRights> {
use yanix::{fcntl, file::OFlag};
use yanix::{fcntl, file::OFlags};
let mut rights = HandleRights::new(
types::Rights::directory_base(),
types::Rights::directory_inheriting(),
);
let flags = unsafe { fcntl::get_status_flags(file.as_raw_fd())? };
let accmode = flags & OFlag::ACCMODE;
if accmode == OFlag::RDONLY {
let accmode = flags & OFlags::ACCMODE;
if accmode == OFlags::RDONLY {
rights.base &= !types::Rights::FD_WRITE;
} else if accmode == OFlag::WRONLY {
} else if accmode == OFlags::WRONLY {
rights.base &= !types::Rights::FD_READ;
}
Ok(rights)