Fix in-core struct nlist and struct ranlib issue in ld and nm, add syscalls
authorNick Downing <downing.nick@gmail.com>
Fri, 27 Jan 2017 06:13:01 +0000 (17:13 +1100)
committerNick Downing <downing.nick@gmail.com>
Fri, 27 Jan 2017 06:13:01 +0000 (17:13 +1100)
23 files changed:
bin/as/Makefile
bin/as/test/libc.a.ok [new file with mode: 0644]
bin/as/test/n.sh
bin/ld.c
bin/nm.c
include/ranlib.h
lib/libc/groups.txt
lib/libc/linux/sys/Makefile
lib/libc/linux/sys/chmod.c [new file with mode: 0644]
lib/libc/linux/sys/chown.c [new file with mode: 0644]
lib/libc/linux/sys/fchmod.c [new file with mode: 0644]
lib/libc/linux/sys/fchown.c [new file with mode: 0644]
lib/libc/linux/sys/ftruncate.c [new file with mode: 0644]
lib/libc/linux/sys/getpagesize.c
lib/libc/linux/sys/link.c [new file with mode: 0644]
lib/libc/linux/sys/linux.c
lib/libc/linux/sys/symlink.c [new file with mode: 0644]
lib/libc/linux/sys/truncate.c [new file with mode: 0644]
lib/libc/linux/sys/umask.c [new file with mode: 0644]
lib/libc/sys/creat.c
n.sh
sys/h/file.h
sys/h/stat.h

index 519bebe..e2ce885 100644 (file)
@@ -97,7 +97,7 @@ AS = /bin/as
 LD = /bin/ld
 
 DFLAGS= -DAS
-CFLAGS = -g -O ${DFLAGS}
+CFLAGS = -O ${DFLAGS}
 
 LDFLAGS = -O
 
diff --git a/bin/as/test/libc.a.ok b/bin/as/test/libc.a.ok
new file mode 100644 (file)
index 0000000..2f19c78
Binary files /dev/null and b/bin/as/test/libc.a.ok differ
index eea79ab..1851304 100755 (executable)
@@ -9,5 +9,9 @@ done
 ../as -o aspseudo.o -R aspseudo.s
 diff -q aspseudo.o aspseudo.o.ok
 
-#ld -X crt0.o -o as asscan1.o asscan2.o asscan3.o asscan4.o bignum1.o bignum2.o natof.o floattab.o asparse.o asexpr.o asmain.o assyms.o asjxxx.o ascode.o aspseudo.o assizetab.o asio.o -L. -lc
-#diff -q as as.ok
+cp crt0.o.ok crt0.o
+cp libc.a.ok libc.a
+touch --date="01 Jan 1980 12:00:00" libc.a
+
+../../ld -X crt0.o -o as asscan1.o asscan2.o asscan3.o asscan4.o bignum1.o bignum2.o natof.o floattab.o asparse.o asexpr.o asmain.o assyms.o asjxxx.o ascode.o aspseudo.o assizetab.o asio.o -L. -lc
+diff -q as as.ok
index 206504c..49dc488 100644 (file)
--- a/bin/ld.c
+++ b/bin/ld.c
 #include <sys/trace.h>
 /*#include <sys/types.h> gen.h*/
 
+#ifdef X_
+struct NLIST {
+       union {
+               char    *n_name;        /* for use when in-core */
+       } n_un;
+unsigned char  n_type;         /* type flag, i.e. N_TEXT etc; see below */
+       char    n_other;        /* unused */
+       short   n_desc;         /* see <stab.h> */
+unsigned long  n_value;        /* value of this symbol (or sdb offset) */
+};
+#else
+#define NLIST nlist
+#endif
+
 /*
  * Copyright (c) 1980 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
@@ -104,11 +118,11 @@ static char sccsid[] = "@(#)ld.c  5.4 (Berkeley) 11/26/85";
  * symbol table segment first.)
  */
 struct symseg {
-       struct  nlist *sy_first;        /* base of this alloc'ed segment */
-       struct  nlist *sy_last;         /* end of this segment, for n_strx */
+       struct  NLIST *sy_first;        /* base of this alloc'ed segment */
+       struct  NLIST *sy_last;         /* end of this segment, for n_strx */
        int     sy_used;                /* symbols used in this seg */
-       struct  nlist **sy_hfirst;      /* base of hash table, this seg */
-       struct  nlist **sy_hlast;       /* end of hash table, this seg */
+       struct  NLIST **sy_hfirst;      /* base of hash table, this seg */
+       struct  NLIST **sy_hlast;       /* end of hash table, this seg */
 } symseg[NSEG], *csymseg;
 
 /*
@@ -130,15 +144,15 @@ struct    symseg {
 #define        xsym(x) (symseg[(x)/NSYM].sy_first+((x)%NSYM))
 /* symx() is a function, defined below */
 
