Add syscalls, and implement an emulation of BSD-style directory files via a tempfile...
authorNick Downing <downing.nick@gmail.com>
Sat, 28 Jan 2017 05:29:49 +0000 (16:29 +1100)
committerNick Downing <downing.nick@gmail.com>
Sat, 28 Jan 2017 05:29:49 +0000 (16:29 +1100)
25 files changed:
lib/libc/linux/sys/Makefile
lib/libc/linux/sys/dup.c [new file with mode: 0644]
lib/libc/linux/sys/dup2.c [new file with mode: 0644]
lib/libc/linux/sys/getdtablesize.c [new file with mode: 0644]
lib/libc/linux/sys/getegid.c [new file with mode: 0644]
lib/libc/linux/sys/geteuid.c [new file with mode: 0644]
lib/libc/linux/sys/getgid.c [new file with mode: 0644]
lib/libc/linux/sys/getpgrp.c [new file with mode: 0644]
lib/libc/linux/sys/getppid.c [new file with mode: 0644]
lib/libc/linux/sys/gettimeofday.c [new file with mode: 0644]
lib/libc/linux/sys/getuid.c [new file with mode: 0644]
lib/libc/linux/sys/ioctl.c [new file with mode: 0644]
lib/libc/linux/sys/linux.c
lib/libc/linux/sys/linux.h
lib/libc/linux/sys/lseek.c
lib/libc/linux/sys/lstat.c [new file with mode: 0644]
lib/libc/linux/sys/readv.c
lib/libc/linux/sys/setpgrp.c [new file with mode: 0644]
lib/libc/linux/sys/setregid.c [new file with mode: 0644]
lib/libc/linux/sys/setreuid.c [new file with mode: 0644]
lib/libc/linux/sys/settimeofday.c [new file with mode: 0644]
lib/libc/linux/sys/sigvec.c
lib/libc/linux/sys/sync.c [new file with mode: 0644]
lib/libc/linux/sys/vopen.c
lib/libc/linux/sys/writev.c

index 342fbfd..5250aa6 100644 (file)
@@ -7,14 +7,19 @@ LD=ld
 #      @(#)Makefile    5.4 (Berkeley) 9/5/85
 #
 
-SRCS=  chmod.c chown.c close.c fchmod.c fchown.c fstat.c ftruncate.c \
-       getpagesize.c getpid.c isatty.c link.c linux.c lseek.c read.c readv.c \
-       sbrk.c sigvec.c stat.c symlink.c truncate.c umask.c unlink.c vopen.c \
-       write.c writev.c _exit.c
-OBJS=  chmod.o chown.o close.o fchmod.o fchown.o fstat.o ftruncate.o \
-       getpagesize.o getpid.o isatty.o link.o linux.o lseek.o read.o readv.o \
-       sbrk.o sigvec.o stat.o symlink.o truncate.o umask.o unlink.o vopen.o \
-       write.o writev.o _exit.o
+SRCS=  chmod.c chown.c close.c dup2.c dup.c _exit.c fchmod.c fchown.c \
+       fstat.c ftruncate.c getdtablesize.c getegid.c geteuid.c getgid.c \
+       getpagesize.c getpgrp.c getpid.c getppid.c gettimeofday.c getuid.c \
+       ioctl.c isatty.c link.c linux.c lseek.c lstat.c read.c readv.c sbrk.c \
+       setpgrp.c setregid.c setreuid.c settimeofday.c sigvec.c stat.c \
+       symlink.c sync.c truncate.c umask.c unlink.c vopen.c write.c writev.c
+
+OBJS=  chmod.o chown.o close.o dup2.o dup.o _exit.o fchmod.o fchown.o \
+       fstat.o ftruncate.o getdtablesize.o getegid.o geteuid.o getgid.o \
+       getpagesize.o getpgrp.o getpid.o getppid.o gettimeofday.o getuid.o \
+       ioctl.o isatty.o link.o linux.o lseek.o lstat.o read.o readv.o sbrk.o \
+       setpgrp.o setregid.o setreuid.o settimeofday.o sigvec.o stat.o \
+       symlink.o sync.o truncate.o umask.o unlink.o vopen.o write.o writev.o
 TAGSFILE=tags
 
 .c.o:
