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

@@ -11,13 +11,13 @@ use std::{
pub use crate::sys::file::*;
bitflags! {
pub struct FdFlag: libc::c_int {
pub struct FdFlags: libc::c_int {
const CLOEXEC = libc::FD_CLOEXEC;
}
}
bitflags! {
pub struct AtFlag: libc::c_int {
pub struct AtFlags: libc::c_int {
const REMOVEDIR = libc::AT_REMOVEDIR;
const SYMLINK_FOLLOW = libc::AT_SYMLINK_FOLLOW;
const SYMLINK_NOFOLLOW = libc::AT_SYMLINK_NOFOLLOW;
@@ -48,7 +48,7 @@ bitflags! {
}
bitflags! {
pub struct OFlag: libc::c_int {
pub struct OFlags: libc::c_int {
const ACCMODE = libc::O_ACCMODE;
const APPEND = libc::O_APPEND;
const CREAT = libc::O_CREAT;
@@ -155,7 +155,7 @@ impl FileType {
pub unsafe fn openat<P: AsRef<OsStr>>(
dirfd: RawFd,
path: P,
oflag: OFlag,
oflag: OFlags,
mode: Mode,
) -> Result<RawFd> {
let path = CString::new(path.as_ref().as_bytes())?;
@@ -194,7 +194,7 @@ pub unsafe fn linkat<P: AsRef<OsStr>>(
old_path: P,
new_dirfd: RawFd,
new_path: P,
flags: AtFlag,
flags: AtFlags,
) -> Result<()> {
let old_path = CString::new(old_path.as_ref().as_bytes())?;
let new_path = CString::new(new_path.as_ref().as_bytes())?;
@@ -207,7 +207,7 @@ pub unsafe fn linkat<P: AsRef<OsStr>>(
))
}
pub unsafe fn unlinkat<P: AsRef<OsStr>>(dirfd: RawFd, path: P, flags: AtFlag) -> Result<()> {
pub unsafe fn unlinkat<P: AsRef<OsStr>>(dirfd: RawFd, path: P, flags: AtFlags) -> Result<()> {
let path = CString::new(path.as_ref().as_bytes())?;
from_success_code(libc::unlinkat(dirfd, path.as_ptr(), flags.bits()))
}
@@ -238,7 +238,11 @@ pub unsafe fn symlinkat<P: AsRef<OsStr>>(old_path: P, new_dirfd: RawFd, new_path
))
}
pub unsafe fn fstatat<P: AsRef<OsStr>>(dirfd: RawFd, path: P, flags: AtFlag) -> Result<libc::stat> {
pub unsafe fn fstatat<P: AsRef<OsStr>>(
dirfd: RawFd,
path: P,
flags: AtFlags,
) -> Result<libc::stat> {
use std::mem::MaybeUninit;
let path = CString::new(path.as_ref().as_bytes())?;
let mut filestat = MaybeUninit::<libc::stat>::uninit();