-struct nlist cursym;           /* current symbol */
-struct nlist *lastsym;         /* last symbol entered */
-struct nlist *nextsym;         /* next available symbol table entry */
-struct nlist *addsym;          /* first sym defined during incr load */
+struct NLIST cursym;           /* current symbol */
+struct NLIST *lastsym;         /* last symbol entered */
+struct NLIST *nextsym;         /* next available symbol table entry */
+struct NLIST *addsym;          /* first sym defined during incr load */
 int    nsym;                   /* pass2: number of local symbols in a.out */
 /* nsym + symx(nextsym) is the symbol table size during pass2 */
 
-/*struct       nlist **lookup(), **slookup();*/
-struct nlist *p_etext, *p_edata, *p_end, *entrypt;
+/*struct       NLIST **lookup(), **slookup();*/
+struct NLIST *p_etext, *p_edata, *p_end, *entrypt;
 
 /*
  * Definitions of segmentation for library member table.
@@ -169,7 +183,7 @@ struct      libseg {
 #define        LHSIZ   31
 struct local {
        int     l_index;                /* index to symbol in file */
-       struct  nlist *l_symbol;        /* ptr to symbol table */
+       struct  NLIST *l_symbol;        /* ptr to symbol table */
        struct  local *l_link;          /* hash link */
 } *lochash[LHSIZ], lhinit[NSYMPR];
 struct locseg {
@@ -196,6 +210,12 @@ int        ssiz;           /* size of string table for table of contents */
 struct ranlib *tab;    /* the table of contents (dynamically allocated) */
 char   *tabstr;        /* string table for table of contents */
 
+#ifdef X_
+#define RAN_NAME(x) (tabstr + (x).ran_un.ran_strx)
+#else
+#define RAN_NAME(x) ((x).ran_un.ran_name)
+#endif
+
 /*
  * We open each input file or library only once, but in pass2 we
  * (historically) read from such a file at 2 different places at the
@@ -379,8 +399,8 @@ void nextlibp __P((off_t val));
 int ldrand __P((void));
 int load1 __P((int libflg, off_t loc));
 void middle __P((void));
-void fixspec __P((struct nlist *sym, long offset));
-void ldrsym __P((register struct nlist *sp, long val, int type));
+void fixspec __P((struct NLIST *sym, long offset));
+void ldrsym __P((register struct NLIST *sp, long val, int type));
 void setupout __P((void));
 void outb __P((register struct biobuf **bp, int inc, int bufsize));
 void load2arg __P((char *acp));
@@ -391,16 +411,16 @@ void finishout __P((void));
 void mkfsym __P((char *s));
 void getarhdr __P((void));
 void mget __P((void *_loc, int n, register STREAM *sp));
-void symwrite __P((struct nlist *sp, struct biobuf *bp));
+void symwrite __P((struct NLIST *sp, struct biobuf *bp));
 void dseek __P((register STREAM *sp, long loc, long s));
 char get __P((STREAM *asp));
 int getfile __P((char *acp));
 int libopen __P((char *name, int oflags));
-struct nlist **lookup __P((void));
-void symfree __P((struct nlist *saved));
-struct nlist **slookup __P((char *s));
-int enter __P((register struct nlist **hp));
-int symx __P((struct nlist *sp));
+struct NLIST **lookup __P((void));
+void symfree __P((struct NLIST *saved));
+struct NLIST **slookup __P((char *s));
+int enter __P((register struct NLIST **hp));
+int symx __P((struct NLIST *sp));
 void symreloc __P((void));
 void error __P((int n, char *s));
 void readhdr __P((off_t loc));
@@ -753,7 +773,9 @@ void load1arg(cp) register char *cp; {
                        if (tp->ran_un.ran_strx < 0 ||
                            tp->ran_un.ran_strx >= ssiz)
                                error(1, "mangled archive table of contents");
+#ifndef X_
                        tp->ran_un.ran_name = tabstr + tp->ran_un.ran_strx;
+#endif
                }
                while (ldrand())
                        continue;
@@ -825,14 +847,14 @@ void nextlibp(val) off_t val; {
  * Indicate to our caller whether this process netted any more symbols.
  */
 int ldrand() {
-       register struct nlist *sp, **hp;
+       register struct NLIST *sp, **hp;
        register struct ranlib *tp, *tplast;
        off_t loc;
        int nsymt = symx(nextsym);
 
        tplast = &tab[tnum-1];
        for (tp = tab; tp <= tplast; tp++) {
-               if ((hp = slookup(tp->ran_un.ran_name)) == 0 || *hp == 0)
+               if ((hp = slookup(RAN_NAME(*tp))) == 0 || *hp == 0)
                        continue;
                sp = *hp;
                if (sp->n_type != N_EXT+N_UNDF)
@@ -849,12 +871,15 @@ int ldrand() {
  * Examine a single file or archive member on pass 1.
  */
 int load1(libflg, loc) int libflg; off_t loc; {
-       register struct nlist *sp;
-       struct nlist *savnext;
+       register struct NLIST *sp;
+       struct NLIST *savnext;
        int ndef, nlocal, type, size, nsymt;
        register int i;
        off_t maxoff;
        struct stat stb;
+#ifdef X_
+       struct nlist temp;
+#endif
 
        readhdr(loc);
        if (filhdr.a_syms == 0) {
@@ -872,7 +897,7 @@ int load1(libflg, loc) int libflg; off_t loc; {
                error(1, "too small (old format .o?)");
        ctrel = tsize; cdrel += dsize; cbrel += bsize;
        ndef = 0;
-       nlocal = sizeof(cursym);
+       nlocal = sizeof(struct nlist);
        savnext = nextsym;
        loc += N_SYMOFF(filhdr);
        dseek(&text, loc, filhdr.a_syms);
@@ -884,6 +909,21 @@ int load1(libflg, loc) int libflg; off_t loc; {
                error(1, "no space for string table");
        mget(curstr+sizeof(off_t), size-sizeof(off_t), &reloc);
        while (text.size > 0) {
+#ifdef X_
+               mget(&temp, sizeof (struct nlist), &text);
+               if (temp.n_un.n_strx) {
+                       if (temp.n_un.n_strx<sizeof(size) ||
+                           temp.n_un.n_strx>=size)
+                               error(1, "bad string table index (pass 1)");
+                       cursym.n_un.n_name = curstr + temp.n_un.n_strx;
+               }
+               else
+                       cursym.n_un.n_name = 0;
+               cursym.n_type = temp.n_type;
+               cursym.n_other = temp.n_other;
+               cursym.n_desc = temp.n_desc;
+               cursym.n_value = temp.n_value;
+#else
                mget(&cursym, sizeof(struct nlist), &text);
                if (cursym.n_un.n_strx) {
                        if (cursym.n_un.n_strx<sizeof(size) ||
@@ -891,11 +931,12 @@ int load1(libflg, loc) int libflg; off_t loc; {
                                error(1, "bad string table index (pass 1)");
                        cursym.n_un.n_name = curstr + cursym.n_un.n_strx;
                }
+#endif
                type = cursym.n_type;
                if ((type&N_EXT)==0) {
                        if (Xflag==0 || cursym.n_un.n_name[0]!='L' ||
                            type & N_STAB)
-                               nlocal += sizeof cursym;
+                               nlocal += sizeof (struct nlist);
                        continue;
                }
                symreloc();
@@ -941,7 +982,7 @@ int load1(libflg, loc) int libflg; off_t loc; {
 }
 
 void middle() {
-       register struct nlist *sp;
+       register struct NLIST *sp;
        long csize, t, corigin, ocsize;
        int nund, rnd;
        char s;
@@ -1054,7 +1095,7 @@ void middle() {
        if (sflag || xflag)
                ssize = 0;
        bsize += csize;
-       nsym = ssize / (sizeof cursym);
+       nsym = ssize / sizeof (struct nlist);
        if (Aflag) {
                fixspec(p_etext,torigin);
                fixspec(p_edata,dorigin);
@@ -1062,13 +1103,13 @@ void middle() {
        }
 }
 
-void fixspec(sym, offset) struct nlist *sym; long offset; {
+void fixspec(sym, offset) struct NLIST *sym; long offset; {
 
        if(symx(sym) < symx(addsym) && sym!=0)
                sym->n_value += offset;
 }
 
-void ldrsym(sp, val, type) register struct nlist *sp; long val; int type; {
+void ldrsym(sp, val, type) register struct NLIST *sp; long val; int type; {
 
        if (sp == 0)
                return;
@@ -1112,7 +1153,7 @@ void setupout() {
        filhdr.a_bss = bss;
        filhdr.a_trsize = trsize;
        filhdr.a_drsize = drsize;
-       filhdr.a_syms = sflag? 0: (ssize + (sizeof cursym)*symx(nextsym));
+       filhdr.a_syms = sflag? 0: (ssize + sizeof (struct nlist)*symx(nextsym));
        if (entrypt) {
                if (entrypt->n_type!=N_EXT+N_TEXT)
                        error(0, "entry point not in text");
@@ -1181,10 +1222,13 @@ void load2arg(acp) char *acp; {
 
 void load2(loc) long loc; {
        int size;
-       register struct nlist *sp;
+       register struct NLIST *sp;
        register struct local *lp;
        register int symno, i;
        int type;
+#ifdef X_
+       struct nlist temp;
+#endif
 
        readhdr(loc);
        if (!funding) {
@@ -1216,6 +1260,21 @@ void load2(loc) long loc; {
                filhdr.a_trsize+filhdr.a_drsize, filhdr.a_syms);
        while (text.size > 0) {
                symno++;
+#ifdef X_
+               mget(&temp, sizeof (struct nlist), &text);
+               if (temp.n_un.n_strx) {
+                       if (temp.n_un.n_strx<sizeof(size) ||
+                           temp.n_un.n_strx>=size)
+                               error(1, "bad string table index (pass 2)");
+                       cursym.n_un.n_name = curstr + temp.n_un.n_strx;
+               }
+               else
+                       cursym.n_un.n_name = 0;
+               cursym.n_type = temp.n_type;
+               cursym.n_other = temp.n_other;
+               cursym.n_desc = temp.n_desc;
+               cursym.n_value = temp.n_value;
+#else
                mget(&cursym, sizeof(struct nlist), &text);
                if (cursym.n_un.n_strx) {
                        if (cursym.n_un.n_strx<sizeof(size) ||
@@ -1223,6 +1282,7 @@ void load2(loc) long loc; {
                                error(1, "bad string table index (pass 2)");
                        cursym.n_un.n_name = curstr + cursym.n_un.n_strx;
                }
+#endif
 /* inline expansion of symreloc() */
                switch (cursym.n_type & 017) {
 
@@ -1361,7 +1421,7 @@ void tracesym() {
  * each relocation datum address by our base position in the new segment.
  */
 void load2td(creloc, position, b1, b2) long creloc; int position; struct biobuf *b1; struct biobuf *b2; {
-       register struct nlist *sp;
+       register struct NLIST *sp;
        register struct local *lp;
        long tw;
        register struct relocation_info *rp, *rpend;
@@ -1580,19 +1640,36 @@ top:
 #undef loc
 }
 
-void symwrite(sp, bp) struct nlist *sp; struct biobuf *bp; {
+void symwrite(sp, bp) struct NLIST *sp; struct biobuf *bp; {
        register int len;
        register char *str;
+#ifdef X_
+       struct nlist temp;
+#endif
 
        str = sp->n_un.n_name;
        if (str) {
+#ifdef X_
+               temp.n_un.n_strx = offset;
+#else
                sp->n_un.n_strx = offset;
+#endif
                len = strlen(str) + 1;
                bwrite(str, len, strout);
                offset += len;
        }
+#ifdef X_
+       else
+               temp.n_un.n_strx = 0;
+       temp.n_type = sp->n_type;
+       temp.n_other = sp->n_other;
+       temp.n_desc = sp->n_desc;
+       temp.n_value = sp->n_value;
+       bwrite(&temp, sizeof (temp), bp);
+#else
        bwrite(sp, sizeof (*sp), bp);
        sp->n_un.n_name = str;
+#endif
 }
 
 void dseek(sp, loc, s) register STREAM *sp; long loc; long s; {
@@ -1731,9 +1808,9 @@ int libopen(name, oflags) char *name; int oflags; {
        return (fd);
 }
 
-struct nlist **lookup() {
+struct NLIST **lookup() {
        register int sh; 
-       register struct nlist **hp;
+       register struct NLIST **hp;
        register char *cp, *cp1;
        register struct symseg *gp;
        register int i;
@@ -1744,10 +1821,10 @@ struct nlist **lookup() {
        sh = (sh & 0x7fffffff) % HSIZE;
        for (gp = symseg; gp < &symseg[NSEG]; gp++) {
                if (gp->sy_first == 0) {
-                       gp->sy_first = (struct nlist *)
-                           calloc(NSYM, sizeof (struct nlist));
-                       gp->sy_hfirst = (struct nlist **)
-                           calloc(HSIZE, sizeof (struct nlist *));
+                       gp->sy_first = (struct NLIST *)
+                           calloc(NSYM, sizeof (struct NLIST));
+                       gp->sy_hfirst = (struct NLIST **)
+                           calloc(HSIZE, sizeof (struct NLIST *));
                        if (gp->sy_first == 0 || gp->sy_hfirst == 0)
                                error(1, "ran out of space for symbol table");
                        gp->sy_last = gp->sy_first + NSYM;
@@ -1782,9 +1859,9 @@ struct nlist **lookup() {
 #endif
 }
 
-void symfree(saved) struct nlist *saved; {
+void symfree(saved) struct NLIST *saved; {
        register struct symseg *gp;
-       register struct nlist *sp;
+       register struct NLIST *sp;
 
        for (gp = csymseg; gp >= symseg; gp--, csymseg--) {
                sp = gp->sy_first + gp->sy_used;
@@ -1806,7 +1883,7 @@ void symfree(saved) struct nlist *saved; {
        error(1, "symfree botch");
 }
 
-struct nlist **slookup(s) char *s; {
+struct NLIST **slookup(s) char *s; {
 
        cursym.n_un.n_name = s;
        cursym.n_type = N_EXT+N_UNDF;
@@ -1814,8 +1891,8 @@ struct nlist **slookup(s) char *s; {
        return (lookup());
 }
 
-int enter(hp) register struct nlist **hp; {
-       register struct nlist *sp;
+int enter(hp) register struct NLIST **hp; {
+       register struct NLIST *sp;
 
        if (*hp==0) {
                if (hp < csymseg->sy_hfirst || hp >= csymseg->sy_hlast)
@@ -1834,7 +1911,7 @@ int enter(hp) register struct nlist **hp; {
        }
 }
 
-int symx(sp) struct nlist *sp; {
+int symx(sp) struct NLIST *sp; {
        register struct symseg *gp;
 
        if (sp == 0)
index 5a5f17c..8fa81ac 100644 (file)
--- a/bin/nm.c
+++ b/bin/nm.c
@@ -47,6 +47,12 @@ off_t        strsiz;
 int    narg;
 int    errs;
 
+#ifdef X_
+#define N_NAME(x) ((x).n_un.n_strx ? strp + (x).n_un.n_strx : "")
+#else
+#define N_NAME(x) ((x).n_un.n_name)
+#endif
+
 #ifndef __P
 #ifdef __STDC__
 #define __P(args) args
@@ -111,7 +117,9 @@ void main(argc, argv) int argc; char **argv; {
 }
 
 void namelist() {
+#ifndef X_
        register int j;
+#endif
 
        archive = 0;
        fi = fopen(*xargv, "r");
@@ -194,12 +202,14 @@ void namelist() {
                        error(1, "ran out of memory");
                if (fread(strp+sizeof(strsiz),strsiz-sizeof(strsiz),1,fi) != 1)
                        error(1, "error reading string table");
+#ifndef X_
                for (j = 0; j < i; j++)
                        if (symp[j].n_un.n_strx)
                                symp[j].n_un.n_name =
                                    symp[j].n_un.n_strx + strp;
                        else
                                symp[j].n_un.n_name = "";
+#endif
                if (pflg==0)
                        qsort(symp, i, sizeof(struct nlist), (int (*) __P((void *p0, void *p1)))compare);
                if ((archive || narg>1) && oflg==0)
@@ -229,7 +239,7 @@ void psyms(symp, nsyms) register struct nlist *symp; int nsyms; {
                            symp[n].n_value,
                            symp[n].n_other & 0xff, symp[n].n_desc & 0xffff,
                            stab(symp[n].n_type & 0xff),
-                           symp[n].n_un.n_name);
+                           N_NAME(symp[n]));
                        continue;
                }
                if (c == N_FN)
@@ -273,7 +283,7 @@ void psyms(symp, nsyms) register struct nlist *symp; int nsyms; {
                                printf(N_FORMAT, symp[n].n_value);
                        printf(" %c ", c);
                }
-               printf("%s\n", symp[n].n_un.n_name);
+               printf("%s\n", N_NAME(symp[n]));
        }
 }
 
@@ -284,7 +294,7 @@ int compare(p1, p2) struct nlist *p1; struct nlist *p2; {
                if (p1->n_value < p2->n_value)
                        return(-rflg);
        }
-       return (rflg * strcmp(p1->n_un.n_name, p2->n_un.n_name));
+       return (rflg * strcmp(N_NAME(*p1), N_NAME(*p2)));
 }
 
 int nextel(af) FILE *af; {
index 7ea58a1..4be751e 100644 (file)
@@ -16,7 +16,9 @@
 struct ranlib {
        union {
                off_t   ran_strx;       /* string table index of */
+#ifndef X_
                char    *ran_name;      /* symbol defined by */
+#endif
        } ran_un;
        off_t   ran_off;                /* library member at this offset */
 };
index d91cf22..109567b 100644 (file)
@@ -193,7 +193,7 @@ sys/bind.c sys/socket.h
 sys/brk.c sys/proc.h
 sys/chdir.c sys/proc.h
 sys/chmod.c sys/stat.h
-sys/chown.c sys/file.h
+sys/chown.c sys/stat.h
 sys/chroot.c sys/proc.h
 sys/close.c sys/file.h
 sys/connect.c sys/socket.h
@@ -207,7 +207,7 @@ sys/execv.c sys/exec.h
 sys/execve.c sys/exec.h
 sys/_exit.c sys/proc.h
 sys/fchmod.c sys/stat.h
-sys/fchown.c sys/file.h
+sys/fchown.c sys/stat.h
 sys/fcntl.c sys/file.h
 sys/flock.c sys/file.h
 sys/fork.c sys/proc.h
index 0163441..342fbfd 100644 (file)
@@ -7,12 +7,14 @@ LD=ld
 #      @(#)Makefile    5.4 (Berkeley) 9/5/85
 #
 
-SRCS=  close.c fstat.c getpagesize.c getpid.c isatty.c linux.c lseek.c read.c \
-       readv.c sbrk.c sigvec.c stat.c unlink.c vopen.c write.c writev.c \
-       _exit.c
-OBJS=  close.o fstat.o getpagesize.o getpid.o isatty.o linux.o lseek.o read.o \
-       readv.o sbrk.o sigvec.o stat.o unlink.o vopen.o write.o writev.o \
-       _exit.o
+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
 TAGSFILE=tags
 
 .c.o:
diff --git a/lib/libc/linux/sys/chmod.c b/lib/libc/linux/sys/chmod.c
new file mode 100644 (file)
index 0000000..752e4e8
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <sys/nox_stat.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/stat.h>
+#include "linux.h"
+
+int chmod(s, m) char *s; int m; {
+       if (nox_chmod(s, (nox_mode_t)m)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/chown.c b/lib/libc/linux/sys/chown.c
new file mode 100644 (file)
index 0000000..46d3932
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/stat.h>
+#include "linux.h"
+
+int chown(s, u, g) char *s; int u; int g; {
+       if (nox_chown(s, (nox_uid_t)u, (nox_gid_t)g)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/fchmod.c b/lib/libc/linux/sys/fchmod.c
new file mode 100644 (file)
index 0000000..4a28b55
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <sys/nox_stat.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/stat.h>
+#include "linux.h"
+
+int fchmod(f, m) int f; int m; {
+       if (nox_fchmod((nox_int)f, (nox_mode_t)m)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/fchown.c b/lib/libc/linux/sys/fchown.c
new file mode 100644 (file)
index 0000000..caca052
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/stat.h>
+#include "linux.h"
+
+int fchown(f, u, g) int f; int u; int g; {
+       if (nox_fchown((nox_int)f, (nox_uid_t)u, (nox_gid_t)g)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/ftruncate.c b/lib/libc/linux/sys/ftruncate.c
new file mode 100644 (file)
index 0000000..743186c
--- /dev/null
@@ -0,0 +1,16 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int ftruncate(d, l) int d; off_t l; {
+       if (nox_ftruncate((nox_int)d, (nox_off_t)l)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
index 545f134..a9b4c9d 100644 (file)
@@ -1,7 +1,7 @@
-#include <nox_unistd.h>
+/*#include <nox_unistd.h>*/
 
 #include <sys.h>
 
 int getpagesize() {
-       return (int)nox_getpagesize();
+       return 0x400; /*(int)nox_getpagesize();*/
 }
diff --git a/lib/libc/linux/sys/link.c b/lib/libc/linux/sys/link.c
new file mode 100644 (file)
index 0000000..aa26d49
--- /dev/null
@@ -0,0 +1,14 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include "linux.h"
+
+int link(a, b) char *a; char *b; {
+       if (nox_link(a, b)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
index f4b6a1e..d6a820c 100644 (file)
@@ -159,6 +159,6 @@ void htot_stat(statbuf, res) struct nox_stat *statbuf; struct stat *res; {
        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 = (long)statbuf->nox_st_blksize;
+       res->st_blksize = /*0x2000;*/ (long)statbuf->nox_st_blksize;
        res->st_blocks = (long)statbuf->nox_st_blocks;
 }
diff --git a/lib/libc/linux/sys/symlink.c b/lib/libc/linux/sys/symlink.c
new file mode 100644 (file)
index 0000000..75d0ced
--- /dev/null
@@ -0,0 +1,14 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include "linux.h"
+
+int symlink(t, f) char *t; char *f; {
+       if (nox_symlink(t, f)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/truncate.c b/lib/libc/linux/sys/truncate.c
new file mode 100644 (file)
index 0000000..fc1b062
--- /dev/null
@@ -0,0 +1,16 @@
+#include <nox_errno.h>
+#include <nox_unistd.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int truncate(p, l) char *p; off_t l; {
+       if (nox_truncate(p, (nox_off_t)l)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       return 0;
+}
diff --git a/lib/libc/linux/sys/umask.c b/lib/libc/linux/sys/umask.c
new file mode 100644 (file)
index 0000000..bdf9bac
--- /dev/null
@@ -0,0 +1,8 @@
+#include <sys/nox_stat.h>
+#include <sys/nox_types.h>
+
+#include <sys/stat.h>
+
+int umask(n) int n; {
+       return (int)nox_umask((nox_mode_t)n);
+}
index ef21e42..def07ed 100644 (file)
@@ -1,7 +1,5 @@
-#include <gen.h>
 #include <sys/file.h>
 
 int creat(s, m) char *s; int m; {
-       write(2, "creat()\n", 8);
-       abort();
+       return open(s, O_CREAT | O_WRONLY | O_TRUNC, m);
 }
diff --git a/n.sh b/n.sh
index 70546a7..9516932 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -26,6 +26,6 @@ mkdir -p lib/libc/ns/profiled
 mkdir -p lib/libc/stdio/profiled
 mkdir -p lib/libc/sys/profiled
 (cd lib/libc && make.sh clean && make.sh && make.sh install)
-(cd bin && make.sh clean && make.sh SUBDIR= NSTD= KMEM= && make.sh SUBDIR= NSTD= KMEM= install)
+(cd bin && make.sh clean && make.sh SUBDIR=as NSTD= KMEM= && make.sh SUBDIR=as NSTD= KMEM= install)
 
 #(cd test && make clean && make)
index faf364e..26f0bae 100644 (file)
@@ -142,9 +142,6 @@ int nfile;
 /* sys/access.c */
 int access __P((char *p, int m));
 
-/* sys/chown.c */
-int chown __P((char *s, int u, int g));
-
 /* sys/close.c */
 int close __P((int f));
 
@@ -157,9 +154,6 @@ int dup __P((int f));
 /* sys/dup2.c */
 int dup2 __P((int o, int n));
 
-/* sys/fchown.c */
-int fchown __P((int f, int u, int g));
-
 /* sys/fcntl.c */
 int fcntl __P((int f, int c, int a));
 
index cd12645..8e3b986 100644 (file)
@@ -57,9 +57,15 @@ struct       stat {
 /* sys/chmod.c */
 int chmod __P((char *s, int m));
 
+/* sys/chown.c */
+int chown __P((char *s, int u, int g));
+
 /* sys/fchmod.c */
 int fchmod __P((int f, int m));
 
+/* sys/fchown.c */
+int fchown __P((int f, int u, int g));
+
 /* sys/fstat.c */
 int fstat __P((int f, struct stat *b));