diff --git a/lib/libc/linux/sys/dup.c b/lib/libc/linux/sys/dup.c
new file mode 100644 (file)
index 0000000..7f5c7b5
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include "linux.h"
+
+int dup(f) int f; {
+       int res;
+
+       res = nox_dup((nox_int)f);
+       if (res == (nox_int)-1)
+               errno = htot_errno(nox_errno);
+       return (int)res;
+}
diff --git a/lib/libc/linux/sys/dup2.c b/lib/libc/linux/sys/dup2.c
new file mode 100644 (file)
index 0000000..e66602c
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include "linux.h"
+
+int dup2(o, n) int o; int n; {
+       int res;
+
+       res = nox_dup2((nox_int)o, (nox_int)n);
+       if (res == (nox_int)-1)
+               errno = htot_errno(nox_errno);
+       return (int)res;
+}
diff --git a/lib/libc/linux/sys/getdtablesize.c b/lib/libc/linux/sys/getdtablesize.c
new file mode 100644 (file)
index 0000000..f7b00a6
--- /dev/null
@@ -0,0 +1,7 @@
+#include <nox_unistd.h>
+
+#include <sys.h>
+
+int getdtablesize() {
+       return (int)nox_getdtablesize();
+}
diff --git a/lib/libc/linux/sys/getegid.c b/lib/libc/linux/sys/getegid.c
new file mode 100644 (file)
index 0000000..76e1870
--- /dev/null
@@ -0,0 +1,9 @@
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <sys.h>
+#include <sys/types.h>
+
+gid_t getegid() {
+       return (gid_t)nox_getegid();
+}
diff --git a/lib/libc/linux/sys/geteuid.c b/lib/libc/linux/sys/geteuid.c
new file mode 100644 (file)
index 0000000..fe2b58a
--- /dev/null
@@ -0,0 +1,9 @@
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <sys.h>
+#include <sys/types.h>
+
+uid_t geteuid() {
+       return (uid_t)nox_geteuid();
+}
diff --git a/lib/libc/linux/sys/getgid.c b/lib/libc/linux/sys/getgid.c
new file mode 100644 (file)
index 0000000..72fd918
--- /dev/null
@@ -0,0 +1,9 @@
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <sys.h>
+#include <sys/types.h>
+
+gid_t getgid() {
+       return (gid_t)nox_getgid();
+}
diff --git a/lib/libc/linux/sys/getpgrp.c b/lib/libc/linux/sys/getpgrp.c
new file mode 100644 (file)
index 0000000..910e582
--- /dev/null
@@ -0,0 +1,18 @@
+#include <nox_errno.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys.h>
+#include "linux.h"
+
+int getpgrp(p) int p; {
+       nox_pid_t res;
+
+       res = nox_getpgid((nox_pid_t)p);
+       if (res == (nox_pid_t)-1) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return res;
+}
diff --git a/lib/libc/linux/sys/getppid.c b/lib/libc/linux/sys/getppid.c
new file mode 100644 (file)
index 0000000..7f5fb62
--- /dev/null
@@ -0,0 +1,5 @@
+#include <nox_unistd.h>
+
+int getpid() {
+       return (int)nox_getppid();
+}
diff --git a/lib/libc/linux/sys/gettimeofday.c b/lib/libc/linux/sys/gettimeofday.c
new file mode 100644 (file)
index 0000000..629eb49
--- /dev/null
@@ -0,0 +1,26 @@
+#include <nox_errno.h>
+#include <sys/nox_time.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/time.h>
+#include "linux.h"
+
+int gettimeofday(t, z) struct timeval *t; struct timezone *z; {
+       struct nox_timeval tv;
+       struct nox_timezone tz;
+
+       if (nox_gettimeofday(&tv, &tz)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       if (t) {
+               t->tv_sec = (long)tv.nox_tv_sec;
+               t->tv_usec = (long)tv.nox_tv_usec;
+       }
+       if (z) {
+               z->tz_minuteswest = (int)tz.nox_tz_minuteswest;
+               z->tz_dsttime = (int)tz.nox_tz_dsttime;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/getuid.c b/lib/libc/linux/sys/getuid.c
new file mode 100644 (file)
index 0000000..3bf1cd9
--- /dev/null
@@ -0,0 +1,9 @@
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <sys.h>
+#include <sys/types.h>
+
+uid_t getuid() {
+       return (uid_t)nox_getuid();
+}
diff --git a/lib/libc/linux/sys/ioctl.c b/lib/libc/linux/sys/ioctl.c
new file mode 100644 (file)
index 0000000..81fd9ea
--- /dev/null
@@ -0,0 +1,28 @@
+#include <nox_errno.h>
+#include <sys/nox_ioctl.h>
+#include <sys/nox_types.h>
+
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int ioctl(d, r, p) int d; u_long r; void *p; {
+       switch (r) {
+       case TIOCGWINSZ: {
+               struct nox_winsize ws;
+               if (nox_ioctl((nox_int)d, nox_TIOCGWINSZ, &ws)) {
+                       errno = htot_errno(nox_errno);
+                       return -1;
+               }
+               ((struct winsize *)p)->ws_row = (unsigned short)ws.nox_ws_row;
+               ((struct winsize *)p)->ws_col = (unsigned short)ws.nox_ws_col;
+               ((struct winsize *)p)->ws_xpixel = (unsigned short)ws.nox_ws_xpixel;
+               ((struct winsize *)p)->ws_ypixel = (unsigned short)ws.nox_ws_ypixel;
+               return 0;
+       }
+       default:
+               errno = ENOTTY;
+               return -1;
+       }
+}
index d6a820c..56875b5 100644 (file)
@@ -1,8 +1,12 @@
+#include <nox_dirent.h>
 #include <nox_errno.h>
 #include <nox_stdlib.h>
+#include <nox_string.h>
+#include <sys/nox_types.h>
 #include <nox_unistd.h>
 
 #include <string.h>
+#include <sys/dir.h>
 #include <sys/errno.h>
 #include <sys/signal.h>
 #include "linux.h"
@@ -146,19 +150,87 @@ int htot_sigmask(set) nox_sigset_t *set; {
        return res;
 }
 
-void htot_stat(statbuf, res) struct nox_stat *statbuf; struct stat *res; {
+void htot_stat(stat, res) struct nox_stat *stat; struct stat *res; {
        bzero(res, sizeof(struct stat));
-       res->st_dev = (dev_t)statbuf->nox_st_dev;
-       res->st_ino = (ino_t)statbuf->nox_st_ino;
-       res->st_mode = (unsigned short)statbuf->nox_st_mode;
-       res->st_nlink = (short)statbuf->nox_st_nlink;
-       res->st_uid = (uid_t)statbuf->nox_st_uid;
-       res->st_gid = (gid_t)statbuf->nox_st_gid;
-       res->st_rdev = (dev_t)statbuf->nox_st_rdev;
-       res->st_size = (off_t)statbuf->nox_st_size;
-       res->st_atime = (time_t)statbuf->nox_st_atime;
-       res->st_mtime = (time_t)statbuf->nox_st_mtime;
-       res->st_ctime = (time_t)statbuf->nox_st_ctime;
-       res->st_blksize = /*0x2000;*/ (long)statbuf->nox_st_blksize;
-       res->st_blocks = (long)statbuf->nox_st_blocks;
+       res->st_dev = (dev_t)stat->nox_st_dev;
+       res->st_ino = (ino_t)stat->nox_st_ino;
+       res->st_mode = (unsigned short)stat->nox_st_mode;
+       res->st_nlink = (short)stat->nox_st_nlink;
+       res->st_uid = (uid_t)stat->nox_st_uid;
+       res->st_gid = (gid_t)stat->nox_st_gid;
+       res->st_rdev = (dev_t)stat->nox_st_rdev;
+       res->st_size = (off_t)stat->nox_st_size;
+       res->st_atime = (time_t)stat->nox_st_atime;
+       res->st_mtime = (time_t)stat->nox_st_mtime;
+       res->st_ctime = (time_t)stat->nox_st_ctime;
+       res->st_blksize = /*0x2000;*/ (long)stat->nox_st_blksize;
+       res->st_blocks = (long)stat->nox_st_blocks;
+}
+
+static void htot_direct(dirent, res) struct nox_dirent *dirent; struct direct *res; {
+       res->d_ino = (ino_t)dirent->nox_d_ino;
+       if (res->d_ino == 0) {
+               nox_write((nox_int)2, "htot_direct(): null inode\n", (nox_size_t)27);
+               nox_abort();
+       }
+       res->d_namlen = strlen(dirent->nox_d_name);
+       if (res->d_namlen > MAXNAMLEN) {
+               nox_write((nox_int)2, "htot_direct(): name too long\n", (nox_size_t)29);
+               nox_abort();
+       }
+       strncpy(res->d_name, dirent->nox_d_name, (res->d_namlen + 4) & ~3);
+       res->d_reclen = DIRSIZ(res);
+}
+
+nox_int htot_dir(fd) nox_int fd; {
+       nox_int res;
+       static char tempfile[] = "/tmp/dirXXXXXX";
+       nox_DIR *dp;
+       struct nox_dirent *d;
+       char buf[DIRBLKSIZ + sizeof(struct direct)], *p, *q;
+
+       res = nox_mkstemp(tempfile);
+       if (res == -1) {
+               errno = htot_errno(nox_errno);
+               return (nox_int)-1;
+       }
+       if (nox_unlink(tempfile) || (dp = nox_fdopendir(fd)) == 0) {
+               errno = htot_errno(nox_errno);
+               nox_close(fd);
+               return (nox_int)-1;
+       }
+       if ((d = nox_readdir(dp)) != 0) {
+               htot_direct(d, (struct direct *)buf);
+               p = buf;
+               while ((d = nox_readdir(dp)) != 0) {
+                       q = p + ((struct direct *)p)->d_reclen;
+                       htot_direct(d, q);
+                       if (q + ((struct direct *)q)->d_reclen > buf + DIRBLKSIZ) {
+ /*nox_memset(q, 0xaa, buf + DIRBLKSIZ - q);*/
+                               ((struct direct *)p)->d_reclen = buf + DIRBLKSIZ - p;
+                               nox_errno = nox_ENOSPC;
+                               if (nox_write(res, buf, (nox_size_t)DIRBLKSIZ) != (nox_ssize_t)DIRBLKSIZ)
+                                       goto nogood;
+ /*htot_direct(d, q);*/
+                               nox_memcpy(buf, q, ((struct direct *)q)->d_reclen);
+                               q = buf;
+                       }
+                       p = q;
+               }
+ /*q = p + ((struct direct *)p)->d_reclen;*/
+ /*nox_memset(q, 0xaa, buf + DIRBLKSIZ - q);*/
+               ((struct direct *)p)->d_reclen = buf + DIRBLKSIZ - p;
+               nox_errno = nox_ENOSPC;
+               if (nox_write(res, buf, (nox_size_t)DIRBLKSIZ) != (nox_ssize_t)DIRBLKSIZ)
+                       goto nogood;
+       }
+       if (nox_lseek(res, (nox_off_t)0, nox_SEEK_SET) == (nox_off_t)-1) {
+       nogood:
+               errno = htot_errno(nox_errno);
+               nox_closedir(dp);
+               nox_close(res);
+               return (nox_int)-1;
+       }
+       nox_closedir(dp);
+       return res;
 }
index 111c24f..71347ea 100644 (file)
@@ -14,5 +14,6 @@ int htot_signo(nox_int n);
 void ttoh_sigmask(int m, nox_sigset_t *res);
 int htot_sigmask(nox_sigset_t *set);
 void htot_stat(struct nox_stat *statbuf, struct stat *res);
+int htot_dir(nox_int fd);
 
 #endif
index feb7b0a..dee8b21 100644 (file)
@@ -9,24 +9,24 @@
 #include "linux.h"
 
 off_t lseek(f, o, d) int f; off_t o; int d; {
-       nox_int cmd;
+       nox_int whence;
        nox_off_t res;
 
        switch (d) {
        case L_SET:
-               cmd = nox_SEEK_SET;
+               whence = nox_SEEK_SET;
                break;
        case L_INCR:
-               cmd = nox_SEEK_CUR;
+               whence = nox_SEEK_CUR;
                break;
        case L_XTND:
-               cmd = nox_SEEK_END;
+               whence = nox_SEEK_END;
                break;
        default:
-               write(2, "lseek()\n", 8);
+               write(2, "lseek(): invalid whence\n", 24);
                abort();
        }
-       res = nox_lseek(f, (nox_off_t)o, cmd);
+       res = nox_lseek(f, (nox_off_t)o, whence);
        if (res == (nox_off_t)-1)
                errno = htot_errno(nox_errno);
        return (off_t)res;
diff --git a/lib/libc/linux/sys/lstat.c b/lib/libc/linux/sys/lstat.c
new file mode 100644 (file)
index 0000000..f7f1399
--- /dev/null
@@ -0,0 +1,18 @@
+#include <nox_errno.h>
+#include <sys/nox_stat.h>
+#include <nox_unistd.h>
+
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include "linux.h"
+
+int lstat(s, b) char *s; struct stat *b; {
+       struct nox_stat statbuf;
+
+       if (nox_lstat(s, &statbuf)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       htot_stat(&statbuf, b);
+       return 0;
+}
index e613318..3346c19 100644 (file)
@@ -14,7 +14,7 @@ int readv(f, v, l) int f; struct iovec *v; int l; {
        nox_int res;
 
        if (l > 8) {
-               write(2, "readv()\n", 8);
+               write(2, "readv(): iovec too large\n", 25);
                abort();
        }
        for (i = 0; i < l; ++i) {
diff --git a/lib/libc/linux/sys/setpgrp.c b/lib/libc/linux/sys/setpgrp.c
new file mode 100644 (file)
index 0000000..cdccc10
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys.h>
+#include "linux.h"
+
+int setpgrp(g, pg) int g; int pg; {
+       if (nox_setpgid((nox_pid_t)g, (nox_pid_t)pg)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/setregid.c b/lib/libc/linux/sys/setregid.c
new file mode 100644 (file)
index 0000000..8919b7f
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys.h>
+#include "linux.h"
+
+int setregid(r, e) int r; int e; {
+       if (nox_setregid((nox_gid_t)r, (nox_gid_t)e)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/setreuid.c b/lib/libc/linux/sys/setreuid.c
new file mode 100644 (file)
index 0000000..2cafd12
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys.h>
+#include "linux.h"
+
+int setreuid(r, e) int r; int e; {
+       if (nox_setreuid((nox_uid_t)r, (nox_uid_t)e)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/settimeofday.c b/lib/libc/linux/sys/settimeofday.c
new file mode 100644 (file)
index 0000000..7b8802d
--- /dev/null
@@ -0,0 +1,30 @@
+#include <nox_errno.h>
+#include <sys/nox_time.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/time.h>
+#include "linux.h"
+
+int settimeofday(t, z) struct timeval *t; struct timezone *z; {
+       struct nox_timeval tv, *tv_p;
+       struct nox_timezone tz, *tz_p;
+
+       tv_p = 0;
+       if (t) {
+               tv.nox_tv_sec = (nox_time_t)t->tv_sec;
+               tv.nox_tv_usec = (nox_suseconds_t)t->tv_usec;
+               tv_p = &tv;
+       }
+       tz_p = 0;
+       if (z) {
+               tz.nox_tz_minuteswest = (nox_int)z->tz_minuteswest;
+               tz.nox_tz_dsttime = (nox_int)z->tz_dsttime;
+               tz_p = &tz;
+       }
+       if (nox_settimeofday(tv_p, tz_p)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
index 37ad416..d50c513 100644 (file)
@@ -16,11 +16,12 @@ int sigvec(c, f, m) int c; struct sigvec *f; struct sigvec *m; {
        act.nox_sa_flags = nox_SA_RESTART | nox_SA_SIGINFO;
        if (f->sv_flags & SV_ONSTACK)
                act.nox_sa_flags |= nox_SA_ONSTACK;
-       if (f->sv_flags & SV_INTERRUPT)
-               goto nogood;
+       if (f->sv_flags & SV_INTERRUPT) {
+               write(2, "sigvec(): SV_INTERRUPT\n", 23);
+               abort();
+       }
        if (c < 0 || c >= NSIG) {
-       nogood:
-               write(2, "sigvec()\n", 9);
+               write(2, "sigvec(): out of range\n", 23);
                abort();
        }
        if (nox_sigaction(ttoh_signo[c], &act, &oldact)) {
diff --git a/lib/libc/linux/sys/sync.c b/lib/libc/linux/sys/sync.c
new file mode 100644 (file)
index 0000000..f6f64cf
--- /dev/null
@@ -0,0 +1,7 @@
+#include <nox_unistd.h>
+
+#include <sys.h>
+
+void sync() {
+       nox_sync();
+}
index f849ac6..6bbe5e5 100644 (file)
@@ -1,5 +1,7 @@
 #include <nox_errno.h>
 #include <nox_fcntl.h>
+#include <sys/nox_stat.h>
+#include <nox_unistd.h>
 
 #include <gen.h>
 #include <sys/errno.h>
@@ -15,6 +17,8 @@ int vopen(f, m, argp) char *f; int m; va_list argp; {
        nox_int flags;
        nox_mode_t mode;
        nox_int res;
+       struct nox_stat stat;
+       nox_int res2;
 
        switch (m & 3) {
        case O_RDONLY:
@@ -44,7 +48,24 @@ int vopen(f, m, argp) char *f; int m; va_list argp; {
        if (m & O_EXCL)
                flags |= nox_O_EXCL;
        res = nox_open(f, flags, mode);
-       if (res == (nox_int)-1)
+       if (res == (nox_int)-1) {
                errno = htot_errno(nox_errno);
+               return -1;
+       }
+       if (nox_fstat(res, &stat)) {
+               errno = htot_errno(nox_errno);
+               nox_close(res);
+               return -1;
+       }
+       if (nox_S_ISDIR(stat.nox_st_mode)) {
+               res2 = htot_dir(res);
+               if (res2 == (nox_int)-1)
+                       return -1;
+               if (nox_dup2(res2, res) == (nox_int)-1) {
+                       errno = htot_errno(nox_errno);
+                       nox_close(res2);
+                       return -1;
+               }
+       }
        return (int)res;
 }
index a863e96..96edafa 100644 (file)
@@ -14,7 +14,7 @@ int writev(f, v, l) int f; struct iovec *v; int l; {
        nox_int res;
 
        if (l > 8) {
-               write(2, "writev()\n", 9);
+               write(2, "writev(): iovec too large\n", 26);
                abort();
        }
        for (i = 0; i < l; ++i) {