Quellcode durchsuchen

Fix a few stat-related things

jD91mZM2 vor 6 Jahren
Ursprung
Commit
257040e164
4 geänderte Dateien mit 45 neuen und 28 gelöschten Zeilen
  1. 5 0
      include/bits/inttypes.h
  2. 11 0
      include/bits/stat.h
  3. 1 0
      src/sys_stat/cbindgen.toml
  4. 28 28
      src/sys_stat/src/lib.rs

+ 5 - 0
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

+ 11 - 0
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

+ 1 - 0
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"
 

+ 28 - 28
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,
 }