summaryrefslogtreecommitdiff
path: root/05/musl-0.6.0/src/unistd
diff options
context:
space:
mode:
Diffstat (limited to '05/musl-0.6.0/src/unistd')
-rw-r--r--05/musl-0.6.0/src/unistd/_exit.c7
-rw-r--r--05/musl-0.6.0/src/unistd/access.c7
-rw-r--r--05/musl-0.6.0/src/unistd/alarm.c7
-rw-r--r--05/musl-0.6.0/src/unistd/chdir.c7
-rw-r--r--05/musl-0.6.0/src/unistd/chown.c7
-rw-r--r--05/musl-0.6.0/src/unistd/close.c11
-rw-r--r--05/musl-0.6.0/src/unistd/ctermid.c23
-rw-r--r--05/musl-0.6.0/src/unistd/dup.c7
-rw-r--r--05/musl-0.6.0/src/unistd/dup2.c7
-rw-r--r--05/musl-0.6.0/src/unistd/faccessat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/fchdir.c7
-rw-r--r--05/musl-0.6.0/src/unistd/fchown.c7
-rw-r--r--05/musl-0.6.0/src/unistd/fchownat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/fdatasync.c7
-rw-r--r--05/musl-0.6.0/src/unistd/fsync.c8
-rw-r--r--05/musl-0.6.0/src/unistd/ftruncate.c10
-rw-r--r--05/musl-0.6.0/src/unistd/getcwd.c8
-rw-r--r--05/musl-0.6.0/src/unistd/getegid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/geteuid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getgid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getgroups.c7
-rw-r--r--05/musl-0.6.0/src/unistd/gethostname.c14
-rw-r--r--05/musl-0.6.0/src/unistd/getlogin.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getlogin_r.c13
-rw-r--r--05/musl-0.6.0/src/unistd/getpgid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getpgrp.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getpid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getppid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getsid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/getuid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/isatty.c8
-rw-r--r--05/musl-0.6.0/src/unistd/lchown.c7
-rw-r--r--05/musl-0.6.0/src/unistd/link.c7
-rw-r--r--05/musl-0.6.0/src/unistd/linkat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/lseek.c15
-rw-r--r--05/musl-0.6.0/src/unistd/nice.c12
-rw-r--r--05/musl-0.6.0/src/unistd/pause.c12
-rw-r--r--05/musl-0.6.0/src/unistd/pipe.c7
-rw-r--r--05/musl-0.6.0/src/unistd/pread.c14
-rw-r--r--05/musl-0.6.0/src/unistd/pwrite.c14
-rw-r--r--05/musl-0.6.0/src/unistd/read.c12
-rw-r--r--05/musl-0.6.0/src/unistd/readlink.c7
-rw-r--r--05/musl-0.6.0/src/unistd/readlinkat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/readv.c12
-rw-r--r--05/musl-0.6.0/src/unistd/renameat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/rmdir.c7
-rw-r--r--05/musl-0.6.0/src/unistd/setegid.c6
-rw-r--r--05/musl-0.6.0/src/unistd/seteuid.c6
-rw-r--r--05/musl-0.6.0/src/unistd/setgid.c9
-rw-r--r--05/musl-0.6.0/src/unistd/setpgid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/setpgrp.c6
-rw-r--r--05/musl-0.6.0/src/unistd/setregid.c9
-rw-r--r--05/musl-0.6.0/src/unistd/setreuid.c9
-rw-r--r--05/musl-0.6.0/src/unistd/setsid.c7
-rw-r--r--05/musl-0.6.0/src/unistd/setuid.c9
-rw-r--r--05/musl-0.6.0/src/unistd/sleep.c10
-rw-r--r--05/musl-0.6.0/src/unistd/symlink.c7
-rw-r--r--05/musl-0.6.0/src/unistd/symlinkat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/sync.c7
-rw-r--r--05/musl-0.6.0/src/unistd/tcgetpgrp.c11
-rw-r--r--05/musl-0.6.0/src/unistd/tcsetpgrp.c9
-rw-r--r--05/musl-0.6.0/src/unistd/truncate.c10
-rw-r--r--05/musl-0.6.0/src/unistd/ttyname.c14
-rw-r--r--05/musl-0.6.0/src/unistd/ttyname_r.c19
-rw-r--r--05/musl-0.6.0/src/unistd/ualarm.c8
-rw-r--r--05/musl-0.6.0/src/unistd/unlink.c7
-rw-r--r--05/musl-0.6.0/src/unistd/unlinkat.c7
-rw-r--r--05/musl-0.6.0/src/unistd/usleep.c11
-rw-r--r--05/musl-0.6.0/src/unistd/write.c12
-rw-r--r--05/musl-0.6.0/src/unistd/writev.c12
70 files changed, 622 insertions, 0 deletions
diff --git a/05/musl-0.6.0/src/unistd/_exit.c b/05/musl-0.6.0/src/unistd/_exit.c
new file mode 100644
index 0000000..d2e84c4
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/_exit.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include <stdlib.h>
+
+void _exit(int status)
+{
+ _Exit(status);
+}
diff --git a/05/musl-0.6.0/src/unistd/access.c b/05/musl-0.6.0/src/unistd/access.c
new file mode 100644
index 0000000..2c10e58
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/access.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int access(const char *filename, int amode)
+{
+ return syscall2(__NR_access, (long)filename, amode);
+}
diff --git a/05/musl-0.6.0/src/unistd/alarm.c b/05/musl-0.6.0/src/unistd/alarm.c
new file mode 100644
index 0000000..bba444d
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/alarm.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+unsigned alarm(unsigned seconds)
+{
+ return syscall1(__NR_alarm, seconds);
+}
diff --git a/05/musl-0.6.0/src/unistd/chdir.c b/05/musl-0.6.0/src/unistd/chdir.c
new file mode 100644
index 0000000..c89bda3
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/chdir.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int chdir(const char *path)
+{
+ return syscall1(__NR_chdir, (long)path);
+}
diff --git a/05/musl-0.6.0/src/unistd/chown.c b/05/musl-0.6.0/src/unistd/chown.c
new file mode 100644
index 0000000..b89b173
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/chown.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int chown(const char *path, uid_t uid, gid_t gid)
+{
+ return syscall3(__NR_chown, (long)path, uid, gid);
+}
diff --git a/05/musl-0.6.0/src/unistd/close.c b/05/musl-0.6.0/src/unistd/close.c
new file mode 100644
index 0000000..97302f6
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/close.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int close(int fd)
+{
+ int ret = __syscall_close(fd);
+ CANCELPT_BEGIN;
+ CANCELPT_END;
+ return ret;
+}
diff --git a/05/musl-0.6.0/src/unistd/ctermid.c b/05/musl-0.6.0/src/unistd/ctermid.c
new file mode 100644
index 0000000..21b44ec
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/ctermid.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+
+char *ctermid(char *s)
+{
+ static char *s2;
+ int fd;
+ if (!s) {
+ if (!s2) s2 = malloc(L_ctermid);
+ s = s2;
+ }
+ fd = open("/dev/tty", O_WRONLY | O_NOCTTY);
+ if (fd < 0)
+ return strcpy(s, "");
+ if (ttyname_r(fd, s, L_ctermid))
+ strcpy(s, "");
+ close(fd);
+ return s;
+}
diff --git a/05/musl-0.6.0/src/unistd/dup.c b/05/musl-0.6.0/src/unistd/dup.c
new file mode 100644
index 0000000..b11cd71
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/dup.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int dup(int fd)
+{
+ return syscall1(__NR_dup, fd);
+}
diff --git a/05/musl-0.6.0/src/unistd/dup2.c b/05/musl-0.6.0/src/unistd/dup2.c
new file mode 100644
index 0000000..9332544
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/dup2.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int dup2(int old, int new)
+{
+ return __syscall_dup2(old, new);
+}
diff --git a/05/musl-0.6.0/src/unistd/faccessat.c b/05/musl-0.6.0/src/unistd/faccessat.c
new file mode 100644
index 0000000..99a9378
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/faccessat.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int faccessat(int fd, const char *filename, int amode, int flag)
+{
+ return syscall4(__NR_faccessat, fd, (long)filename, amode, flag);
+}
diff --git a/05/musl-0.6.0/src/unistd/fchdir.c b/05/musl-0.6.0/src/unistd/fchdir.c
new file mode 100644
index 0000000..b2acbc2
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/fchdir.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int fchdir(int fd)
+{
+ return syscall1(__NR_fchdir, fd);
+}
diff --git a/05/musl-0.6.0/src/unistd/fchown.c b/05/musl-0.6.0/src/unistd/fchown.c
new file mode 100644
index 0000000..6050b77
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/fchown.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int fchown(int fd, uid_t uid, gid_t gid)
+{
+ return syscall3(__NR_fchown, fd, uid, gid);
+}
diff --git a/05/musl-0.6.0/src/unistd/fchownat.c b/05/musl-0.6.0/src/unistd/fchownat.c
new file mode 100644
index 0000000..7062642
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/fchownat.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag)
+{
+ return syscall5(__NR_fchownat, fd, (long)path, uid, gid, flag);
+}
diff --git a/05/musl-0.6.0/src/unistd/fdatasync.c b/05/musl-0.6.0/src/unistd/fdatasync.c
new file mode 100644
index 0000000..ef7c9a9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/fdatasync.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int fdatasync(int fd)
+{
+ return 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/fsync.c b/05/musl-0.6.0/src/unistd/fsync.c
new file mode 100644
index 0000000..7cfedc9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/fsync.c
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int fsync(int fd)
+{
+ //return syscall1(__NR_fsync, fd);
+ return 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/ftruncate.c b/05/musl-0.6.0/src/unistd/ftruncate.c
new file mode 100644
index 0000000..db5da84
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/ftruncate.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int ftruncate(int fd, off_t length)
+{
+ return syscall3(__NR_ftruncate, fd, SYSCALL_LL(length));
+}
+
+LFS64(ftruncate);
diff --git a/05/musl-0.6.0/src/unistd/getcwd.c b/05/musl-0.6.0/src/unistd/getcwd.c
new file mode 100644
index 0000000..4910f42
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getcwd.c
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <errno.h>
+#include "syscall.h"
+
+char *getcwd(char *buf, size_t size)
+{
+ return syscall2(__NR_getcwd, (long)buf, size) < 0 ? NULL : buf;
+}
diff --git a/05/musl-0.6.0/src/unistd/getegid.c b/05/musl-0.6.0/src/unistd/getegid.c
new file mode 100644
index 0000000..33ee205
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getegid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+gid_t getegid(void)
+{
+ return syscall0(__NR_getegid);
+}
diff --git a/05/musl-0.6.0/src/unistd/geteuid.c b/05/musl-0.6.0/src/unistd/geteuid.c
new file mode 100644
index 0000000..cdec631
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/geteuid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+uid_t geteuid(void)
+{
+ return syscall0(__NR_geteuid);
+}
diff --git a/05/musl-0.6.0/src/unistd/getgid.c b/05/musl-0.6.0/src/unistd/getgid.c
new file mode 100644
index 0000000..8a4590b
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getgid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+gid_t getgid(void)
+{
+ return syscall0(__NR_getgid);
+}
diff --git a/05/musl-0.6.0/src/unistd/getgroups.c b/05/musl-0.6.0/src/unistd/getgroups.c
new file mode 100644
index 0000000..37619b9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getgroups.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int getgroups(int count, gid_t list[])
+{
+ return syscall2(__NR_getgroups, count, (long)list);
+}
diff --git a/05/musl-0.6.0/src/unistd/gethostname.c b/05/musl-0.6.0/src/unistd/gethostname.c
new file mode 100644
index 0000000..a406c4e
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/gethostname.c
@@ -0,0 +1,14 @@
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <string.h>
+
+int gethostname(char *name, size_t len)
+{
+ size_t i;
+ struct utsname uts;
+ if (uname(&uts)) return -1;
+ if (len > sizeof uts.nodename) len = sizeof uts.nodename;
+ for (i=0; i<len && (name[i] = uts.nodename[i]); i++);
+ if (i==len) name[i-1] = 0;
+ return 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/getlogin.c b/05/musl-0.6.0/src/unistd/getlogin.c
new file mode 100644
index 0000000..0601191
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getlogin.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include <stdlib.h>
+
+char *getlogin(void)
+{
+ return getenv("LOGNAME");
+}
diff --git a/05/musl-0.6.0/src/unistd/getlogin_r.c b/05/musl-0.6.0/src/unistd/getlogin_r.c
new file mode 100644
index 0000000..f04f71e
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getlogin_r.c
@@ -0,0 +1,13 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+int getlogin_r(char *name, size_t size)
+{
+ char *logname = getlogin();
+ if (!logname) return ENXIO; /* or...? */
+ if (strlen(name) >= size) return ERANGE;
+ strcpy(name, logname);
+ return 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/getpgid.c b/05/musl-0.6.0/src/unistd/getpgid.c
new file mode 100644
index 0000000..50d716b
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getpgid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t getpgid(pid_t pid)
+{
+ return syscall1(__NR_getpgid, pid);
+}
diff --git a/05/musl-0.6.0/src/unistd/getpgrp.c b/05/musl-0.6.0/src/unistd/getpgrp.c
new file mode 100644
index 0000000..2004630
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getpgrp.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t getpgrp(void)
+{
+ return syscall0(__NR_getpgrp);
+}
diff --git a/05/musl-0.6.0/src/unistd/getpid.c b/05/musl-0.6.0/src/unistd/getpid.c
new file mode 100644
index 0000000..31cbe1c
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getpid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t getpid(void)
+{
+ return syscall0(__NR_getpid);
+}
diff --git a/05/musl-0.6.0/src/unistd/getppid.c b/05/musl-0.6.0/src/unistd/getppid.c
new file mode 100644
index 0000000..a324182
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getppid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t getppid(void)
+{
+ return syscall0(__NR_getppid);
+}
diff --git a/05/musl-0.6.0/src/unistd/getsid.c b/05/musl-0.6.0/src/unistd/getsid.c
new file mode 100644
index 0000000..064229c
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getsid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t getsid(pid_t pid)
+{
+ return syscall1(__NR_getsid, pid);
+}
diff --git a/05/musl-0.6.0/src/unistd/getuid.c b/05/musl-0.6.0/src/unistd/getuid.c
new file mode 100644
index 0000000..cd7233d
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/getuid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+uid_t getuid(void)
+{
+ return syscall0(__NR_getuid);
+}
diff --git a/05/musl-0.6.0/src/unistd/isatty.c b/05/musl-0.6.0/src/unistd/isatty.c
new file mode 100644
index 0000000..cff6e9f
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/isatty.c
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <termios.h>
+
+int isatty(int fd)
+{
+ struct termios t;
+ return tcgetattr(fd, &t) == 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/lchown.c b/05/musl-0.6.0/src/unistd/lchown.c
new file mode 100644
index 0000000..a840213
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/lchown.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int lchown(const char *path, uid_t uid, gid_t gid)
+{
+ return syscall3(__NR_lchown, (long)path, uid, gid);
+}
diff --git a/05/musl-0.6.0/src/unistd/link.c b/05/musl-0.6.0/src/unistd/link.c
new file mode 100644
index 0000000..f121bb9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/link.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int link(const char *existing, const char *new)
+{
+ return syscall2(__NR_link, (long)existing, (long)new);
+}
diff --git a/05/musl-0.6.0/src/unistd/linkat.c b/05/musl-0.6.0/src/unistd/linkat.c
new file mode 100644
index 0000000..0eb5122
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/linkat.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int linkat(int fd1, const char *existing, int fd2, const char *new, int flag)
+{
+ return syscall5(__NR_linkat, fd1, (long)existing, fd2, (long)new, flag);
+}
diff --git a/05/musl-0.6.0/src/unistd/lseek.c b/05/musl-0.6.0/src/unistd/lseek.c
new file mode 100644
index 0000000..0152866
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/lseek.c
@@ -0,0 +1,15 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+off_t lseek(int fd, off_t offset, int whence)
+{
+#ifdef __NR__llseek
+ off_t result;
+ return syscall5(__NR__llseek, fd, offset>>32, offset, (long)&result, whence) ? -1 : result;
+#else
+ return syscall3(__NR_lseek, fd, offset, whence);
+#endif
+}
+
+LFS64(lseek);
diff --git a/05/musl-0.6.0/src/unistd/nice.c b/05/musl-0.6.0/src/unistd/nice.c
new file mode 100644
index 0000000..f38db67
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/nice.c
@@ -0,0 +1,12 @@
+#include <unistd.h>
+#include <sys/resource.h>
+#include "syscall.h"
+
+int nice(int inc)
+{
+#ifdef __NR_nice
+ return syscall1(__NR_nice, inc);
+#else
+ return setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS, 0)+inc);
+#endif
+}
diff --git a/05/musl-0.6.0/src/unistd/pause.c b/05/musl-0.6.0/src/unistd/pause.c
new file mode 100644
index 0000000..1472065
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/pause.c
@@ -0,0 +1,12 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int pause(void)
+{
+ int r;
+ CANCELPT_BEGIN;
+ r = syscall0(__NR_pause);
+ CANCELPT_END;
+ return r;
+}
diff --git a/05/musl-0.6.0/src/unistd/pipe.c b/05/musl-0.6.0/src/unistd/pipe.c
new file mode 100644
index 0000000..2dfc9c9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/pipe.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int pipe(int fd[2])
+{
+ return syscall1(__NR_pipe, (long)fd);
+}
diff --git a/05/musl-0.6.0/src/unistd/pread.c b/05/musl-0.6.0/src/unistd/pread.c
new file mode 100644
index 0000000..534215a
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/pread.c
@@ -0,0 +1,14 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
+{
+ ssize_t r;
+ CANCELPT_BEGIN;
+ r = syscall5(__NR_pread, fd, (long)buf, size, SYSCALL_LL(ofs));
+ CANCELPT_END;
+ return r;
+}
+
+LFS64(pread);
diff --git a/05/musl-0.6.0/src/unistd/pwrite.c b/05/musl-0.6.0/src/unistd/pwrite.c
new file mode 100644
index 0000000..56ed6b4
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/pwrite.c
@@ -0,0 +1,14 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs)
+{
+ ssize_t r;
+ CANCELPT_BEGIN;
+ r = syscall5(__NR_pwrite, fd, (long)buf, size, SYSCALL_LL(ofs));
+ CANCELPT_END;
+ return r;
+}
+
+LFS64(pwrite);
diff --git a/05/musl-0.6.0/src/unistd/read.c b/05/musl-0.6.0/src/unistd/read.c
new file mode 100644
index 0000000..87ff1f1
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/read.c
@@ -0,0 +1,12 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+ssize_t read(int fd, void *buf, size_t count)
+{
+ ssize_t r;
+ CANCELPT_BEGIN;
+ r = __syscall_read(fd, buf, count);
+ CANCELPT_END;
+ return r;
+}
diff --git a/05/musl-0.6.0/src/unistd/readlink.c b/05/musl-0.6.0/src/unistd/readlink.c
new file mode 100644
index 0000000..f6b1635
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/readlink.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int readlink(const char *path, char *buf, size_t bufsize)
+{
+ return syscall3(__NR_readlink, (long)path, (long)buf, bufsize);
+}
diff --git a/05/musl-0.6.0/src/unistd/readlinkat.c b/05/musl-0.6.0/src/unistd/readlinkat.c
new file mode 100644
index 0000000..8171050
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/readlinkat.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int readlinkat(int fd, const char *path, char *buf, size_t bufsize)
+{
+ return syscall4(__NR_readlinkat, fd, (long)path, (long)buf, bufsize);
+}
diff --git a/05/musl-0.6.0/src/unistd/readv.c b/05/musl-0.6.0/src/unistd/readv.c
new file mode 100644
index 0000000..e311f9d
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/readv.c
@@ -0,0 +1,12 @@
+#include <sys/uio.h>
+#include "syscall.h"
+#include "libc.h"
+
+ssize_t readv(int fd, const struct iovec *iov, int count)
+{
+ ssize_t r;
+ CANCELPT_BEGIN;
+ r = syscall3(__NR_readv, fd, (long)iov, count);
+ CANCELPT_END;
+ return r;
+}
diff --git a/05/musl-0.6.0/src/unistd/renameat.c b/05/musl-0.6.0/src/unistd/renameat.c
new file mode 100644
index 0000000..0dae9f1
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/renameat.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include "syscall.h"
+
+int renameat(int oldfd, const char *old, int newfd, const char *new)
+{
+ return syscall4(__NR_renameat, oldfd, (long)old, newfd, (long)new);
+}
diff --git a/05/musl-0.6.0/src/unistd/rmdir.c b/05/musl-0.6.0/src/unistd/rmdir.c
new file mode 100644
index 0000000..8e18c7a
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/rmdir.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int rmdir(const char *path)
+{
+ return syscall1(__NR_rmdir, (long)path);
+}
diff --git a/05/musl-0.6.0/src/unistd/setegid.c b/05/musl-0.6.0/src/unistd/setegid.c
new file mode 100644
index 0000000..8534884
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setegid.c
@@ -0,0 +1,6 @@
+#include <unistd.h>
+
+int setegid(gid_t egid)
+{
+ return setregid(-1, egid);
+}
diff --git a/05/musl-0.6.0/src/unistd/seteuid.c b/05/musl-0.6.0/src/unistd/seteuid.c
new file mode 100644
index 0000000..0aaa86e
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/seteuid.c
@@ -0,0 +1,6 @@
+#include <unistd.h>
+
+int seteuid(uid_t euid)
+{
+ return setreuid(-1, euid);
+}
diff --git a/05/musl-0.6.0/src/unistd/setgid.c b/05/musl-0.6.0/src/unistd/setgid.c
new file mode 100644
index 0000000..42976d9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setgid.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int setgid(gid_t gid)
+{
+ if (libc.rsyscall) return libc.rsyscall(__NR_setgid, gid, 0, 0, 0, 0, 0);
+ return syscall1(__NR_setgid, gid);
+}
diff --git a/05/musl-0.6.0/src/unistd/setpgid.c b/05/musl-0.6.0/src/unistd/setpgid.c
new file mode 100644
index 0000000..748d290
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setpgid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t setpgid(pid_t pid, pid_t pgid)
+{
+ return syscall2(__NR_setpgid, pid, pgid);
+}
diff --git a/05/musl-0.6.0/src/unistd/setpgrp.c b/05/musl-0.6.0/src/unistd/setpgrp.c
new file mode 100644
index 0000000..a2a37f6
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setpgrp.c
@@ -0,0 +1,6 @@
+#include <unistd.h>
+
+pid_t setpgrp(void)
+{
+ return setpgid(0, 0);
+}
diff --git a/05/musl-0.6.0/src/unistd/setregid.c b/05/musl-0.6.0/src/unistd/setregid.c
new file mode 100644
index 0000000..158753b
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setregid.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int setregid(gid_t rgid, gid_t egid)
+{
+ if (libc.rsyscall) return libc.rsyscall(__NR_setregid, rgid, egid, 0, 0, 0, 0);
+ return syscall2(__NR_setregid, rgid, egid);
+}
diff --git a/05/musl-0.6.0/src/unistd/setreuid.c b/05/musl-0.6.0/src/unistd/setreuid.c
new file mode 100644
index 0000000..47c6730
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setreuid.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int setreuid(uid_t ruid, uid_t euid)
+{
+ if (libc.rsyscall) return libc.rsyscall(__NR_setreuid, ruid, euid, 0, 0, 0, 0);
+ return syscall2(__NR_setreuid, ruid, euid);
+}
diff --git a/05/musl-0.6.0/src/unistd/setsid.c b/05/musl-0.6.0/src/unistd/setsid.c
new file mode 100644
index 0000000..e2c5690
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setsid.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+pid_t setsid(void)
+{
+ return syscall0(__NR_setsid);
+}
diff --git a/05/musl-0.6.0/src/unistd/setuid.c b/05/musl-0.6.0/src/unistd/setuid.c
new file mode 100644
index 0000000..9e9da61
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/setuid.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int setuid(uid_t uid)
+{
+ if (libc.rsyscall) return libc.rsyscall(__NR_setuid, uid, 0, 0, 0, 0, 0);
+ return syscall1(__NR_setuid, uid);
+}
diff --git a/05/musl-0.6.0/src/unistd/sleep.c b/05/musl-0.6.0/src/unistd/sleep.c
new file mode 100644
index 0000000..d645094
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/sleep.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include <time.h>
+
+unsigned sleep(unsigned seconds)
+{
+ struct timespec tv = { .tv_sec = seconds, .tv_nsec = 0 };
+ if (nanosleep(&tv, &tv))
+ return tv.tv_sec;
+ return 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/symlink.c b/05/musl-0.6.0/src/unistd/symlink.c
new file mode 100644
index 0000000..8d380d8
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/symlink.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int symlink(const char *existing, const char *new)
+{
+ return syscall2(__NR_symlink, (long)existing, (long)new);
+}
diff --git a/05/musl-0.6.0/src/unistd/symlinkat.c b/05/musl-0.6.0/src/unistd/symlinkat.c
new file mode 100644
index 0000000..9693b22
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/symlinkat.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int symlinkat(const char *existing, int fd, const char *new)
+{
+ return syscall3(__NR_symlinkat, (long)existing, fd, (long)new);
+}
diff --git a/05/musl-0.6.0/src/unistd/sync.c b/05/musl-0.6.0/src/unistd/sync.c
new file mode 100644
index 0000000..a49808f
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/sync.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+void sync(void)
+{
+ syscall0(__NR_sync);
+}
diff --git a/05/musl-0.6.0/src/unistd/tcgetpgrp.c b/05/musl-0.6.0/src/unistd/tcgetpgrp.c
new file mode 100644
index 0000000..50080c7
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/tcgetpgrp.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+pid_t tcgetpgrp(int fd)
+{
+ int pgrp;
+ if (ioctl(fd, TIOCGPGRP, &pgrp) < 0)
+ return -1;
+ return pgrp;
+}
diff --git a/05/musl-0.6.0/src/unistd/tcsetpgrp.c b/05/musl-0.6.0/src/unistd/tcsetpgrp.c
new file mode 100644
index 0000000..67c38cb
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/tcsetpgrp.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+int tcsetpgrp(int fd, pid_t pgrp)
+{
+ int pgrp_int = pgrp;
+ return ioctl(fd, TIOCSPGRP, &pgrp_int);
+}
diff --git a/05/musl-0.6.0/src/unistd/truncate.c b/05/musl-0.6.0/src/unistd/truncate.c
new file mode 100644
index 0000000..322349d
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/truncate.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int truncate(const char *path, off_t length)
+{
+ return syscall3(__NR_truncate, (long)path, SYSCALL_LL(length));
+}
+
+LFS64(truncate);
diff --git a/05/musl-0.6.0/src/unistd/ttyname.c b/05/musl-0.6.0/src/unistd/ttyname.c
new file mode 100644
index 0000000..0f3e114
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/ttyname.c
@@ -0,0 +1,14 @@
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+
+char *ttyname(int fd)
+{
+ static char buf[TTY_NAME_MAX];
+ int result;
+ if ((result = ttyname_r(fd, buf, sizeof buf))) {
+ errno = result;
+ return NULL;
+ }
+ return buf;
+}
diff --git a/05/musl-0.6.0/src/unistd/ttyname_r.c b/05/musl-0.6.0/src/unistd/ttyname_r.c
new file mode 100644
index 0000000..f86fbd9
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/ttyname_r.c
@@ -0,0 +1,19 @@
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+int ttyname_r(int fd, char *name, size_t size)
+{
+ char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2];
+ ssize_t l;
+
+ if (!isatty(fd)) return ENOTTY;
+
+ snprintf(procname, sizeof procname, "/proc/self/fd/%d", fd);
+ l = readlink(procname, name, size);
+
+ if (l < 0) return errno;
+ else if (l == size) return ERANGE;
+ else return 0;
+}
diff --git a/05/musl-0.6.0/src/unistd/ualarm.c b/05/musl-0.6.0/src/unistd/ualarm.c
new file mode 100644
index 0000000..be85303
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/ualarm.c
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include "syscall.h"
+
+/* FIXME: ?? */
+useconds_t ualarm(useconds_t useconds, useconds_t interval)
+{
+ return -1;
+}
diff --git a/05/musl-0.6.0/src/unistd/unlink.c b/05/musl-0.6.0/src/unistd/unlink.c
new file mode 100644
index 0000000..fb57792
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/unlink.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int unlink(const char *path)
+{
+ return __syscall_unlink(path);
+}
diff --git a/05/musl-0.6.0/src/unistd/unlinkat.c b/05/musl-0.6.0/src/unistd/unlinkat.c
new file mode 100644
index 0000000..47fccc1
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/unlinkat.c
@@ -0,0 +1,7 @@
+#include <unistd.h>
+#include "syscall.h"
+
+int unlinkat(int fd, const char *path, int flag)
+{
+ return syscall3(__NR_unlinkat, fd, (long)path, flag);
+}
diff --git a/05/musl-0.6.0/src/unistd/usleep.c b/05/musl-0.6.0/src/unistd/usleep.c
new file mode 100644
index 0000000..e386901
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/usleep.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <time.h>
+
+int usleep(useconds_t useconds)
+{
+ struct timespec tv = {
+ .tv_sec = useconds/1000000,
+ .tv_nsec = (useconds%1000000)*1000
+ };
+ return nanosleep(&tv, &tv);
+}
diff --git a/05/musl-0.6.0/src/unistd/write.c b/05/musl-0.6.0/src/unistd/write.c
new file mode 100644
index 0000000..426cfc5
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/write.c
@@ -0,0 +1,12 @@
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+ssize_t write(int fd, const void *buf, size_t count)
+{
+ int r;
+ CANCELPT_BEGIN;
+ r = __syscall_write(fd, buf, count);
+ CANCELPT_END;
+ return r;
+}
diff --git a/05/musl-0.6.0/src/unistd/writev.c b/05/musl-0.6.0/src/unistd/writev.c
new file mode 100644
index 0000000..a6a118a
--- /dev/null
+++ b/05/musl-0.6.0/src/unistd/writev.c
@@ -0,0 +1,12 @@
+#include <sys/uio.h>
+#include "syscall.h"
+#include "libc.h"
+
+ssize_t writev(int fd, const struct iovec *iov, int count)
+{
+ ssize_t r;
+ CANCELPT_BEGIN;
+ r = syscall3(__NR_writev, fd, (long)iov, count);
+ CANCELPT_END;
+ return r;
+}