Usermode - Added sys/stat.h to help with cross compiles
authorJohn Hodge <[email protected]>
Sun, 25 Sep 2011 04:31:52 +0000 (12:31 +0800)
committerJohn Hodge <[email protected]>
Sun, 25 Sep 2011 04:31:52 +0000 (12:31 +0800)
Usermode/include/sys/stat.h [new file with mode: 0644]
Usermode/include/sys/types.h

diff --git a/Usermode/include/sys/stat.h b/Usermode/include/sys/stat.h
new file mode 100644 (file)
index 0000000..e9b9a8f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ */
+#ifndef _SYS_STAT_H_
+#define _SYS_STAT_H_
+
+#include <stdint.h>    //EVIL!
+
+typedef uintptr_t      dev_t;  // TODO: How to identify a device with Acess
+typedef uint64_t       ino_t;
+typedef unsigned int   blksize_t;
+typedef uint64_t       blkcnt_t;
+typedef unsigned int   nlink_t;
+typedef uint32_t       mode_t;
+
+typedef uint32_t       uid_t;
+typedef uint32_t       gid_t;
+
+#define        S_IFMT          0170000 /* type of file */
+#define                S_IFDIR 0040000 /* directory */
+#define                S_IFCHR 0020000 /* character special */
+#define                S_IFBLK 0060000 /* block special */
+#define                S_IFREG 0100000 /* regular */
+#define                S_IFLNK 0120000 /* symbolic link */
+#define                S_IFSOCK        0140000 /* socket */
+#define                S_IFIFO 0010000 /* fifo */
+
+
+struct stat
+{
+       dev_t     st_dev;     /* ID of device containing file */
+       ino_t     st_ino;     /* inode number */
+       mode_t    st_mode;    /* protection */
+       nlink_t   st_nlink;   /* number of hard links */
+       uid_t     st_uid;     /* user ID of owner */
+       gid_t     st_gid;     /* group ID of owner */
+       dev_t     st_rdev;    /* device ID (if special file) */
+       off_t     st_size;    /* total size, in bytes */
+       blksize_t st_blksize; /* blocksize for file system I/O */
+       blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
+       time_t    st_atime;   /* time of last access */
+       time_t    st_mtime;   /* time of last modification */
+       time_t    st_ctime;   /* time of last status change */
+};
+
+extern int stat(const char *path, struct stat *buf);
+extern int fstat(int fd, struct stat *buf);
+
+#endif
index 4bfba7d..acf6b7e 100644 (file)
@@ -4,19 +4,7 @@
 #define _SYS_TYPES_H
 //#include <stdint.h>
 
-typedef struct {
-       int             st_dev;         //dev_t
-       int             st_ino;         //ino_t
-       int             st_mode;        //mode_t
-       unsigned int    st_nlink;
-       unsigned int    st_uid;
-       unsigned int    st_gid;
-       int             st_rdev;        //dev_t
-       unsigned int    st_size;
-       long    st_atime;       //time_t
-       long    st_mtime;
-       long    st_ctime;
-} t_fstat;
+typedef struct stat    t_fstat;
 
 #define FD_SETSIZE     128
 
@@ -73,4 +61,6 @@ static inline int FD_ISSET(int fd, fd_set *fdsetp) {
        return !!( fdsetp->flags[fd/16] & (1<<(fd%16)) );
 }
 
+#include <sys/stat.h>
+
 #endif

UCC git Repository :: git.ucc.asn.au