From 257040e16433a315d8e167b6fd107960a3d53529 Mon Sep 17 00:00:00 2001 From: jD91mZM2 <me@krake.one> Date: Tue, 26 Jun 2018 10:47:22 +0200 Subject: [PATCH] Fix a few stat-related things --- include/bits/inttypes.h | 5 ++++ include/bits/stat.h | 11 ++++++++ src/sys_stat/cbindgen.toml | 1 + src/sys_stat/src/lib.rs | 56 +++++++++++++++++++------------------- 4 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 include/bits/stat.h diff --git a/include/bits/inttypes.h b/include/bits/inttypes.h index 996a45055..20e998c8d 100644 --- a/include/bits/inttypes.h +++ b/include/bits/inttypes.h @@ -1,3 +1,6 @@ +#ifndef _BITS_INTTYPE_H +#define _BITS_INTTYPE_H + #define PRId8 "i" #define PRId16 "i" #define PRId32 "i" @@ -188,3 +191,5 @@ #define SCNoPTR "to" #define SCNuPTR "tu" #define SCNxPTR "tx" + +#endif diff --git a/include/bits/stat.h b/include/bits/stat.h new file mode 100644 index 000000000..9f62d7ff4 --- /dev/null +++ b/include/bits/stat.h @@ -0,0 +1,11 @@ +#ifndef _BITS_STAT_H +#define _BITS_STAT_H + +#define S_ISDIR(mode) mode & S_IFMT == S_IFDIR +#define S_ISCHR(mode) mode & S_IFMT == S_IFCHR +#define S_ISBLK(mode) mode & S_IFMT == S_IFBLK +#define S_ISREG(mode) mode & S_IFMT == S_IFREG +#define S_ISIFO(mode) mode & S_IFMT == S_IFIFO +#define S_ISLNK(mode) mode & S_IFMT == S_IFLNK + +#endif diff --git a/src/sys_stat/cbindgen.toml b/src/sys_stat/cbindgen.toml index 58eced99e..cf9eef50c 100644 --- a/src/sys_stat/cbindgen.toml +++ b/src/sys_stat/cbindgen.toml @@ -1,5 +1,6 @@ sys_includes = ["sys/types.h"] include_guard = "_SYS_STAT_H" +trailer = "#include <bits/stat.h>" language = "C" style = "Tag" diff --git a/src/sys_stat/src/lib.rs b/src/sys_stat/src/lib.rs index 5b4a389d7..b34cb2480 100644 --- a/src/sys_stat/src/lib.rs +++ b/src/sys_stat/src/lib.rs @@ -6,31 +6,31 @@ extern crate platform; use platform::types::*; -pub const S_IFMT: c_int = 00170000; -pub const S_IFBLK: c_int = 0060000; -pub const S_IFCHR: c_int = 0020000; -pub const S_IFIFO: c_int = 0010000; -pub const S_IFREG: c_int = 0100000; -pub const S_IFDIR: c_int = 0040000; -pub const S_IFLNK: c_int = 0120000; - -pub const S_IRWXU: c_int = 00700; -pub const S_IRUSR: c_int = 00400; -pub const S_IWUSR: c_int = 00200; -pub const S_IXUSR: c_int = 00100; - -pub const S_IRWXG: c_int = 00070; -pub const S_IRGRP: c_int = 00040; -pub const S_IWGRP: c_int = 00020; -pub const S_IXGRP: c_int = 00010; - -pub const S_IRWXO: c_int = 00007; -pub const S_IROTH: c_int = 00004; -pub const S_IWOTH: c_int = 00002; -pub const S_IXOTH: c_int = 00001; -pub const S_ISUID: c_int = 04000; -pub const S_ISGID: c_int = 02000; -pub const S_ISVTX: c_int = 01000; +pub const S_IFMT: c_int = 0o0170000; +pub const S_IFBLK: c_int = 0o060000; +pub const S_IFCHR: c_int = 0o020000; +pub const S_IFIFO: c_int = 0o010000; +pub const S_IFREG: c_int = 0o100000; +pub const S_IFDIR: c_int = 0o040000; +pub const S_IFLNK: c_int = 0o120000; + +pub const S_IRWXU: c_int = 0o0700; +pub const S_IRUSR: c_int = 0o0400; +pub const S_IWUSR: c_int = 0o0200; +pub const S_IXUSR: c_int = 0o0100; + +pub const S_IRWXG: c_int = 0o0070; +pub const S_IRGRP: c_int = 0o0040; +pub const S_IWGRP: c_int = 0o0020; +pub const S_IXGRP: c_int = 0o0010; + +pub const S_IRWXO: c_int = 0o0007; +pub const S_IROTH: c_int = 0o0004; +pub const S_IWOTH: c_int = 0o0002; +pub const S_IXOTH: c_int = 0o0001; +pub const S_ISUID: c_int = 0o4000; +pub const S_ISGID: c_int = 0o2000; +pub const S_ISVTX: c_int = 0o1000; #[repr(C)] pub struct stat { @@ -43,9 +43,9 @@ pub struct stat { pub st_rdev: dev_t, pub st_size: off_t, pub st_blksize: blksize_t, - pub st_atim: time_t, - pub st_mtim: time_t, - pub st_ctim: time_t, + pub st_atime: time_t, + pub st_mtime: time_t, + pub st_ctime: time_t, pub st_blocks: blkcnt_t, } -- GitLab