Skip to content

chore: minor cleanup mode_t usage #4405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 28 additions & 34 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,9 +1452,9 @@ pub const GRPQUOTA: c_int = 1;

pub const SIGIOT: c_int = 6;

pub const S_ISUID: crate::mode_t = 0o4000;
pub const S_ISGID: crate::mode_t = 0o2000;
pub const S_ISVTX: crate::mode_t = 0o1000;
pub const S_ISUID: mode_t = 0o4000;
pub const S_ISGID: mode_t = 0o2000;
pub const S_ISVTX: mode_t = 0o1000;

pub const IF_NAMESIZE: size_t = 16;
pub const IFNAMSIZ: size_t = IF_NAMESIZE;
Expand Down Expand Up @@ -1585,26 +1585,26 @@ pub const O_RDONLY: c_int = 0;
pub const O_WRONLY: c_int = 1;
pub const O_RDWR: c_int = 2;

pub const S_IFIFO: crate::mode_t = 0o1_0000;
pub const S_IFCHR: crate::mode_t = 0o2_0000;
pub const S_IFBLK: crate::mode_t = 0o6_0000;
pub const S_IFDIR: crate::mode_t = 0o4_0000;
pub const S_IFREG: crate::mode_t = 0o10_0000;
pub const S_IFLNK: crate::mode_t = 0o12_0000;
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
pub const S_IFMT: crate::mode_t = 0o17_0000;
pub const S_IRWXU: crate::mode_t = 0o0700;
pub const S_IXUSR: crate::mode_t = 0o0100;
pub const S_IWUSR: crate::mode_t = 0o0200;
pub const S_IRUSR: crate::mode_t = 0o0400;
pub const S_IRWXG: crate::mode_t = 0o0070;
pub const S_IXGRP: crate::mode_t = 0o0010;
pub const S_IWGRP: crate::mode_t = 0o0020;
pub const S_IRGRP: crate::mode_t = 0o0040;
pub const S_IRWXO: crate::mode_t = 0o0007;
pub const S_IXOTH: crate::mode_t = 0o0001;
pub const S_IWOTH: crate::mode_t = 0o0002;
pub const S_IROTH: crate::mode_t = 0o0004;
pub const S_IFIFO: mode_t = 0o1_0000;
pub const S_IFCHR: mode_t = 0o2_0000;
pub const S_IFBLK: mode_t = 0o6_0000;
pub const S_IFDIR: mode_t = 0o4_0000;
pub const S_IFREG: mode_t = 0o10_0000;
pub const S_IFLNK: mode_t = 0o12_0000;
pub const S_IFSOCK: mode_t = 0o14_0000;
pub const S_IFMT: mode_t = 0o17_0000;
pub const S_IRWXU: mode_t = 0o0700;
pub const S_IXUSR: mode_t = 0o0100;
pub const S_IWUSR: mode_t = 0o0200;
pub const S_IRUSR: mode_t = 0o0400;
pub const S_IRWXG: mode_t = 0o0070;
pub const S_IXGRP: mode_t = 0o0010;
pub const S_IWGRP: mode_t = 0o0020;
pub const S_IRGRP: mode_t = 0o0040;
pub const S_IRWXO: mode_t = 0o0007;
pub const S_IXOTH: mode_t = 0o0001;
pub const S_IWOTH: mode_t = 0o0002;
pub const S_IROTH: mode_t = 0o0004;
pub const F_OK: c_int = 0;
pub const R_OK: c_int = 4;
pub const W_OK: c_int = 2;
Expand Down Expand Up @@ -3726,12 +3726,7 @@ extern "C" {
pub fn rewinddir(dirp: *mut crate::DIR);

pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
pub fn fchmodat(
dirfd: c_int,
pathname: *const c_char,
mode: crate::mode_t,
flags: c_int,
) -> c_int;
pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int;
pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
pub fn fchownat(
dirfd: c_int,
Expand All @@ -3748,7 +3743,7 @@ extern "C" {
newpath: *const c_char,
flags: c_int,
) -> c_int;
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn readlinkat(
dirfd: c_int,
pathname: *const c_char,
Expand Down Expand Up @@ -3959,7 +3954,7 @@ extern "C" {
pub fn gmtime(time_p: *const time_t) -> *mut tm;
pub fn localtime(time_p: *const time_t) -> *mut tm;

pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int;
pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int;
pub fn uname(buf: *mut crate::utsname) -> c_int;
pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent;
Expand Down Expand Up @@ -4079,8 +4074,7 @@ extern "C" {

pub fn fdopendir(fd: c_int) -> *mut crate::DIR;

pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn pthread_condattr_getclock(
attr: *const pthread_condattr_t,
clock_id: *mut clockid_t,
Expand Down Expand Up @@ -4205,7 +4199,7 @@ extern "C" {
pub fn setfsuid(uid: crate::uid_t) -> c_int;

// Not available now on Android
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn if_nameindex() -> *mut if_nameindex;
pub fn if_freenameindex(ptr: *mut if_nameindex);
pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;
Expand Down
9 changes: 4 additions & 5 deletions src/unix/aix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2877,9 +2877,8 @@ extern "C" {
) -> *mut c_void;
pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int;
pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int;
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
pub fn mq_close(mqd: crate::mqd_t) -> c_int;
Expand Down Expand Up @@ -2973,7 +2972,7 @@ extern "C" {
fd: c_int,
path: *const c_char,
oflag: c_int,
mode: crate::mode_t,
mode: mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
Expand Down Expand Up @@ -3138,7 +3137,7 @@ extern "C" {
pub fn shmdt(shmaddr: *const c_void) -> c_int;
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
pub fn shm_unlink(name: *const c_char) -> c_int;
pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int;
pub fn srand(seed: c_uint);
Expand Down
9 changes: 4 additions & 5 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ s! {
pub gid: crate::gid_t,
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub mode: mode_t,
pub _seq: c_ushort,
pub _key: crate::key_t,
}
Expand Down Expand Up @@ -6151,7 +6151,7 @@ extern "C" {
fd: c_int,
path: *const c_char,
oflag: c_int,
mode: crate::mode_t,
mode: mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_addclose(
actions: *mut posix_spawn_file_actions_t,
Expand Down Expand Up @@ -6449,9 +6449,8 @@ extern "C" {
pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;

pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int;
pub fn execvP(
file: *const c_char,
Expand Down
11 changes: 5 additions & 6 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ s! {
pub cgid: crate::gid_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub mode: crate::mode_t,
pub mode: mode_t,
pub seq: c_ushort,
pub key: crate::key_t,
}
Expand Down Expand Up @@ -1598,13 +1598,12 @@ extern "C" {
pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int;
pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
#[cfg_attr(
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "mknodat@FBSD_1.1"
)]
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
Expand Down Expand Up @@ -1726,7 +1725,7 @@ extern "C" {
pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int;
pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int;
pub fn setutxent();
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
pub fn sigtimedwait(
set: *const sigset_t,
info: *mut siginfo_t,
Expand Down Expand Up @@ -1868,7 +1867,7 @@ extern "C" {
fd: c_int,
path: *const c_char,
oflag: c_int,
mode: crate::mode_t,
mode: mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_addclose(
actions: *mut posix_spawn_file_actions_t,
Expand Down
11 changes: 5 additions & 6 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ s! {
pub cgid: crate::gid_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub mode: crate::mode_t,
pub mode: mode_t,
#[cfg(target_os = "openbsd")]
pub seq: c_ushort,
#[cfg(target_os = "netbsd")]
Expand Down Expand Up @@ -687,7 +687,7 @@ extern "C" {
#[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")]
pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
pub fn __errno() -> *mut c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;
Expand All @@ -705,9 +705,8 @@ extern "C" {
pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;

pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
pub fn pthread_condattr_setclock(
Expand Down Expand Up @@ -825,7 +824,7 @@ extern "C" {
fd: c_int,
path: *const c_char,
oflag: c_int,
mode: crate::mode_t,
mode: mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_addclose(
actions: *mut posix_spawn_file_actions_t,
Expand Down
53 changes: 26 additions & 27 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ s! {
pub gid: crate::gid_t,
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub mode: mode_t,
}

pub struct sembuf {
Expand Down Expand Up @@ -774,27 +774,27 @@ pub const O_NOFOLLOW: c_int = 0x00080000;
pub const O_NOCACHE: c_int = 0x00100000;
pub const O_DIRECTORY: c_int = 0x00200000;

pub const S_IFIFO: crate::mode_t = 0o1_0000;
pub const S_IFCHR: crate::mode_t = 0o2_0000;
pub const S_IFBLK: crate::mode_t = 0o6_0000;
pub const S_IFDIR: crate::mode_t = 0o4_0000;
pub const S_IFREG: crate::mode_t = 0o10_0000;
pub const S_IFLNK: crate::mode_t = 0o12_0000;
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
pub const S_IFMT: crate::mode_t = 0o17_0000;

pub const S_IRWXU: crate::mode_t = 0o0700;
pub const S_IRUSR: crate::mode_t = 0o0400;
pub const S_IWUSR: crate::mode_t = 0o0200;
pub const S_IXUSR: crate::mode_t = 0o0100;
pub const S_IRWXG: crate::mode_t = 0o0070;
pub const S_IRGRP: crate::mode_t = 0o0040;
pub const S_IWGRP: crate::mode_t = 0o0020;
pub const S_IXGRP: crate::mode_t = 0o0010;
pub const S_IRWXO: crate::mode_t = 0o0007;
pub const S_IROTH: crate::mode_t = 0o0004;
pub const S_IWOTH: crate::mode_t = 0o0002;
pub const S_IXOTH: crate::mode_t = 0o0001;
pub const S_IFIFO: mode_t = 0o1_0000;
pub const S_IFCHR: mode_t = 0o2_0000;
pub const S_IFBLK: mode_t = 0o6_0000;
pub const S_IFDIR: mode_t = 0o4_0000;
pub const S_IFREG: mode_t = 0o10_0000;
pub const S_IFLNK: mode_t = 0o12_0000;
pub const S_IFSOCK: mode_t = 0o14_0000;
pub const S_IFMT: mode_t = 0o17_0000;

pub const S_IRWXU: mode_t = 0o0700;
pub const S_IRUSR: mode_t = 0o0400;
pub const S_IWUSR: mode_t = 0o0200;
pub const S_IXUSR: mode_t = 0o0100;
pub const S_IRWXG: mode_t = 0o0070;
pub const S_IRGRP: mode_t = 0o0040;
pub const S_IWGRP: mode_t = 0o0020;
pub const S_IXGRP: mode_t = 0o0010;
pub const S_IRWXO: mode_t = 0o0007;
pub const S_IROTH: mode_t = 0o0004;
pub const S_IWOTH: mode_t = 0o0002;
pub const S_IXOTH: mode_t = 0o0001;

pub const F_OK: c_int = 0;
pub const R_OK: c_int = 4;
Expand Down Expand Up @@ -1731,9 +1731,8 @@ extern "C" {
bufferSize: size_t,
res: *mut *mut spwd,
) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
-> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn sem_destroy(sem: *mut sem_t) -> c_int;
pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;

Expand Down Expand Up @@ -1811,7 +1810,7 @@ extern "C" {
pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int;
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;

pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
pub fn shm_unlink(name: *const c_char) -> c_int;

pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
Expand Down Expand Up @@ -2027,7 +2026,7 @@ extern "C" {
fildes: c_int,
path: *const c_char,
oflag: c_int,
mode: crate::mode_t,
mode: mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_addclose(
file_actions: *mut posix_spawn_file_actions_t,
Expand Down
Loading
Loading