diff --git a/plat/osx/include/build.lua b/plat/osx/include/build.lua index 7eb73f3aa..ff7c87a4d 100644 --- a/plat/osx/include/build.lua +++ b/plat/osx/include/build.lua @@ -9,7 +9,9 @@ local function addheader(h) end addheader("ack/config.h") +addheader("sys/dirent.h") addheader("sys/mman.h") +addheader("sys/stat.h") addheader("sys/types.h") addheader("unistd.h") diff --git a/plat/osx/include/sys/dirent.h b/plat/osx/include/sys/dirent.h new file mode 100644 index 000000000..073c84588 --- /dev/null +++ b/plat/osx/include/sys/dirent.h @@ -0,0 +1,17 @@ +#ifndef _SYS_DIRENT_H +#define _SYS_DIRENT_H + +#include + +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 diff --git a/plat/osx/include/sys/stat.h b/plat/osx/include/sys/stat.h new file mode 100644 index 000000000..6cb24902f --- /dev/null +++ b/plat/osx/include/sys/stat.h @@ -0,0 +1,49 @@ +#ifndef _SYS_STAT_H +#define _SYS_STAT_H + +#include +#include /* 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 diff --git a/plat/osx/include/sys/types.h b/plat/osx/include/sys/types.h index a9fb63277..b4561b7b3 100644 --- a/plat/osx/include/sys/types.h +++ b/plat/osx/include/sys/types.h @@ -3,7 +3,15 @@ #include /* 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 diff --git a/plat/osx/include/unistd.h b/plat/osx/include/unistd.h index 24eaf4e54..320db4a86 100644 --- a/plat/osx/include/unistd.h +++ b/plat/osx/include/unistd.h @@ -22,6 +22,11 @@ int ioctl(int, unsigned long, ...); 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; @@ -48,8 +53,6 @@ int gettimeofday(struct timeval *, struct timezone *); #define O_TRUNC 0x0400 #define O_EXCL 0x0800 -typedef int mode_t; - int creat(const char *, mode_t); int open(const char *, int, ...); diff --git a/plat/osx386/libsys/build.lua b/plat/osx386/libsys/build.lua index a5356ee6c..b3a04c8e7 100644 --- a/plat/osx386/libsys/build.lua +++ b/plat/osx386/libsys/build.lua @@ -3,17 +3,21 @@ acklibrary { 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", diff --git a/plat/osx386/libsys/fstat.s b/plat/osx386/libsys/fstat.s new file mode 100644 index 000000000..1b49ae0b7 --- /dev/null +++ b/plat/osx386/libsys/fstat.s @@ -0,0 +1,7 @@ +.sect .text +.define _fstat +_fstat: + mov eax, 189 + int 0x80 + jb .set_errno + ret diff --git a/plat/osx386/libsys/getdirentries.s b/plat/osx386/libsys/getdirentries.s new file mode 100644 index 000000000..9c59c627c --- /dev/null +++ b/plat/osx386/libsys/getdirentries.s @@ -0,0 +1,7 @@ +.sect .text +.define _getdirentries +_getdirentries: + mov eax, 196 + int 0x80 + jb .set_errno + ret diff --git a/plat/osx386/libsys/lstat.s b/plat/osx386/libsys/lstat.s new file mode 100644 index 000000000..a492cc3cb --- /dev/null +++ b/plat/osx386/libsys/lstat.s @@ -0,0 +1,7 @@ +.sect .text +.define _lstat +_lstat: + mov eax, 190 + int 0x80 + jb .set_errno + ret diff --git a/plat/osx386/libsys/stat.s b/plat/osx386/libsys/stat.s new file mode 100644 index 000000000..858d84db0 --- /dev/null +++ b/plat/osx386/libsys/stat.s @@ -0,0 +1,7 @@ +.sect .text +.define _stat +_stat: + mov eax, 188 + int 0x80 + jb .set_errno + ret diff --git a/plat/osxppc/libsys/build.lua b/plat/osxppc/libsys/build.lua index a595ed0fa..2accf6eb7 100644 --- a/plat/osxppc/libsys/build.lua +++ b/plat/osxppc/libsys/build.lua @@ -3,17 +3,21 @@ acklibrary { 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", diff --git a/plat/osxppc/libsys/fstat.s b/plat/osxppc/libsys/fstat.s new file mode 100644 index 000000000..d641cbd91 --- /dev/null +++ b/plat/osxppc/libsys/fstat.s @@ -0,0 +1,9 @@ +.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 diff --git a/plat/osxppc/libsys/getdirentries.s b/plat/osxppc/libsys/getdirentries.s new file mode 100644 index 000000000..d038c5977 --- /dev/null +++ b/plat/osxppc/libsys/getdirentries.s @@ -0,0 +1,11 @@ +.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 diff --git a/plat/osxppc/libsys/lstat.s b/plat/osxppc/libsys/lstat.s new file mode 100644 index 000000000..24d7c44ab --- /dev/null +++ b/plat/osxppc/libsys/lstat.s @@ -0,0 +1,9 @@ +.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 diff --git a/plat/osxppc/libsys/stat.s b/plat/osxppc/libsys/stat.s new file mode 100644 index 000000000..ab8422cda --- /dev/null +++ b/plat/osxppc/libsys/stat.s @@ -0,0 +1,9 @@ +.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