end
addheader("ack/config.h")
+addheader("sys/dirent.h")
addheader("sys/mman.h")
+addheader("sys/stat.h")
addheader("sys/types.h")
addheader("unistd.h")
--- /dev/null
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <sys/types.h>
+
+struct dirent {
+ ino_t d_ino;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ unsigned char d_namlen;
+#define MAXNAMLEN 255
+ char d_name[MAXNAMLEN + 1];
+};
+
+int getdirentries(int, char *, int, long *);
+
+#endif
--- /dev/null
+#ifndef _SYS_STAT_H
+#define _SYS_STAT_H
+
+#include <sys/types.h>
+#include <sys/time.h> /* for timespec */
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+#define st_atime st_atim.tv_sec
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
+ /*
+ * XXX - We don't have 64-bit integers, so we only expose the
+ * lower 32 bits of 64-bit fields. We insert dummy fields for
+ * the higher 32 bits.
+ */
+#if defined(__i386)
+ off_t st_size;
+ off_t _st_size_hi;
+ blkcnt_t st_blocks;
+ blkcnt_t _st_blkcnt_hi;
+#elif defined(__powerpc)
+ off_t _st_size_hi;
+ off_t st_size;
+ blkcnt_t _st_blkcnt_hi;
+ blkcnt_t st_blkcnt;
+#else
+#error unknown arch
+#endif
+ blksize_t st_blksize;
+ unsigned int st_flags;
+ unsigned int st_gen;
+ unsigned int _st_spare[5];
+};
+
+int fstat(int, struct stat *);
+int lstat(const char *, struct stat *);
+int stat(const char *, struct stat *);
+
+#endif
#include <stddef.h> /* for off_t, ptrdiff_t, size_t */
-typedef int pid_t;
-typedef ptrdiff_t ssize_t;
+typedef int blkcnt_t; /* XXX should have 64 bits */
+typedef int blksize_t;
+typedef int dev_t;
+typedef unsigned int gid_t;
+typedef unsigned int ino_t;
+typedef unsigned short mode_t;
+typedef unsigned short nlink_t;
+typedef int pid_t;
+typedef ptrdiff_t ssize_t;
+typedef unsigned int uid_t;
#endif
typedef long _libsys_time_t;
typedef int suseconds_t;
+struct timespec {
+ _libsys_time_t tv_sec;
+ long tv_nsec;
+};
+
struct timeval {
_libsys_time_t tv_sec;
suseconds_t tv_usec;
#define O_TRUNC 0x0400
#define O_EXCL 0x0800
-typedef int mode_t;
-
int creat(const char *, mode_t);
int open(const char *, int, ...);
srcs = {
"./_exit.s",
"./close.s",
+ "./fstat.s",
+ "./getdirentries.s",
"./getpid.s",
"./gettimeofday.s",
"./ioctl.s",
"./kill.s",
"./lseek.s",
+ "./lstat.s",
"./mmap.s",
"./mprotect.s",
"./open.s",
"./read.s",
"./set_errno.s",
"./sigaction.s",
+ "./stat.s",
"./write.s",
"plat/linux/libsys/errno.s",
"plat/osx/libsys/brk.c",
--- /dev/null
+.sect .text
+.define _fstat
+_fstat:
+ mov eax, 189
+ int 0x80
+ jb .set_errno
+ ret
--- /dev/null
+.sect .text
+.define _getdirentries
+_getdirentries:
+ mov eax, 196
+ int 0x80
+ jb .set_errno
+ ret
--- /dev/null
+.sect .text
+.define _lstat
+_lstat:
+ mov eax, 190
+ int 0x80
+ jb .set_errno
+ ret
--- /dev/null
+.sect .text
+.define _stat
+_stat:
+ mov eax, 188
+ int 0x80
+ jb .set_errno
+ ret
srcs = {
"./_exit.s",
"./close.s",
+ "./fstat.s",
+ "./getdirentries.s",
"./getpid.s",
"./gettimeofday.s",
"./ioctl.s",
"./kill.s",
"./lseek.s",
+ "./lstat.s",
"./mmap.s",
"./mprotect.s",
"./open.s",
"./read.s",
"./set_errno.s",
"./sigaction.s",
+ "./stat.s",
"./write.s",
"plat/linuxppc/libsys/trap.s",
"plat/osx/libsys/brk.c",
--- /dev/null
+.sect .text
+.define _fstat
+_fstat:
+ addi r0, r0, 189 ! fstat
+ lwz r3, 0(sp) ! fd
+ lwz r4, 4(sp) ! stat pointer
+ sc 0
+ b .set_errno
+ bclr 20, 0, 0
--- /dev/null
+.sect .text
+.define _getdirentries
+_getdirentries:
+ addi r0, r0, 196 ! getdirentries
+ lwz r3, 0(sp) ! fd
+ lwz r4, 4(sp) ! buffer
+ lwz r5, 8(sp) ! buffer size
+ lwz r6, 12(sp) ! base pointer
+ sc 0
+ b .set_errno
+ bclr 20, 0, 0
--- /dev/null
+.sect .text
+.define _lstat
+_lstat:
+ addi r0, r0, 190 ! lstat
+ lwz r3, 0(sp) ! path
+ lwz r4, 4(sp) ! stat pointer
+ sc 0
+ b .set_errno
+ bclr 20, 0, 0
--- /dev/null
+.sect .text
+.define _stat
+_stat:
+ addi r0, r0, 188 ! stat
+ lwz r3, 0(sp) ! path
+ lwz r4, 4(sp) ! stat pointer
+ sc 0
+ b .set_errno
+ bclr 20, 0, 0