Skip to content

Commit

Permalink
Auto merge of #2841 - asomers:openbsd-chflags, r=Amanieu
Browse files Browse the repository at this point in the history
Fix the type of file flags on OpenBSD

In C they're defined as macros, but since they're used with chflags(2)
they should have the same type as that function's flags argument.
  • Loading branch information
bors committed Jul 12, 2022
2 parents 8fdcb90 + 27264ed commit 8dbd2c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 0 additions & 11 deletions src/unix/bsd/netbsdlike/mod.rs
Expand Up @@ -639,17 +639,6 @@ pub const TIOCM_DSR: ::c_int = 0o0400;
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
pub const TIOCM_RI: ::c_int = TIOCM_RNG;

// Flags for chflags(2)
pub const UF_SETTABLE: ::c_ulong = 0x0000ffff;
pub const UF_NODUMP: ::c_ulong = 0x00000001;
pub const UF_IMMUTABLE: ::c_ulong = 0x00000002;
pub const UF_APPEND: ::c_ulong = 0x00000004;
pub const UF_OPAQUE: ::c_ulong = 0x00000008;
pub const SF_SETTABLE: ::c_ulong = 0xffff0000;
pub const SF_ARCHIVED: ::c_ulong = 0x00010000;
pub const SF_IMMUTABLE: ::c_ulong = 0x00020000;
pub const SF_APPEND: ::c_ulong = 0x00040000;

pub const TIMER_ABSTIME: ::c_int = 1;

#[link(name = "util")]
Expand Down
11 changes: 10 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/mod.rs
Expand Up @@ -2228,9 +2228,18 @@ pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20;
pub const POSIX_SPAWN_RETURNERROR: ::c_int = 0x40;

// Flags for chflags(2)
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
pub const SF_APPEND: ::c_ulong = 0x00040000;
pub const SF_ARCHIVED: ::c_ulong = 0x00010000;
pub const SF_IMMUTABLE: ::c_ulong = 0x00020000;
pub const SF_LOG: ::c_ulong = 0x00400000;
pub const SF_SETTABLE: ::c_ulong = 0xffff0000;
pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
pub const UF_APPEND: ::c_ulong = 0x00000004;
pub const UF_IMMUTABLE: ::c_ulong = 0x00000002;
pub const UF_NODUMP: ::c_ulong = 0x00000001;
pub const UF_OPAQUE: ::c_ulong = 0x00000008;
pub const UF_SETTABLE: ::c_ulong = 0x0000ffff;

// sys/sysctl.h
pub const KVME_PROT_READ: ::c_int = 0x00000001;
Expand Down
11 changes: 11 additions & 0 deletions src/unix/bsd/netbsdlike/openbsd/mod.rs
Expand Up @@ -1628,6 +1628,17 @@ pub const EPROC_SLEADER: i32 = 0x02; // session leader
pub const EPROC_UNVEIL: i32 = 0x04; // has unveil settings
pub const EPROC_LKUNVEIL: i32 = 0x08; // unveil is locked

// Flags for chflags(2)
pub const UF_SETTABLE: ::c_uint = 0x0000ffff;
pub const UF_NODUMP: ::c_uint = 0x00000001;
pub const UF_IMMUTABLE: ::c_uint = 0x00000002;
pub const UF_APPEND: ::c_uint = 0x00000004;
pub const UF_OPAQUE: ::c_uint = 0x00000008;
pub const SF_SETTABLE: ::c_uint = 0xffff0000;
pub const SF_ARCHIVED: ::c_uint = 0x00010000;
pub const SF_IMMUTABLE: ::c_uint = 0x00020000;
pub const SF_APPEND: ::c_uint = 0x00040000;

const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
Expand Down

0 comments on commit 8dbd2c9

Please sign in to comment.