diff --git a/qa/kern/segattach.c b/qa/kern/segattach.c index 866871e..f80c1bb 100644 --- a/qa/kern/segattach.c +++ b/qa/kern/segattach.c @@ -58,7 +58,7 @@ main(void) } if(p == (char*)seg+(1024*1024)){ print("FAIL: segfree: no page previously freed had been faulted\n"); - exit("FAIL"); + exits("FAIL"); } if(segdetach(seg) < 0){ diff --git a/sys/include/fcall.h b/sys/include/9P2000.h similarity index 86% rename from sys/include/fcall.h rename to sys/include/9P2000.h index 3cd23bc..610b8b0 100644 --- a/sys/include/fcall.h +++ b/sys/include/9P2000.h @@ -14,6 +14,17 @@ #define MAXWELEM 16 +/* Plan9/9p2000 flags for Topen Tcreate */ +#define NP_OREAD 0 /* open for read */ +#define NP_OWRITE 1 /* write */ +#define NP_ORDWR 2 /* read and write */ +#define NP_OEXEC 3 /* execute, == read but check execute permission */ +#define NP_OTRUNC 16 /* or'ed in (except for exec), truncate file first */ +#define NP_ORCLOSE 64 /* or'ed in, remove on close */ + +/* bits that must be zero in open/create mode */ +#define NP_OZEROES ~(NP_OREAD|NP_OWRITE|NP_ORDWR|NP_OEXEC|NP_OTRUNC|NP_ORCLOSE) + typedef struct Fcall { @@ -44,7 +55,7 @@ struct Fcall char *aname; /* Tauth, Tattach */ }; struct { - uint32_t perm; /* Tcreate */ + uint32_t perm; /* Tcreate */ char *name; /* Tcreate */ uint8_t mode; /* Tcreate, Topen */ }; diff --git a/sys/include/libc.h b/sys/include/libc.h index a396c20..f2ce6fd 100644 --- a/sys/include/libc.h +++ b/sys/include/libc.h @@ -551,21 +551,26 @@ extern void freenetconninfo(NetConnInfo*); #define MCACHE 0x0010 /* cache some data */ #define MMASK 0x0017 /* all bits on */ -#define OREAD 0 /* open for read */ -#define OWRITE 1 /* write */ -#define ORDWR 2 /* read and write */ -#define OSTAT 4 /* open for stat/wstat */ -#define OEXEC 7 /* execute, == read but check execute permission */ -#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */ -#define OCEXEC 32 /* or'ed in, close on exec */ -#define ORCLOSE 64 /* or'ed in, remove on close */ -#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */ -// #define OBEHIND 0x2000 /* use write behind for writes [for 9n] */ +/* Open modes: Kernel reserved flags */ +#define OSTAT 0x00 /* open for stat/wstat */ +#define OREAD 0x01 /* open for read */ +#define OWRITE 0x02 /* write */ +#define ORDWR (OREAD|OWRITE) /* read and write */ +#define OEXEC 0x04 /* execute, == read but check execute permission */ +#define OCEXEC 0x08 /* or'ed in, close on exec */ +#define ORCLOSE 0x10 /* or'ed in, remove on close */ +#define OKMODE 0xff /* least significant byte reserved for kernel use */ -#define AEXIST 0 /* accessible: exists */ -#define AEXEC 1 /* execute access */ -#define AWRITE 2 /* write access */ -#define AREAD 4 /* read access */ +/* Open modes: Popular flags among filesystems */ +#define OTRUNC 0x0100 /* or'ed in (except for exec), truncate file first */ +#define OEXCL 0x0200 /* or'ed in, exclusive create */ + +/* Access modes */ +#define AEXIST OSTAT /* accessible: exists */ +#define AREAD OREAD /* read access */ +#define AWRITE OWRITE /* write access */ +#define AEXEC OEXEC /* execute access */ +#define AMASK (OSTAT|OREAD|OWRITE|OEXEC) /* Segattch */ #define SG_RONLY 0040 /* read only */ diff --git a/sys/src/cmd/acme/acme.c b/sys/src/cmd/acme/acme.c index 1e8d230..db15b0b 100644 --- a/sys/src/cmd/acme/acme.c +++ b/sys/src/cmd/acme/acme.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -114,7 +114,7 @@ threadmain(int argc, char *argv[]) fontnames[0] = getenv("font"); if(fontnames[0] == nil) fontnames[0] = "/lib/font/bit/fixed/unicode.6x13.font"; - if(access(fontnames[0], 0) < 0){ + if(access(fontnames[0], AEXIST) < 0){ fprint(2, "acme: can't access %s: %r\n", fontnames[0]); exits("font open"); } @@ -133,7 +133,7 @@ threadmain(int argc, char *argv[]) free(p); } if(maxtab == 0) - maxtab = 4; + maxtab = 4; if(loadfile) rowloadfonts(loadfile); putenv("font", fontnames[0]); @@ -458,7 +458,7 @@ mousethread(void *v) if(cplumb == nil) alts[MPlumb].op = CHANNOP; alts[NMALT].op = CHANEND; - + for(;;){ qlock(&row); flushwarnings(); diff --git a/sys/src/cmd/acme/addr.c b/sys/src/cmd/acme/addr.c index 9c91f71..b90a417 100644 --- a/sys/src/cmd/acme/addr.c +++ b/sys/src/cmd/acme/addr.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/aux/win/fs.c b/sys/src/cmd/acme/aux/win/fs.c index 2c3b1c3..c35f9fa 100644 --- a/sys/src/cmd/acme/aux/win/fs.c +++ b/sys/src/cmd/acme/aux/win/fs.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> #include "dat.h" diff --git a/sys/src/cmd/acme/aux/win/main.c b/sys/src/cmd/acme/aux/win/main.c index a9a1e16..21b1783 100644 --- a/sys/src/cmd/acme/aux/win/main.c +++ b/sys/src/cmd/acme/aux/win/main.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include #include "dat.h" diff --git a/sys/src/cmd/acme/aux/win/pipe.c b/sys/src/cmd/acme/aux/win/pipe.c index 58b53d6..a065769 100644 --- a/sys/src/cmd/acme/aux/win/pipe.c +++ b/sys/src/cmd/acme/aux/win/pipe.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> #include "dat.h" diff --git a/sys/src/cmd/acme/buff.c b/sys/src/cmd/acme/buff.c index 4892801..2983142 100644 --- a/sys/src/cmd/acme/buff.c +++ b/sys/src/cmd/acme/buff.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/cols.c b/sys/src/cmd/acme/cols.c index ab6c96e..d3f649f 100644 --- a/sys/src/cmd/acme/cols.c +++ b/sys/src/cmd/acme/cols.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/disk.c b/sys/src/cmd/acme/disk.c index cc9fb89..e775642 100644 --- a/sys/src/cmd/acme/disk.c +++ b/sys/src/cmd/acme/disk.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/ecmd.c b/sys/src/cmd/acme/ecmd.c index 3170741..a6dbfcc 100644 --- a/sys/src/cmd/acme/ecmd.c +++ b/sys/src/cmd/acme/ecmd.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "edit.h" diff --git a/sys/src/cmd/acme/edit.c b/sys/src/cmd/acme/edit.c index bb6eea4..c54f464 100644 --- a/sys/src/cmd/acme/edit.c +++ b/sys/src/cmd/acme/edit.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "edit.h" diff --git a/sys/src/cmd/acme/elog.c b/sys/src/cmd/acme/elog.c index ab6ffae..31012cc 100644 --- a/sys/src/cmd/acme/elog.c +++ b/sys/src/cmd/acme/elog.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/exec.c b/sys/src/cmd/acme/exec.c index 31bda3b..fa6005f 100644 --- a/sys/src/cmd/acme/exec.c +++ b/sys/src/cmd/acme/exec.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -165,7 +165,7 @@ execute(Text *t, uint32_t aq0, uint32_t aq1, int external, Text *argt) f |= 2; } aa = getbytearg(argt, TRUE, TRUE, &a); - if(a){ + if(a){ if(strlen(a) > EVENTSIZE){ /* too big; too bad */ free(aa); free(a); @@ -921,7 +921,7 @@ putall(Text*ta, Text*b, Text*tc, int d, int ie, Rune*f, int g) if(w->nopen[QWevent] > 0) continue; a = runetobyte(w->body.file->name, w->body.file->nname); - e = access(a, 0); + e = access(a, AEXIST); if(w->body.file->mod || w->body.ncache) if(e < 0) warning(nil, "no auto-Put of %s: %r\n", a); diff --git a/sys/src/cmd/acme/file.c b/sys/src/cmd/acme/file.c index fe71315..3322cfe 100644 --- a/sys/src/cmd/acme/file.c +++ b/sys/src/cmd/acme/file.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/fsys.c b/sys/src/cmd/acme/fsys.c index 02400f9..6c830de 100644 --- a/sys/src/cmd/acme/fsys.c +++ b/sys/src/cmd/acme/fsys.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -279,7 +279,7 @@ fsysmount(Rune *dir, int ndir, Rune **incl, int nincl) close(sfd); m = fsysaddid(dir, ndir, incl, nincl); sprint(buf, "%d", m->id); - if(mount(cfd, -1, "/mnt/acme", MREPL, buf, 'M') < 0){ + if(mount(cfd, -1, "/mnt/acme", MREPL, buf, '9') < 0){ fsysdelid(m); return nil; } @@ -482,7 +482,7 @@ fsyswalk(Xfid *x, Fid *f) qunlock(&row); dir = dirtabw; goto Accept; - + Regular: // if(FILE(f->qid) == Qacme) /* empty directory */ // break; @@ -548,20 +548,20 @@ fsysopen(Xfid *x, Fid *f) int m; /* can't truncate anything, so just disregard */ - x->mode &= ~(OTRUNC|OCEXEC); + x->mode &= ~(NP_OTRUNC); /* can't execute or remove anything */ - if(x->mode==OEXEC || (x->mode&ORCLOSE)) + if(x->mode==NP_OEXEC || (x->mode&NP_ORCLOSE)) goto Deny; switch(x->mode){ default: goto Deny; - case OREAD: + case NP_OREAD: m = 0400; break; - case OWRITE: + case NP_OWRITE: m = 0200; break; - case ORDWR: + case NP_ORDWR: m = 0600; break; } diff --git a/sys/src/cmd/acme/look.c b/sys/src/cmd/acme/look.c index 84132a1..4bfe40f 100644 --- a/sys/src/cmd/acme/look.c +++ b/sys/src/cmd/acme/look.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -351,7 +351,7 @@ includefile(Rune *dir, Rune *file, int nfile) m = runestrlen(dir); a = emalloc((m+1+nfile)*UTFmax+1); sprint(a, "%S/%.*S", dir, nfile, file); - n = access(a, 0); + n = access(a, AEXIST); free(a); if(n < 0) return (Runestr){nil, 0}; @@ -377,7 +377,7 @@ includename(Text *t, Rune *r, int n) sprint(buf, "/%s/include", objtype); objdir = bytetorune(buf, &i); objdir = runerealloc(objdir, i+1); - objdir[i] = '\0'; + objdir[i] = '\0'; } w = t->w; @@ -536,7 +536,7 @@ expandfile(Text *t, uint32_t q0, uint32_t q1, Expand *e) if(w != nil) goto Isfile; /* if it's the name of a file, it's a file */ - if(access(e->bname, 0) < 0){ + if(access(e->bname, AEXIST) < 0){ free(e->bname); e->bname = nil; goto Isntfile; diff --git a/sys/src/cmd/acme/regx.c b/sys/src/cmd/acme/regx.c index 54adfe8..e469705 100644 --- a/sys/src/cmd/acme/regx.c +++ b/sys/src/cmd/acme/regx.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/rows.c b/sys/src/cmd/acme/rows.c index fa3d141..c2e3ff7 100644 --- a/sys/src/cmd/acme/rows.c +++ b/sys/src/cmd/acme/rows.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include "dat.h" @@ -384,7 +384,7 @@ rowdump(Row *row, char *file) 0, 0, 100*(w->r.min.y-c->r.min.y)/Dy(c->r), fontname); - }else if((w->dirty==FALSE && access(a, 0)==0) || w->isdir){ + }else if((w->dirty==FALSE && access(a, AEXIST)==0) || w->isdir){ dumped = FALSE; t->file->dumpid = w->id; Bprint(b, "f%11d %11d %11d %11d %11d %s\n", i, w->id, diff --git a/sys/src/cmd/acme/scrl.c b/sys/src/cmd/acme/scrl.c index f6e5bfb..d4cb4c3 100644 --- a/sys/src/cmd/acme/scrl.c +++ b/sys/src/cmd/acme/scrl.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/text.c b/sys/src/cmd/acme/text.c index 74a44c0..3292ca5 100644 --- a/sys/src/cmd/acme/text.c +++ b/sys/src/cmd/acme/text.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include "dat.h" diff --git a/sys/src/cmd/acme/time.c b/sys/src/cmd/acme/time.c index 799a1db..ea7abf2 100644 --- a/sys/src/cmd/acme/time.c +++ b/sys/src/cmd/acme/time.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/util.c b/sys/src/cmd/acme/util.c index 737b478..f4cff29 100644 --- a/sys/src/cmd/acme/util.c +++ b/sys/src/cmd/acme/util.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/wind.c b/sys/src/cmd/acme/wind.c index 292427f..9f3d34c 100644 --- a/sys/src/cmd/acme/wind.c +++ b/sys/src/cmd/acme/wind.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/acme/xfid.c b/sys/src/cmd/acme/xfid.c index 8d5f52d..a6d5ef9 100644 --- a/sys/src/cmd/acme/xfid.c +++ b/sys/src/cmd/acme/xfid.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/auth/changeuser.c b/sys/src/cmd/auth/changeuser.c index 07ad8ac..af1ee3d 100644 --- a/sys/src/cmd/auth/changeuser.c +++ b/sys/src/cmd/auth/changeuser.c @@ -137,7 +137,7 @@ exists(char *db, char *u) char buf[KEYDBBUF+ANAMELEN+6]; sprint(buf, "%s/%s/expire", db, u); - if(access(buf, 0) < 0) + if(access(buf, AEXIST) < 0) return 0; return 1; } diff --git a/sys/src/cmd/auth/factotum/dat.h b/sys/src/cmd/auth/factotum/dat.h index d4299a0..a5cb62b 100644 --- a/sys/src/cmd/auth/factotum/dat.h +++ b/sys/src/cmd/auth/factotum/dat.h @@ -6,7 +6,7 @@ #include #include #include /* only for 9p.h */ -#include +#include <9P2000.h> #include <9p.h> #pragma varargck type "N" Attr* diff --git a/sys/src/cmd/auth/factotum/fs.c b/sys/src/cmd/auth/factotum/fs.c index 14e1f0d..5e9672d 100644 --- a/sys/src/cmd/auth/factotum/fs.c +++ b/sys/src/cmd/auth/factotum/fs.c @@ -249,11 +249,11 @@ static struct { uint32_t perm; } dirtab[] = { "confirm", Qconfirm, 0600|DMEXCL, /* we know this is slot #0 below */ - "needkey", Qneedkey, 0600|DMEXCL, /* we know this is slot #1 below */ - "ctl", Qctl, 0644, - "rpc", Qrpc, 0666, + "needkey", Qneedkey, 0600|DMEXCL, /* we know this is slot #1 below */ + "ctl", Qctl, 0644, + "rpc", Qrpc, 0666, "proto", Qprotolist, 0444, - "log", Qlog, 0400|DMEXCL, + "log", Qlog, 0400|DMEXCL, }; static int inuse[nelem(dirtab)]; int *confirminuse = &inuse[0]; @@ -349,14 +349,14 @@ fsstat(Req *r) respond(r, nil); return; } - respond(r, "file not found"); + respond(r, "file not found"); } static void fsopen(Req *r) { int i, *p, perm; - static int need[4] = {4, 2, 6, 1}; + static int need[8] = {0, 4, 2, 6, 1, 0xff, 0xff, 0xff}; int n; Fsstate *fss; @@ -375,7 +375,7 @@ fsopen(Req *r) perm = 5; n = need[r->ifcall.mode&3]; - if((r->ifcall.mode&~(3|OTRUNC)) || ((perm&n) != n)){ + if((r->ifcall.mode&~(3|NP_OTRUNC)) || ((perm&n) != n)){ respond(r, "permission denied"); return; } diff --git a/sys/src/cmd/auth/factotum/util.c b/sys/src/cmd/auth/factotum/util.c index 32ddfee..6a19de4 100644 --- a/sys/src/cmd/auth/factotum/util.c +++ b/sys/src/cmd/auth/factotum/util.c @@ -14,7 +14,7 @@ bindnetcs(void) if(access("/net/cs", AEXIST) < 0){ if((srvfd = open("#s/cs", ORDWR)) >= 0){ - if(mount(srvfd, -1, "/net", MBEFORE, "", 'M') >= 0) + if(mount(srvfd, -1, "/net", MBEFORE, "", '9') >= 0) return 0; close(srvfd); } diff --git a/sys/src/cmd/auth/guard.srv.c b/sys/src/cmd/auth/guard.srv.c index 98ed198..9ab4ecb 100644 --- a/sys/src/cmd/auth/guard.srv.c +++ b/sys/src/cmd/auth/guard.srv.c @@ -3,7 +3,7 @@ */ #include #include -#include +#include <9P2000.h> #include #include #include diff --git a/sys/src/cmd/auth/keyfs.c b/sys/src/cmd/auth/keyfs.c index e24f793..d926858 100644 --- a/sys/src/cmd/auth/keyfs.c +++ b/sys/src/cmd/auth/keyfs.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include @@ -209,7 +209,7 @@ main(int argc, char *argv[]) error("fork"); default: close(p[1]); - if(mount(p[0], -1, mntpt, MREPL|MCREATE, "", 'M') < 0) + if(mount(p[0], -1, mntpt, MREPL|MCREATE, "", '9') < 0) error("can't mount: %r"); exits(0); } @@ -374,7 +374,7 @@ Open(Fid *f) if(!f->busy) return "open of unused fid"; mode = rhdr.mode; - if(f->qtype == Quser && (mode & (OWRITE|OTRUNC))) + if(f->qtype == Quser && (mode & (NP_OWRITE|NP_OTRUNC))) return "user already exists"; if((f->qtype == Qaeskey || f->qtype == Qpakhash) && !keydbaes) return "keyfile not in aes format"; diff --git a/sys/src/cmd/auth/login.c b/sys/src/cmd/auth/login.c index 836ac3a..fab8d52 100644 --- a/sys/src/cmd/auth/login.c +++ b/sys/src/cmd/auth/login.c @@ -110,7 +110,7 @@ mountfactotum(char *srvname) fd = open(srvname, ORDWR); if(fd < 0) sysfatal("opening factotum: %r"); - mount(fd, -1, "/mnt", MBEFORE, "", 'M'); + mount(fd, -1, "/mnt", MBEFORE, "", '9'); close(fd); } @@ -164,7 +164,7 @@ startfactotum(char *user, char *password, char *srvname) } /* wait for agent to really be there */ - while(access(srvname, 0) < 0) + while(access(srvname, AEXIST) < 0) sleep(250); /* mount it */ diff --git a/sys/src/cmd/auth/secstore/SConn.c b/sys/src/cmd/auth/secstore/SConn.c index a29f5e6..14d1b0a 100644 --- a/sys/src/cmd/auth/secstore/SConn.c +++ b/sys/src/cmd/auth/secstore/SConn.c @@ -1,3 +1,4 @@ +#define PORTABLE_SYSCALLS #include #include #include diff --git a/sys/src/cmd/auth/secstore/pak.c b/sys/src/cmd/auth/secstore/pak.c index 8dd53b0..635ea3f 100644 --- a/sys/src/cmd/auth/secstore/pak.c +++ b/sys/src/cmd/auth/secstore/pak.c @@ -1,6 +1,16 @@ +/* + * This file is part of the UCB release of Plan 9. It is subject to the license + * terms in the LICENSE file found in the top-level directory of this + * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No + * part of the UCB release of Plan 9, including this file, may be copied, + * modified, propagated, or distributed except according to the terms contained + * in the LICENSE file. + */ + // PAK is an encrypted key exchange protocol designed by Philip MacKenzie et al. // It is patented and use outside Plan 9 requires you get a license. // (All other EKE protocols are patented as well, by Lucent or others.) +#define PORTABLE_SYSCALLS #include #include #include diff --git a/sys/src/cmd/auth/secstore/secstore.c b/sys/src/cmd/auth/secstore/secstore.c index 6d51be6..7f1ef7a 100644 --- a/sys/src/cmd/auth/secstore/secstore.c +++ b/sys/src/cmd/auth/secstore/secstore.c @@ -1,4 +1,5 @@ /* secstore - network login client */ +#define PORTABLE_SYSCALLS #include #include #include diff --git a/sys/src/cmd/auth/secstore/secstored.c b/sys/src/cmd/auth/secstore/secstored.c index 503377c..4deffce 100644 --- a/sys/src/cmd/auth/secstore/secstored.c +++ b/sys/src/cmd/auth/secstore/secstored.c @@ -1,4 +1,5 @@ /* secstored - secure store daemon */ +#define PORTABLE_SYSCALLS #include #include #include diff --git a/sys/src/cmd/bind.c b/sys/src/cmd/bind.c index d407b1d..0221261 100644 --- a/sys/src/cmd/bind.c +++ b/sys/src/cmd/bind.c @@ -42,9 +42,9 @@ main(int argc, char *argv[]) if(qflag) exits(0); /* try to give a less confusing error than the default */ - if(access(argv[0], 0) < 0) + if(access(argv[0], AEXIST) < 0) fprint(2, "bind: %s: %r\n", argv[0]); - else if(access(argv[1], 0) < 0) + else if(access(argv[1], AEXIST) < 0) fprint(2, "bind: %s: %r\n", argv[1]); else fprint(2, "bind %s %s: %r\n", argv[0], argv[1]); diff --git a/sys/src/cmd/cpu.c b/sys/src/cmd/cpu.c index 7c9fd3e..6c2bf45 100644 --- a/sys/src/cmd/cpu.c +++ b/sys/src/cmd/cpu.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include <9P2000.h> #include #define Maxfdata 8192 @@ -239,7 +239,7 @@ main(int argc, char **argv) /* start up a process to pass along notes */ lclnoteproc(data); - /* + /* * Wait for the other end to execute and start our file service * of /mnt/term */ @@ -356,7 +356,7 @@ remoteside(int old) strcpy(buf, VERSION9P); if(fversion(fd, 64*1024, buf, sizeof buf) < 0) exits("fversion failed"); - if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "", 'M') < 0) + if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "", '9') < 0) exits("mount failed"); close(fd); @@ -439,7 +439,7 @@ readstr(int fd, char *str, int len) while(len) { n = read(fd, str, 1); - if(n < 0) + if(n < 0) return -1; if(*str == '\0') return 0; @@ -712,7 +712,7 @@ rmtnoteproc(void) syslog(0, "cpu", "cpu -R: can't open %s", rmtnotefile); _exits(0); } - + for(;;){ n = read(fd, buf, sizeof(buf)-1); if(n <= 0){ @@ -1029,7 +1029,7 @@ nofids: } break; case Topen: - if(f.mode != OREAD){ + if(f.mode != NP_OREAD){ f.type = Rerror; f.ename = Eperm; break; @@ -1122,7 +1122,7 @@ lclnoteproc(int netfd) return; case 0: close(pfd[0]); - if(mount(pfd[1], -1, "/dev", MBEFORE, "", 'M') < 0) + if(mount(pfd[1], -1, "/dev", MBEFORE, "", '9') < 0) fprint(2, "cpu: can't mount note proc: %r\n"); close(pfd[1]); return; diff --git a/sys/src/cmd/dd.c b/sys/src/cmd/dd.c index 15e9eb5..0fb9244 100644 --- a/sys/src/cmd/dd.c +++ b/sys/src/cmd/dd.c @@ -216,9 +216,9 @@ main(int argc, char *argv[]) } if(ofile){ if(dotrunc) - obf = create(ofile, 1, 0664); + obf = create(ofile, OWRITE, 0664); else - obf = open(ofile, 1); + obf = open(ofile, OWRITE); if(obf < 0) { fprint(2, "dd: create %s: %r\n", ofile); exits("create"); diff --git a/sys/src/cmd/disk/rofs/rofs.c b/sys/src/cmd/disk/rofs/rofs.c index c3212f3..1e5df8b 100644 --- a/sys/src/cmd/disk/rofs/rofs.c +++ b/sys/src/cmd/disk/rofs/rofs.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include @@ -32,7 +32,7 @@ struct Fid }; struct Paq -{ +{ int ref; Paq *up; PaqDir *dir; @@ -227,7 +227,7 @@ main(int argc, char *argv[]) usage(); init(argv[0], verify); - + if(!stdio){ if(pipe(pfd) < 0) sysfatal("pipe: %r"); @@ -252,7 +252,7 @@ main(int argc, char *argv[]) break; default: close(pfd[1]); /* don't deadlock if child fails */ - if(mnt && mount(pfd[0], -1, mntpoint, MREPL|MCREATE, "", 'M') < 0) + if(mnt && mount(pfd[0], -1, mntpoint, MREPL|MCREATE, "", '9') < 0) sysfatal("mount %s: %r", mntpoint); } exits(0); @@ -403,21 +403,21 @@ ropen(Fid *f) return Enotexist; mode = rhdr.mode; if(f->paq->qid.type & QTDIR){ - if(mode != OREAD) + if(mode != NP_OREAD) return Eperm; thdr.qid = f->paq->qid; return 0; } - if(mode & ORCLOSE) + if(mode & NP_ORCLOSE) return Erdonly; - trunc = mode & OTRUNC; + trunc = mode & NP_OTRUNC; mode &= OPERM; - if(mode==OWRITE || mode==ORDWR || trunc) + if(mode==NP_OWRITE || mode==NP_ORDWR || trunc) return Erdonly; - if(mode==OREAD) + if(mode==NP_OREAD) if(!perm(f->paq->dir, f->user, Pread)) return Eperm; - if(mode==OEXEC) + if(mode==NP_OEXEC) if(!perm(f->paq->dir, f->user, Pexec)) return Eperm; thdr.qid = f->paq->qid; @@ -714,7 +714,7 @@ blockLoad(uint32_t addr, int type) b->age = cacheage; b->addr = addr; b->ref = 1; - + return b; } @@ -881,7 +881,7 @@ init(char *file, int verify) sysfatal("could not open file: %s: %r", file); if(verify) ds = sha1(0, 0, 0, 0); - + readHeader(&hdr, file, ds); blocksize = hdr.blocksize; @@ -991,7 +991,7 @@ void readHeader(PaqHeader *hdr, char *name, DigestState *ds) { uint8_t buf[HeaderSize]; - + if(Bread(bin, buf, HeaderSize) < HeaderSize) sysfatal("could not read header: %s: %r", name); if(ds) @@ -1105,7 +1105,7 @@ gets(uint8_t *p) int checkDirSize(uint8_t *p, uint8_t *ep) { - int n; + int n; int i; if(ep-p < 2) diff --git a/sys/src/cmd/dossrv/dosfs.c b/sys/src/cmd/dossrv/dosfs.c index 897473c..99f025b 100644 --- a/sys/src/cmd/dossrv/dosfs.c +++ b/sys/src/cmd/dossrv/dosfs.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "iotrack.h" #include "dat.h" #include "dosfs.h" @@ -204,7 +204,7 @@ ropen(void) } dp = f->ptr; omode = 0; - if(!isroot(dp->paddr) && (req->mode & ORCLOSE)){ + if(!isroot(dp->paddr) && (req->mode & NP_ORCLOSE)){ /* * check on parent directory of file to be deleted */ @@ -220,7 +220,7 @@ ropen(void) return; } omode |= Orclose; - }else if(req->mode & ORCLOSE) + }else if(req->mode & NP_ORCLOSE) omode |= Orclose; if(getfile(f) < 0){ errno = Enonexist; @@ -231,14 +231,14 @@ ropen(void) else attr = DDIR; switch(req->mode & 7){ - case OREAD: - case OEXEC: + case NP_OREAD: + case NP_OEXEC: omode |= Oread; break; - case ORDWR: + case NP_ORDWR: omode |= Oread; /* fall through */ - case OWRITE: + case NP_OWRITE: omode |= Owrite; if(attr & DRONLY){ errno = Eperm; @@ -249,7 +249,7 @@ ropen(void) errno = Eio; goto out; } - if(req->mode & OTRUNC){ + if(req->mode & NP_OTRUNC){ if(attr & DDIR || attr & DRONLY){ errno = Eperm; goto out; @@ -383,17 +383,17 @@ badperm: return; } omode = 0; - if(req->mode & ORCLOSE) + if(req->mode & NP_ORCLOSE) omode |= Orclose; switch(req->mode & 7){ - case OREAD: - case OEXEC: + case NP_OREAD: + case NP_OEXEC: omode |= Oread; break; - case ORDWR: + case NP_ORDWR: omode |= Oread; /* fall through */ - case OWRITE: + case NP_OWRITE: omode |= Owrite; if(req->perm & DMDIR) goto badperm; @@ -586,7 +586,7 @@ doremove(Xfs *xf, Dosptr *dp) p->flags |= BMOD; } putsect(p); - } + } } void diff --git a/sys/src/cmd/dossrv/dossubs.c b/sys/src/cmd/dossrv/dossubs.c index 674a13f..5cb18d4 100644 --- a/sys/src/cmd/dossrv/dossubs.c +++ b/sys/src/cmd/dossrv/dossubs.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include <9P2000.h> #include "iotrack.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/dossrv/xfssrv.c b/sys/src/cmd/dossrv/xfssrv.c index 3beb43e..45fde05 100644 --- a/sys/src/cmd/dossrv/xfssrv.c +++ b/sys/src/cmd/dossrv/xfssrv.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "iotrack.h" #include "dat.h" #include "dosfs.h" diff --git a/sys/src/cmd/ed.c b/sys/src/cmd/ed.c index 9aa6b1f..11dd266 100644 --- a/sys/src/cmd/ed.c +++ b/sys/src/cmd/ed.c @@ -1593,7 +1593,7 @@ mktemp(char *as) } s++; i = 'a'; - while(access(as, 0) != -1) { + while(access(as, AEXIST) != -1) { if(i == 'z') return "/"; *s = i++; diff --git a/sys/src/cmd/exportfs/exportfs.c b/sys/src/cmd/exportfs/exportfs.c index 88d8343..034cb51 100644 --- a/sys/src/cmd/exportfs/exportfs.c +++ b/sys/src/cmd/exportfs/exportfs.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "exportfs.h" diff --git a/sys/src/cmd/exportfs/exportsrv.c b/sys/src/cmd/exportfs/exportsrv.c index 6cb57c3..fe8a878 100644 --- a/sys/src/cmd/exportfs/exportsrv.c +++ b/sys/src/cmd/exportfs/exportsrv.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "exportfs.h" extern char *netdir, *local, *remote; @@ -192,7 +192,7 @@ Xwalk(Fsrpc *t) wf->ref++; goto Accept; } - + wf = file(f->f, t->work.wname[i]); if(wf == 0){ errstr(err, sizeof err); @@ -308,7 +308,7 @@ Xcreate(Fsrpc *t) t->busy = 0; return; } - + path = makepath(f->f, t->work.name); f->fid = create(path, t->work.mode, t->work.perm); @@ -469,7 +469,7 @@ slave(Fsrpc *f) f->busy = 0; return; case Topen: - if((f->work.mode&3) == OWRITE || (f->work.mode&OTRUNC)){ + if((f->work.mode&3) == NP_OWRITE || (f->work.mode&NP_OTRUNC)){ reply(&f->work, &rhdr, Ereadonly); f->busy = 0; return; @@ -485,7 +485,7 @@ slave(Fsrpc *f) if(pid != p->pid) fatal("rendezvous sync fail"); return; - } + } } if(++nproc > MAXPROC) @@ -499,7 +499,7 @@ slave(Fsrpc *f) case 0: if (local[0] != '\0') if (netdir[0] != '\0') - procsetname("%s: %s -> %s", netdir, + procsetname("%s: %s -> %s", netdir, local, remote); else procsetname("%s -> %s", local, remote); @@ -534,7 +534,7 @@ blockingslave(void) pid = getpid(); m = rendezvous((void*)pid, 0); - + for(;;) { p = rendezvous((void*)pid, (void*)pid); if(p == (void*)~0) /* Interrupted */ @@ -607,7 +607,7 @@ openmount(int sfd) dup(p[0], 0); dup(p[0], 1); exec("/cmd/exportfs", arg); - _exits("whoops: exec failed"); + _exits("whoops: exec failed"); return -1; } @@ -630,7 +630,7 @@ slaveopen(Fsrpc *p) close(f->fid); f->fid = -1; } - + path = makepath(f->f, ""); DEBUG(DFD, "\topen: %s %d\n", path, work->mode); diff --git a/sys/src/cmd/exportfs/pattern.c b/sys/src/cmd/exportfs/pattern.c index 3b9e5df..a227cd6 100644 --- a/sys/src/cmd/exportfs/pattern.c +++ b/sys/src/cmd/exportfs/pattern.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> #include #include #include "exportfs.h" diff --git a/sys/src/cmd/hjfs/9p.c b/sys/src/cmd/hjfs/9p.c index 53a852f..ad65771 100644 --- a/sys/src/cmd/hjfs/9p.c +++ b/sys/src/cmd/hjfs/9p.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/hjfs/auth.c b/sys/src/cmd/hjfs/auth.c index 4e4ae5a..a011f92 100644 --- a/sys/src/cmd/hjfs/auth.c +++ b/sys/src/cmd/hjfs/auth.c @@ -1,5 +1,6 @@ #include #include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -54,7 +55,7 @@ usersparseline(char *l, PUser **u, int *nu) PUser v; char *f[5], *r, *s; int c; - + if(*l == 0 || *l == '#') return; c = getfields(l, f, 5, 0, ":"); @@ -106,7 +107,7 @@ static int uidcomp(const void *a, const void *b) { const short *aa, *bb; - + aa = a; bb = b; return *aa - *bb; @@ -116,7 +117,7 @@ static int usercomp(const void *a, const void *b) { const User *aa, *bb; - + aa = a; bb = b; return aa->uid - bb->uid; @@ -129,7 +130,7 @@ usersload(Fs *fs, Chan *ch) int bufl, i, j, rc, nu; PUser *u; User *v; - + buf = nil; bufl = 0; u = nil; @@ -191,7 +192,7 @@ userssave(Fs *fs, Chan *ch) int nu, i; char buf[512], ubuf[USERLEN], *p, *e; uint64_t off; - + rlock(&fs->udatal); u = fs->udata; if(u == nil){ @@ -305,16 +306,14 @@ permcheck(Fs *fs, Dentry *d, short uid, int mode) perm >>= 6; else if(ingroup(fs, uid, d->gid, 0)) perm >>= 3; - switch(mode & 7){ - case OSTAT: - return 1; - case OREAD: + switch(mode & 3){ + case NP_OREAD: return (perm & 4) != 0; - case OWRITE: + case NP_OWRITE: return (perm & 2) != 0; - case OEXEC: + case NP_OEXEC: return (perm & 1) != 0; - case ORDWR: + case NP_ORDWR: return (perm & 6) == 6; } return 0; @@ -324,7 +323,7 @@ char * uid2name(Fs *fs, short uid, char *buf) { User *u; - + rlock(&fs->udatal); u = lookupuid(fs, uid); if(buf == nil) @@ -374,7 +373,7 @@ createuserdir(Fs *fs, char *name, short uid) return; ch->uid = uid; if(chanwalk(ch, "usr") > 0) - chancreat(ch, name, DMDIR | 0775, OREAD); + chancreat(ch, name, DMDIR | 0775, NP_OREAD); chanclunk(ch); } diff --git a/sys/src/cmd/hjfs/cons.c b/sys/src/cmd/hjfs/cons.c index d822e4d..f628612 100644 --- a/sys/src/cmd/hjfs/cons.c +++ b/sys/src/cmd/hjfs/cons.c @@ -1,6 +1,7 @@ #include #include #include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -156,7 +157,7 @@ cmdcreate(int argc, char **argv) chanclunk(ch); return -1; } - if(chancreat(ch, n, perm, OREAD) < 0){ + if(chancreat(ch, n, perm, NP_OREAD) < 0){ chanclunk(ch); return -1; } diff --git a/sys/src/cmd/hjfs/dump.c b/sys/src/cmd/hjfs/dump.c index a5d0ecc..9401050 100644 --- a/sys/src/cmd/hjfs/dump.c +++ b/sys/src/cmd/hjfs/dump.c @@ -1,6 +1,7 @@ #include #include #include +#include <9P2000.h> #include "dat.h" #include "fns.h" @@ -79,7 +80,7 @@ fsdump(Fs *fs) } if(chanwalk(ch, buf) < 0){ chh = chanclone(ch); - rc = chancreat(chh, buf, DMDIR|0555, OREAD); + rc = chancreat(chh, buf, DMDIR|0555, NP_OREAD); chanclunk(chh); if(rc < 0) goto err; diff --git a/sys/src/cmd/hjfs/fs1.c b/sys/src/cmd/hjfs/fs1.c index 0bdf9b2..04b7d46 100644 --- a/sys/src/cmd/hjfs/fs1.c +++ b/sys/src/cmd/hjfs/fs1.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" @@ -184,12 +184,12 @@ void writeusers(Fs *fs) { Chan *ch; - + ch = chanattach(fs, 0); if(ch == nil) goto error; ch->uid = -1; - chancreat(ch, "cfg", DMDIR | 0775, OREAD); + chancreat(ch, "cfg", DMDIR | 0775, NP_OREAD); chanclunk(ch); ch = chanattach(fs, 0); if(ch == nil) @@ -198,9 +198,9 @@ writeusers(Fs *fs) if(chanwalk(ch, "cfg") <= 0) goto error; if(chanwalk(ch, "users") > 0){ - if(chanopen(ch, OWRITE|OTRUNC) <= 0) + if(chanopen(ch, NP_OWRITE|NP_OTRUNC) <= 0) goto error; - }else if(chancreat(ch, "users", 0664, OWRITE) <= 0) + }else if(chancreat(ch, "users", 0664, NP_OWRITE) <= 0) goto error; if(userssave(fs, ch) < 0){ chanremove(ch); @@ -219,7 +219,7 @@ void readusers(Fs *fs) { Chan *ch; - + ch = chanattach(fs, 0); if(ch == nil) goto err; @@ -228,7 +228,7 @@ readusers(Fs *fs) goto err; if(chanwalk(ch, "users") <= 0) goto err; - if(chanopen(ch, OREAD) < 0) + if(chanopen(ch, NP_OREAD) < 0) goto err; if(usersload(fs, ch) < 0) goto err; @@ -247,7 +247,7 @@ ream(Fs *fs) Buf *b, *c; uint64_t i, firsti, lasti; int j, je; - + d = fs->d; dprint("hjfs: reaming %s\n", d->name); b = getbuf(d, SUPERBLK, TSUPERBLOCK, 1); @@ -300,7 +300,7 @@ initfs(Dev *d, int doream, int flags) Fs *fs; Buf *b; FLoc f; - + fs = emalloc(sizeof(*fs)); fs->d = d; if(doream) @@ -353,7 +353,7 @@ int newqid(Fs *fs, uint64_t *q) { Buf *b; - + b = getbuf(fs->d, SUPERBLK, TSUPERBLOCK, 0); if(b == nil) return -1; @@ -367,7 +367,7 @@ Loc * getloc(Fs *fs, FLoc f, Loc *next) { Loc *l; - + qlock(&fs->loctree); if(next != nil && next->child != nil){ l = next->child; @@ -818,7 +818,7 @@ findentry(Fs *fs, FLoc *l, Buf *b, char *name, FLoc *rl, int dump) Dentry *d; uint64_t r; Buf *c; - + d = getdent(l, b); if(d == nil) return -1; @@ -844,7 +844,7 @@ findentry(Fs *fs, FLoc *l, Buf *b, char *name, FLoc *rl, int dump) putbuf(c); } werrstr(Enoent); - return 0; + return 0; } void @@ -872,7 +872,7 @@ deltraverse(Fs *fs, Del *p, Buf *b, Del **last) uint64_t i, s, r; int j, rc; Del *dd; - + frb = b == nil; if(frb){ b = getbuf(fs->d, p->blk, TDENTRY, 0); diff --git a/sys/src/cmd/hjfs/fs2.c b/sys/src/cmd/hjfs/fs2.c index 342999b..dd4cfb3 100644 --- a/sys/src/cmd/hjfs/fs2.c +++ b/sys/src/cmd/hjfs/fs2.c @@ -1,13 +1,13 @@ #include #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" Chan * chanattach(Fs *fs, int flags) -{ +{ Chan *ch; ch = emalloc(sizeof(*ch)); @@ -39,7 +39,7 @@ chanwalk(Chan *ch, char *name) Dentry *d; Loc *l; FLoc f; - + if(name == nil || name[0] == 0 || name[0] == '.' && name[1] == 0) return 1; chbegin(ch); @@ -89,7 +89,7 @@ int namevalid(char *name) { char *p; - + if(name == nil || name[0] == 0) return 0; if(name[0] == '.' && (name[1] == 0 || name[1] == '.' && name[2] == 0)) @@ -120,7 +120,7 @@ chancreat(Chan *ch, char *name, int perm, int mode) if(willmodify(ch->fs, ch->loc, ch->flags & CHFNOLOCK) < 0) goto error; if(isdir = ((perm & DMDIR) != 0)) - if((mode & (OWRITE | OEXEC | ORCLOSE | OTRUNC)) != 0) + if((mode & (NP_OWRITE | NP_OEXEC | NP_ORCLOSE | NP_OTRUNC)) != 0) goto inval; b = getbuf(ch->fs->d, ch->loc->blk, TDENTRY, 0); if(b == nil) @@ -133,7 +133,7 @@ chancreat(Chan *ch, char *name, int perm, int mode) goto error; } if((ch->flags & CHFNOPERM) == 0){ - if(!permcheck(ch->fs, d, ch->uid, OWRITE)){ + if(!permcheck(ch->fs, d, ch->uid, NP_OWRITE)){ werrstr(Eperm); goto error; } @@ -175,18 +175,18 @@ chancreat(Chan *ch, char *name, int perm, int mode) } b->op |= BDELWRI; putbuf(b); - switch(mode & OEXEC){ - case ORDWR: + switch(mode & NP_OEXEC){ + case NP_ORDWR: ch->open |= CHREAD; - case OWRITE: + case NP_OWRITE: ch->open |= CHWRITE; break; - case OEXEC: - case OREAD: + case NP_OEXEC: + case NP_OREAD: ch->open |= CHREAD; break; } - if((mode & ORCLOSE) != 0) + if((mode & NP_ORCLOSE) != 0) ch->open |= CHRCLOSE; chend(ch); return 1; @@ -211,12 +211,12 @@ chanopen(Chan *ch, int mode) chbegin(ch); if(ch->open != 0) goto inval; - if((ch->flags & CHFRO) != 0 && (mode & (ORCLOSE | OTRUNC | OWRITE | ORDWR)) != 0) + if((ch->flags & CHFRO) != 0 && (mode & (NP_ORCLOSE | NP_OTRUNC | NP_OWRITE | NP_ORDWR)) != 0) goto inval; - if((mode & OTRUNC) != 0) + if((mode & NP_OTRUNC) != 0) if(willmodify(ch->fs, ch->loc, ch->flags & CHFNOLOCK) < 0) goto error; - if((mode & ORCLOSE) != 0){ + if((mode & NP_ORCLOSE) != 0){ if(ch->loc->next == nil) goto inval; b = getbuf(ch->fs->d, ch->loc->next->blk, TDENTRY, 0); @@ -226,7 +226,7 @@ chanopen(Chan *ch, int mode) if(d == nil) goto error; if((ch->flags & CHFNOPERM) == 0) - if(!permcheck(ch->fs, d, ch->uid, OWRITE)) + if(!permcheck(ch->fs, d, ch->uid, NP_OWRITE)) goto perm; putbuf(b); } @@ -237,13 +237,13 @@ chanopen(Chan *ch, int mode) if(d == nil) goto error; if((d->type & QTAPPEND) != 0) - mode &= ~OTRUNC; - if((d->type & QTDIR) != 0 && (mode & (ORCLOSE | OTRUNC | OWRITE | ORDWR)) != 0) + mode &= ~NP_OTRUNC; + if((d->type & QTDIR) != 0 && (mode & (NP_ORCLOSE | NP_OTRUNC | NP_OWRITE | NP_ORDWR)) != 0) goto inval; if((ch->flags & CHFNOPERM) == 0){ - if(!permcheck(ch->fs, d, ch->uid, mode & OEXEC)) + if(!permcheck(ch->fs, d, ch->uid, mode & NP_OEXEC)) goto perm; - if((mode & OTRUNC) != 0 && !permcheck(ch->fs, d, ch->uid, OWRITE)) + if((mode & NP_OTRUNC) != 0 && !permcheck(ch->fs, d, ch->uid, NP_OWRITE)) goto perm; } if((ch->loc->type & QTEXCL) != 0){ @@ -258,23 +258,23 @@ chanopen(Chan *ch, int mode) goto error; } } - switch(mode & OEXEC){ - case ORDWR: + switch(mode & NP_OEXEC){ + case NP_ORDWR: ch->open |= CHREAD; - case OWRITE: + case NP_OWRITE: ch->open |= CHWRITE; break; - case OEXEC: - case OREAD: + case NP_OEXEC: + case NP_OREAD: ch->open |= CHREAD; break; } - if((mode & OTRUNC) != 0){ + if((mode & NP_OTRUNC) != 0){ trunc(ch->fs, ch->loc, b, 0); modified(ch, d); b->op |= BDELWRI; } - if((mode & ORCLOSE) != 0) + if((mode & NP_ORCLOSE) != 0) ch->open |= CHRCLOSE; putbuf(b); chend(ch); @@ -492,7 +492,7 @@ chanstat(Chan *ch, Dir *di) { Buf *b; Dentry *d; - + chbegin(ch); b = getbuf(ch->fs->d, ch->loc->blk, TDENTRY, 0); if(b == nil){ @@ -627,7 +627,7 @@ chanclunk(Chan *ch) if(d == nil) goto error; if((ch->flags & CHFNOPERM) == 0) - if(!permcheck(ch->fs, d, ch->uid, OWRITE)){ + if(!permcheck(ch->fs, d, ch->uid, NP_OWRITE)){ werrstr(Eperm); goto error; } @@ -703,7 +703,7 @@ chanwstat(Chan *ch, Dir *di) goto error; else if(rc == 0){ if((ch->flags & CHFNOPERM) == 0) - if(!permcheck(ch->fs, d, ch->uid, OWRITE)) + if(!permcheck(ch->fs, d, ch->uid, NP_OWRITE)) goto perm; } else if(f.blk != ch->loc->blk || f.deind != ch->loc->deind){ werrstr(Eexists); @@ -725,7 +725,7 @@ chanwstat(Chan *ch, Dir *di) if(isdir && di->length != 0) goto inval; if((ch->flags & CHFNOPERM) == 0) - if(di->length != d->size && !permcheck(ch->fs, d, ch->uid, OWRITE)) + if(di->length != d->size && !permcheck(ch->fs, d, ch->uid, NP_OWRITE)) goto perm; } if(di->mtime != ~0 && !owner) diff --git a/sys/src/cmd/hmi/console/cga.c b/sys/src/cmd/hmi/console/cga.c index 51cf92a..a7f8343 100644 --- a/sys/src/cmd/hmi/console/cga.c +++ b/sys/src/cmd/hmi/console/cga.c @@ -133,8 +133,8 @@ writecga(int conswrites, int device) debug("writecga %d: shut down (r = %d, w = %d)\n", pid, r, w); if(r < 0) - exits("read"); + exits("writecga: read"); if(w < 0) - exits("write"); + exits("writecga: write"); exits(nil); } diff --git a/sys/src/cmd/hmi/console/comconsole.c b/sys/src/cmd/hmi/console/comconsole.c index 69ef54d..4e89da1 100644 --- a/sys/src/cmd/hmi/console/comconsole.c +++ b/sys/src/cmd/hmi/console/comconsole.c @@ -71,6 +71,7 @@ main(int argc, char *argv[]) fd = servecons(passthrough, passthrough, &devmnt); if(srv){ + debug("%s (%d): posting %d\n", argv0, getpid(), fd); post(srv, fd); exits(0); } else { diff --git a/sys/src/cmd/hmi/console/passthrough.c b/sys/src/cmd/hmi/console/passthrough.c index 61eaca5..6c3dbd9 100644 --- a/sys/src/cmd/hmi/console/passthrough.c +++ b/sys/src/cmd/hmi/console/passthrough.c @@ -54,10 +54,10 @@ passthrough(int input, int output) debug("%s (%d) shut down (r = %d, w = %d)\n", name, pid, r, w); if(r < 0) - exits("read"); + exits("passthrough: read"); if(w < 0) - exits("write"); + exits("passthrough: write"); if(w < r) - exits("i/o error"); + exits("passthrough: i/o error"); exits(nil); } diff --git a/sys/src/cmd/hmi/console/serve9p.c b/sys/src/cmd/hmi/console/serve9p.c index c6e701d..f18e589 100644 --- a/sys/src/cmd/hmi/console/serve9p.c +++ b/sys/src/cmd/hmi/console/serve9p.c @@ -17,7 +17,7 @@ */ #include #include -#include +#include <9P2000.h> #include "console.h" @@ -703,11 +703,19 @@ rwalk(Fcall *req, Fcall *rep) static int ropen(Fcall *req, Fcall *rep) { - static int need[4] = { 4, 2, 6, 1 }; + static int need[4] = { + 4, /* NP_OREAD */ + 2, /* NP_OWRITE */ + 6, /* NP_ORDWR */ + 1 /* NP_OEXEC */ + }; struct Qtab *t; Fid *f; int n; + if(req->mode&NP_OZEROES) + return rerror(rep, "invalid 9P2000 open mode"); + f = findFid(req->fid); if(f == nil) return rerror(rep, "bad fid"); @@ -742,11 +750,11 @@ ropen(Fcall *req, Fcall *rep) } break; case Qcons: - if(ISCLOSED(inputfid) && (req->mode & OREAD) == OREAD) + if(ISCLOSED(inputfid) && (req->mode & NP_OREAD) == NP_OREAD) return rerror(rep, "input device closed"); - if(ISCLOSED(outputfid) && (req->mode & OWRITE) == OWRITE) + if(ISCLOSED(outputfid) && (req->mode & NP_OWRITE) == NP_OWRITE) return rerror(rep, "output device closed"); - if((req->mode & OWRITE) == OWRITE) + if((req->mode & NP_OWRITE) == NP_OWRITE) rep->iounit = ScreenBufferSize; break; default: @@ -816,7 +824,7 @@ rwrite(Fcall *req, Fcall *rep) f = findFid(req->fid); if(f == nil) return rerror(rep, "bad fid"); - if(ISCLOSED(f) || (f->opened & OWRITE) != OWRITE) + if(ISCLOSED(f) || (f->opened & NP_OWRITE) != NP_OWRITE) return rerror(rep, "i/o error"); switch(f->qid.path){ @@ -972,7 +980,7 @@ fsinit(int *mnt, int *mntdev) pipe(tmp); *mnt = tmp[0]; - *mntdev = 'M'; + *mntdev = '9'; return tmp[1]; } diff --git a/sys/src/cmd/hmi/console/utils.c b/sys/src/cmd/hmi/console/utils.c index 4845111..dd5b2ea 100644 --- a/sys/src/cmd/hmi/console/utils.c +++ b/sys/src/cmd/hmi/console/utils.c @@ -17,7 +17,7 @@ */ #include #include -#include +#include <9P2000.h> #include "console.h" @@ -124,15 +124,15 @@ servecons(StreamFilter inputFilter, StreamFilter outputFilter, int *devmnt) pid = getpid(); - if(!debugging) - close(2); - rfork(RFNAMEG); debug("%s %d: started, linecontrol = %d, blind = %d\n", argv0, pid, linecontrol, blind); fs = fsinit(&mnt, devmnt); + if(!debugging) + close(2); + /* start the file system */ switch(rfork(RFPROC|RFMEM|RFNOWAIT|RFCENVG|RFNOTEG|RFCNAMEG|RFFDG)){ case -1: diff --git a/sys/src/cmd/hmi/realemu/main.c b/sys/src/cmd/hmi/realemu/main.c index 91ecab8..931dce3 100644 --- a/sys/src/cmd/hmi/realemu/main.c +++ b/sys/src/cmd/hmi/realemu/main.c @@ -5,7 +5,7 @@ /* for fs */ #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/cmd/import.c b/sys/src/cmd/import.c index 42ea128..0cfbfc2 100644 --- a/sys/src/cmd/import.c +++ b/sys/src/cmd/import.c @@ -243,7 +243,7 @@ main(int argc, char **argv) post(srvfile, srvpost, fd); } procsetname("mount on %s", mntpt); - if(mount(fd, -1, mntpt, mntflags, "", 'M') < 0) + if(mount(fd, -1, mntpt, mntflags, "", '9') < 0) sysfatal("can't mount %s: %r", argv[1]); alarm(0); diff --git a/sys/src/cmd/ip/dhcpd/dhcpd.c b/sys/src/cmd/ip/dhcpd/dhcpd.c index 5bc72c1..a2e1312 100644 --- a/sys/src/cmd/ip/dhcpd/dhcpd.c +++ b/sys/src/cmd/ip/dhcpd/dhcpd.c @@ -951,7 +951,7 @@ bootp(Req *rp) } /* ignore if the file is unreadable */ - if((!rp->genrequest) && bp->file[0] && access(bp->file, 4) < 0){ + if((!rp->genrequest) && bp->file[0] && access(bp->file, AREAD) < 0){ warning(0, "inaccessible bootfile1 %s", bp->file); return; } diff --git a/sys/src/cmd/ip/gping.c b/sys/src/cmd/ip/gping.c index 99e70ba..8bdfd98 100644 --- a/sys/src/cmd/ip/gping.c +++ b/sys/src/cmd/ip/gping.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include diff --git a/sys/src/cmd/ip/ipconfig/main.c b/sys/src/cmd/ip/ipconfig/main.c index f6726e1..cf80d6e 100644 --- a/sys/src/cmd/ip/ipconfig/main.c +++ b/sys/src/cmd/ip/ipconfig/main.c @@ -759,7 +759,7 @@ lookforip(char *net) char proto[64]; snprint(proto, sizeof proto, "%s/ipifc", net); - if(access(proto, 0) == 0) + if(access(proto, AEXIST) == 0) return; sysfatal("no ip stack bound onto %s", net); } diff --git a/sys/src/cmd/ip/timesync.c b/sys/src/cmd/ip/timesync.c index 359e77b..86d1509 100644 --- a/sys/src/cmd/ip/timesync.c +++ b/sys/src/cmd/ip/timesync.c @@ -606,9 +606,9 @@ inittime(void) mode = ORDWR; /* bind in clocks */ - if(access("/dev/time", 0) < 0) + if(access("/dev/time", AEXIST) < 0) bind("#c", "/dev", MAFTER); - if(access("/dev/rtc", 0) < 0) + if(access("/dev/rtc", AEXIST) < 0) bind("#r", "/dev", MAFTER); /* figure out what interface we have */ @@ -1374,7 +1374,7 @@ background(void) if(inbackground) return; - if(!debug) + if(!debug) switch(rfork(RFPROC|RFFDG|RFNAMEG|RFNOTEG|RFNOWAIT)){ case -1: sysfatal("forking: %r"); diff --git a/sys/src/cmd/ip/trampoline.c b/sys/src/cmd/ip/trampoline.c index f5646d3..f9e3dda 100644 --- a/sys/src/cmd/ip/trampoline.c +++ b/sys/src/cmd/ip/trampoline.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include <9P2000.h> enum { diff --git a/sys/src/cmd/ls.c b/sys/src/cmd/ls.c index d111ef2..684cd55 100644 --- a/sys/src/cmd/ls.c +++ b/sys/src/cmd/ls.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> typedef struct NDir NDir; struct NDir diff --git a/sys/src/cmd/mntgen.c b/sys/src/cmd/mntgen.c index cd728ec..22de58e 100644 --- a/sys/src/cmd/mntgen.c +++ b/sys/src/cmd/mntgen.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> #include @@ -59,7 +59,7 @@ hash(char *name) static void fsopen(Req *r) { - if(r->ifcall.mode != OREAD) + if(r->ifcall.mode != NP_OREAD) respond(r, "permission denied"); else respond(r, nil); @@ -210,7 +210,7 @@ fsattach(Req *r) respond(r, "invalid attach specifier"); return; } - + r->ofcall.qid = (Qid){0, 0, QTDIR}; r->fid->qid = r->ofcall.qid; respond(r, nil); diff --git a/sys/src/cmd/ndb/cs.c b/sys/src/cmd/ndb/cs.c index 2aa93a7..dd8bdec 100644 --- a/sys/src/cmd/ndb/cs.c +++ b/sys/src/cmd/ndb/cs.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include @@ -327,7 +327,7 @@ mountinit(char *service, char *mntpt) * put ourselves into the file system */ close(p[0]); - if(mount(p[1], -1, mntpt, MAFTER, "", 'M') < 0) + if(mount(p[1], -1, mntpt, MAFTER, "", '9') < 0) error("mount failed\n"); _exits(0); } diff --git a/sys/src/cmd/ndb/dns.c b/sys/src/cmd/ndb/dns.c index 7427235..ce47c71 100644 --- a/sys/src/cmd/ndb/dns.c +++ b/sys/src/cmd/ndb/dns.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include "dns.h" @@ -287,7 +287,7 @@ mountinit(char *service, char *mntpt) /* * put ourselves into the file system */ - if(mount(p[1], -1, mntpt, MAFTER, "", 'M') < 0) + if(mount(p[1], -1, mntpt, MAFTER, "", '9') < 0) fprint(2, "dns mount failed: %r\n"); _exits(0); } diff --git a/sys/src/cmd/ndb/dnsquery.c b/sys/src/cmd/ndb/dnsquery.c index eba615c..1e8fa21 100644 --- a/sys/src/cmd/ndb/dnsquery.c +++ b/sys/src/cmd/ndb/dnsquery.c @@ -26,7 +26,7 @@ setup(int argc, char **argv) fd = open(srv, ORDWR); if(fd < 0) sysfatal("can't open %s: %r", srv); - if(mount(fd, -1, mtpt, MBEFORE, "", 'M') < 0) + if(mount(fd, -1, mtpt, MBEFORE, "", '9') < 0) sysfatal("can't mount(%s, %s): %r", srv, mtpt); fd = open(dns, ORDWR); if(fd < 0) diff --git a/sys/src/cmd/ns.c b/sys/src/cmd/ns.c index bc00fc1..337fa5e 100644 --- a/sys/src/cmd/ns.c +++ b/sys/src/cmd/ns.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include <9P2000.h> #pragma varargck type "P" char* diff --git a/sys/src/cmd/ramfs.c b/sys/src/cmd/ramfs.c index 18ad2e2..460d7ba 100644 --- a/sys/src/cmd/ramfs.c +++ b/sys/src/cmd/ramfs.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> /* * Rather than reading /adm/users, which is a lot of work for @@ -248,7 +248,7 @@ main(int argc, char *argv[]) break; default: close(p[0]); /* don't deadlock if child fails */ - if(defmnt && mount(p[1], -1, defmnt, MREPL|MCREATE, "", 'M') < 0) + if(defmnt && mount(p[1], -1, defmnt, MREPL|MCREATE, "", '9') < 0) error("mount failed"); } exits(0); @@ -406,26 +406,26 @@ ropen(Fid *f) return Excl; mode = thdr.mode; if(r->qid.type & QTDIR){ - if(mode != OREAD) + if(mode != NP_OREAD) return Eperm; rhdr.qid = r->qid; return 0; } - if(mode & ORCLOSE){ + if(mode & NP_ORCLOSE){ /* can't remove root; must be able to write parent */ if(r->qid.path==0 || !perm(f, &ram[r->parent], Pwrite)) return Eperm; f->rclose = 1; } - trunc = mode & OTRUNC; + trunc = mode & NP_OTRUNC; mode &= OPERM; - if(mode==OWRITE || mode==ORDWR || trunc) + if(mode==NP_OWRITE || mode==NP_ORDWR || trunc) if(!perm(f, r, Pwrite)) return Eperm; - if(mode==OREAD || mode==ORDWR) + if(mode==NP_OREAD || mode==NP_ORDWR) if(!perm(f, r, Pread)) return Eperm; - if(mode==OEXEC) + if(mode==NP_OEXEC) if(!perm(f, r, Pexec)) return Eperm; if(trunc && (r->perm&DMAPPEND)==0){ diff --git a/sys/src/cmd/rc/exec.c b/sys/src/cmd/rc/exec.c index 2731bad..756f5f7 100644 --- a/sys/src/cmd/rc/exec.c +++ b/sys/src/cmd/rc/exec.c @@ -153,7 +153,7 @@ main(int argc, char *argv[]) if(flag['I']) flag['i'] = 0; else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset; - rcmain = flag['m']?flag['m'][0]:Rcmain; + rcmain = flag['m']?flag['m'][0]:Rcmain; err = openfd(2); kinit(); Trapinit(); @@ -268,7 +268,7 @@ Xappend(void) break; } file = runq->argv->words->word; - if((f = open(file, 1))<0 && (f = Creat(file))<0){ + if((f = open(file, OWRITE))<0 && (f = Creat(file))<0){ pfmt(err, "%s: ", file); Xerror("can't open"); return; @@ -702,7 +702,7 @@ word* copynwords(word *a, word *tail, int n) { word *v, **end; - + v = 0; end = &v; while(n-- > 0){ diff --git a/sys/src/cmd/rc/glob.c b/sys/src/cmd/rc/glob.c index c12a0a9..e27754f 100644 --- a/sys/src/cmd/rc/glob.c +++ b/sys/src/cmd/rc/glob.c @@ -76,7 +76,7 @@ globdir(uint8_t *p, uint8_t *namep) /* If we ran out of pattern, append the name if accessible */ if(*newp=='\0'){ *t='\0'; - if(access(globname, 0)==0) + if(access(globname, AEXIST)==0) globv = newword(globname, globv); return; } @@ -130,7 +130,7 @@ equtf(uint8_t *p, uint8_t *q) Rune pr, qr; if(*p!=*q) return 0; - + chartorune(&pr, (char*)p); chartorune(&qr, (char*)q); return pr == qr; diff --git a/sys/src/cmd/rc/io.c b/sys/src/cmd/rc/io.c index 4e104b8..fc1beec 100644 --- a/sys/src/cmd/rc/io.c +++ b/sys/src/cmd/rc/io.c @@ -267,7 +267,7 @@ opencore(char *s, int len) io *f = new(struct io); uint8_t *buf = emalloc(len); - f->fd = -1 /*open("/dev/null", 0)*/; + f->fd = -1 /*open("/dev/null", OREAD)*/; f->bufp = f->strp = buf; f->ebuf = buf+len; Memcpy(buf, s, len); diff --git a/sys/src/cmd/rc/plan9.c b/sys/src/cmd/rc/plan9.c index cd29d0f..291b4be 100644 --- a/sys/src/cmd/rc/plan9.c +++ b/sys/src/cmd/rc/plan9.c @@ -320,7 +320,7 @@ ForkExecute(char *file, char **argv, int sin, int sout, int serr) { int pid; - if(access(file, 1) != 0) + if(access(file, AEXEC) != 0) return -1; switch(pid = fork()){ case -1: @@ -447,7 +447,7 @@ trimdirs(Dir *d, int nd) * onlydirs is advisory -- it means you only * need to return the directories. it's okay to * return files too (e.g., on unix where you can't - * tell during the readdir), but that just makes + * tell during the readdir), but that just makes * the globber work harder. */ int @@ -467,7 +467,7 @@ Again: n = trimdirs(dir[f].dbuf, n); if(n == 0) goto Again; - } + } dir[f].n = n; }else dir[f].n = 0; @@ -562,7 +562,7 @@ Executable(char *file) int Creat(char *file) { - return create(file, 1, 0666L); + return create(file, OWRITE, 0666L); } int @@ -649,7 +649,7 @@ void delwaitpid(int pid) { int r, w; - + for(r=w=0; rargv->words->next->word)); break; - case 1: + case 1: umask(m = umask(0)); out->fd = mapfd(1); out->bufp = out->buf; @@ -576,7 +576,7 @@ void delwaitpid(int pid) { int r, w; - + for(r=w=0; r #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c index 4ef5bbf..69cc381 100644 --- a/sys/src/cmd/rio/fsys.c +++ b/sys/src/cmd/rio/fsys.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" @@ -237,7 +237,7 @@ filsysmount(Filsys *fs, int id) close(fs->sfd); /* close server end so mount won't hang if exiting */ sprint(buf, "%d", id); - if(mount(fs->cfd, -1, "/mnt/wsys", MREPL, buf, 'M') < 0){ + if(mount(fs->cfd, -1, "/mnt/wsys", MREPL, buf, '9') < 0){ fprint(2, "mount failed: %r\n"); return -1; } @@ -497,26 +497,26 @@ filsysopen(Filsys *fs, Xfid *x, Fid *f) int m; /* can't truncate anything, so just disregard */ - x->mode &= ~(OTRUNC|OCEXEC); + x->mode &= ~(NP_OTRUNC); /* can't execute or remove anything */ - if(x->mode==OEXEC || (x->mode&ORCLOSE)) + if(x->mode==NP_OEXEC || (x->mode&NP_ORCLOSE)) goto Deny; switch(x->mode){ default: goto Deny; - case OREAD: + case NP_OREAD: m = 0400; break; - case OWRITE: + case NP_OWRITE: m = 0200; break; - case ORDWR: + case NP_ORDWR: m = 0600; break; } if(((f->dir->perm&~(DMDIR|DMAPPEND))&m) != m) goto Deny; - + sendp(x->c, xfidopen); return nil; diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c index f483ac6..c395694 100644 --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/rio/scrl.c b/sys/src/cmd/rio/scrl.c index 2c7f91e..1d48409 100644 --- a/sys/src/cmd/rio/scrl.c +++ b/sys/src/cmd/rio/scrl.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/rio/time.c b/sys/src/cmd/rio/time.c index bc14a5a..4dda61d 100644 --- a/sys/src/cmd/rio/time.c +++ b/sys/src/cmd/rio/time.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/rio/util.c b/sys/src/cmd/rio/util.c index 7d646dc..e161f2e 100644 --- a/sys/src/cmd/rio/util.c +++ b/sys/src/cmd/rio/util.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/rio/wctl.c b/sys/src/cmd/rio/wctl.c index 2751a6a..74c9d66 100644 --- a/sys/src/cmd/rio/wctl.c +++ b/sys/src/cmd/rio/wctl.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c index d8b6d19..9ba7dd8 100644 --- a/sys/src/cmd/rio/wind.c +++ b/sys/src/cmd/rio/wind.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include #include "dat.h" diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c index 879ab15..911abce 100644 --- a/sys/src/cmd/rio/xfid.c +++ b/sys/src/cmd/rio/xfid.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "dat.h" #include "fns.h" @@ -281,11 +281,11 @@ xfidopen(Xfid *x) w->mouseopen = TRUE; break; case Qsnarf: - if(x->mode==ORDWR || x->mode==OWRITE) + if(x->mode==NP_ORDWR || x->mode==NP_OWRITE) ntsnarf = 0; break; case Qwctl: - if(x->mode==OREAD || x->mode==ORDWR){ + if(x->mode==NP_OREAD || x->mode==NP_ORDWR){ /* * It would be much nicer to implement fan-out for wctl reads, * so multiple people can see the resizings, but rio just isn't @@ -346,14 +346,14 @@ xfidclose(Xfid *x) break; /* odd behavior but really ok: replace snarf buffer when /dev/snarf is closed */ case Qsnarf: - if(x->f->mode==ORDWR || x->f->mode==OWRITE){ + if(x->f->mode==NP_ORDWR || x->f->mode==NP_OWRITE){ snarf = runerealloc(snarf, ntsnarf+1); cvttorunes(tsnarf, ntsnarf, snarf, &nb, &nsnarf, &nulls); ntsnarf = 0; } break; case Qwctl: - if(x->f->mode==OREAD || x->f->mode==ORDWR) + if(x->f->mode==NP_OREAD || x->f->mode==NP_ORDWR) w->wctlopen = FALSE; break; } @@ -396,7 +396,7 @@ xfidwrite(Xfid *x) alts[CWflush].v = nil; alts[CWflush].op = CHANRCV; alts[NCW].op = CHANEND; - + switch(alt(alts)){ case CWdata: break; diff --git a/sys/src/cmd/sam/io.c b/sys/src/cmd/sam/io.c index 602a64a..0257d6f 100644 --- a/sys/src/cmd/sam/io.c +++ b/sys/src/cmd/sam/io.c @@ -55,7 +55,7 @@ writef(File *f) if(genc) free(genc); genc = Strtoc(&genstr); - if((io=create(genc, 1, 0666L)) < 0) + if((io=create(genc, OWRITE, 0666L)) < 0) error_r(Ecreate, genc); dprint("%s: ", genc); if(statfd(io, 0, 0, 0, &length, &appendonly) > 0 && appendonly && length>0) diff --git a/sys/src/cmd/sam/mesg.c b/sys/src/cmd/sam/mesg.c index 518d553..10c70a8 100644 --- a/sys/src/cmd/sam/mesg.c +++ b/sys/src/cmd/sam/mesg.c @@ -98,7 +98,7 @@ journal(int out, char *s) static int fd = 0; if(fd <= 0) - fd = create("/tmp/sam.out", 1, 0666L); + fd = create("/tmp/sam.out", OWRITE, 0666L); fprint(fd, "%s%s\n", out? "out: " : "in: ", s); } diff --git a/sys/src/cmd/sam/sam.c b/sys/src/cmd/sam/sam.c index 42a62a2..fc43650 100644 --- a/sys/src/cmd/sam/sam.c +++ b/sys/src/cmd/sam/sam.c @@ -137,7 +137,7 @@ rescue(void) continue; if(io == -1){ sprint(buf, "%s/sam.save", home); - io = create(buf, 1, 0777); + io = create(buf, OWRITE, 0777); if(io<0) return; } diff --git a/sys/src/cmd/sam/shell.c b/sys/src/cmd/sam/shell.c index bb42857..8be7081 100644 --- a/sys/src/cmd/sam/shell.c +++ b/sys/src/cmd/sam/shell.c @@ -41,9 +41,9 @@ plan9(File *f, int type, String *s, int nest) snarf(f, addr.r.p1, addr.r.p2, &plan9buf, 1); if((pid=fork()) == 0){ if(downloaded){ /* also put nasty fd's into errfile */ - fd = create(errfile, 1, 0666L); + fd = create(errfile, OWRITE, 0666L); if(fd < 0) - fd = create("/dev/null", 1, 0666L); + fd = create("/dev/null", OWRITE, 0666L); dup(fd, 2); close(fd); /* 2 now points at err file */ @@ -51,7 +51,7 @@ plan9(File *f, int type, String *s, int nest) dup(2, 1); else if(type=='!'){ dup(2, 1); - fd = open("/dev/null", 0); + fd = open("/dev/null", OREAD); dup(fd, 0); close(fd); } @@ -98,7 +98,7 @@ plan9(File *f, int type, String *s, int nest) } if(type=='<'){ close(0); /* so it won't read from terminal */ - open("/dev/null", 0); + open("/dev/null", OREAD); } execl(SHPATH, SH, "-c", Strtoc(&plan9cmd), nil); exits("exec"); @@ -145,7 +145,7 @@ checkerrs(void) long l; if(statfile(errfile, 0, 0, 0, &l, 0) > 0 && l != 0){ - if((f=open((char *)errfile, 0)) != -1){ + if((f=open((char *)errfile, OREAD)) != -1){ if((n=read(f, buf, sizeof buf-1)) > 0){ for(nl=0,p=buf; nl<3 && p<&buf[n]; p++) if(*p=='\n') diff --git a/sys/src/cmd/samterm/plan9.c b/sys/src/cmd/samterm/plan9.c index 35d3112..4069b5c 100644 --- a/sys/src/cmd/samterm/plan9.c +++ b/sys/src/cmd/samterm/plan9.c @@ -107,7 +107,7 @@ snarfswap(char *fromsam, int nc, char **tosam) free(s1); } else s1[n] = 0; - f = create("/dev/snarf", 1, 0666); + f = create("/dev/snarf", OWRITE, 0666); if(f >= 0){ write(f, fromsam, nc); close(f); @@ -167,7 +167,7 @@ extstart(void) if(pipe(p) < 0) return; sprint(exname, "/srv/sam.%s", getuser()); - fd = create(exname, 1, 0600); + fd = create(exname, OWRITE, 0600); if(fd < 0){ /* assume existing guy is more important */ Err: close(p[0]); diff --git a/sys/src/cmd/srv.c b/sys/src/cmd/srv.c index de3bd65..18c305c 100644 --- a/sys/src/cmd/srv.c +++ b/sys/src/cmd/srv.c @@ -169,7 +169,7 @@ main(int argc, char *argv[]) Again: try++; - if(access(srv, 0) == 0){ + if(access(srv, AEXIST) == 0){ if(domount){ fd = open(srv, ORDWR); if(fd >= 0) @@ -206,7 +206,7 @@ Mount: if(domount == 0 || reallymount == 0) exits(0); - if((!doauth && mount(fd, -1, mtpt, mountflag, "", 'M') < 0) + if((!doauth && mount(fd, -1, mtpt, mountflag, "", '9') < 0) || (doauth && amount(fd, mtpt, mountflag, "") < 0)){ err[0] = 0; errstr(err, sizeof err); diff --git a/sys/src/cmd/sys/call/syscall.c b/sys/src/cmd/sys/call/syscall.c index cd6c2f6..5a1be0c 100644 --- a/sys/src/cmd/sys/call/syscall.c +++ b/sys/src/cmd/sys/call/syscall.c @@ -10,7 +10,7 @@ #include #include //#include -#include +#include <9P2000.h> char buf[1048576]; #define NARG 5 diff --git a/sys/src/cmd/tail.c b/sys/src/cmd/tail.c index 66ca86a..aaf702d 100644 --- a/sys/src/cmd/tail.c +++ b/sys/src/cmd/tail.c @@ -99,7 +99,7 @@ main(int argc, char **argv) count--; if(argc > 2) usage(); - if(argc > 1 && (file=open(argv[1],0)) < 0) + if(argc > 1 && (file=open(argv[1], OREAD)) < 0) fatal(argv[1]); seekable = isseekable(file); @@ -355,9 +355,9 @@ getnumber(char *s) if(count < 0 || (int)count != count) fatal("too big"); return 1; -} +} -void +void fatal(char *s) { char buf[ERRMAX]; @@ -380,7 +380,7 @@ usage(void) */ static int isseekable(int fd) -{ +{ int64_t m; m = seek(fd, 0, 1); diff --git a/sys/src/cmd/tar.c b/sys/src/cmd/tar.c index 7e590a0..b1614d0 100644 --- a/sys/src/cmd/tar.c +++ b/sys/src/cmd/tar.c @@ -9,7 +9,7 @@ #include #include #include -#include /* for %M */ +#include <9P2000.h> /* for %M */ #include /* diff --git a/sys/src/cmd/test.c b/sys/src/cmd/test.c index e437a45..8af1a34 100644 --- a/sys/src/cmd/test.c +++ b/sys/src/cmd/test.c @@ -152,16 +152,16 @@ e3(void) return(isdir(nxtarg(0))); if(EQ(a, "-r")) - return(tio(nxtarg(0), 4)); + return(tio(nxtarg(0), AREAD)); if(EQ(a, "-w")) - return(tio(nxtarg(0), 2)); + return(tio(nxtarg(0), AWRITE)); if(EQ(a, "-x")) - return(tio(nxtarg(0), 1)); + return(tio(nxtarg(0), AEXEC)); if(EQ(a, "-e")) - return(tio(nxtarg(0), 0)); + return(tio(nxtarg(0), AEXIST)); if(EQ(a, "-c")) return(0); diff --git a/sys/src/cmd/usb/audio/audio.c b/sys/src/cmd/usb/audio/audio.c index 0d41c8f..cccd6ef 100644 --- a/sys/src/cmd/usb/audio/audio.c +++ b/sys/src/cmd/usb/audio/audio.c @@ -1,6 +1,6 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> #include "usb.h" diff --git a/sys/src/cmd/usb/disk/disk.c b/sys/src/cmd/usb/disk/disk.c index 1c51b26..14e0eff 100644 --- a/sys/src/cmd/usb/disk/disk.c +++ b/sys/src/cmd/usb/disk/disk.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> #include "scsireq.h" diff --git a/sys/src/cmd/usb/disk/scsireq.c b/sys/src/cmd/usb/disk/scsireq.c index 1fd3465..958d349 100644 --- a/sys/src/cmd/usb/disk/scsireq.c +++ b/sys/src/cmd/usb/disk/scsireq.c @@ -15,7 +15,7 @@ #include #include -#include +#include <9P2000.h> #include "scsireq.h" enum { diff --git a/sys/src/cmd/usb/ether/ether.c b/sys/src/cmd/usb/ether/ether.c index 756e112..37a24af 100644 --- a/sys/src/cmd/usb/ether/ether.c +++ b/sys/src/cmd/usb/ether/ether.c @@ -5,7 +5,7 @@ #include "usb.h" #include "dat.h" -#include +#include <9P2000.h> #include <9p.h> #include diff --git a/sys/src/cmd/usb/ptp/ptp.c b/sys/src/cmd/usb/ptp/ptp.c index 006d7ea..876d528 100644 --- a/sys/src/cmd/usb/ptp/ptp.c +++ b/sys/src/cmd/usb/ptp/ptp.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" @@ -295,7 +295,7 @@ vptprpc(Ioproc *io, int code, int flags, va_list a) l = GET4(rpc.length); l -= (4+2+2+4); n -= (4+2+2+4); - + b = emalloc9p(l); p = b; e = b+l; @@ -658,7 +658,7 @@ readchilds(Req *r, Node *nod) *xx = x; xx = &x->next; *xx = nil; - } + } free(a); break; @@ -838,7 +838,7 @@ fsread(Req *r) count = nod->d.length - offset; pos = 3; } - if(!ptprpc(r, GetPartialObject, 4|DataRecv, + if(!ptprpc(r, GetPartialObject, 4|DataRecv, nod->handle, offset, count, pos, &p, &np)){ if(np <= count){ memmove(r->ofcall.data, p, np); @@ -900,7 +900,7 @@ fsremove(Req *r) static void fsopen(Req *r) { - if(r->ifcall.mode != OREAD){ + if(r->ifcall.mode != NP_OREAD){ respond(r, Eperm); return; } @@ -971,7 +971,7 @@ findendpoints(Dev *d, int *epin, int *epout, int *epint) return -1; } -Srv fs = +Srv fs = { .attach = fsattach, .destroyfid = fsdestroyfid, diff --git a/sys/src/cmd/usb/serial/ftdi.c b/sys/src/cmd/usb/serial/ftdi.c index d1cdc19..a5db406 100644 --- a/sys/src/cmd/usb/serial/ftdi.c +++ b/sys/src/cmd/usb/serial/ftdi.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" #include "serial.h" diff --git a/sys/src/cmd/usb/serial/prolific.c b/sys/src/cmd/usb/serial/prolific.c index dfdf633..a46cec6 100644 --- a/sys/src/cmd/usb/serial/prolific.c +++ b/sys/src/cmd/usb/serial/prolific.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" #include "serial.h" diff --git a/sys/src/cmd/usb/serial/serial.c b/sys/src/cmd/usb/serial/serial.c index 10e7de4..4f64693 100644 --- a/sys/src/cmd/usb/serial/serial.c +++ b/sys/src/cmd/usb/serial/serial.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" #include "serial.h" diff --git a/sys/src/cmd/usb/serial/silabs.c b/sys/src/cmd/usb/serial/silabs.c index 2e56b98..9cf75f9 100644 --- a/sys/src/cmd/usb/serial/silabs.c +++ b/sys/src/cmd/usb/serial/silabs.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" #include "serial.h" diff --git a/sys/src/cmd/usb/serial/ucons.c b/sys/src/cmd/usb/serial/ucons.c index 552126f..3349b4e 100644 --- a/sys/src/cmd/usb/serial/ucons.c +++ b/sys/src/cmd/usb/serial/ucons.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" #include "serial.h" diff --git a/sys/src/cmd/usb/usbd/usbd.c b/sys/src/cmd/usb/usbd/usbd.c index 19f0596..7cbb3c0 100644 --- a/sys/src/cmd/usb/usbd/usbd.c +++ b/sys/src/cmd/usb/usbd/usbd.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> #include "usb.h" #include "dat.h" diff --git a/sys/src/kern/386/devether.c b/sys/src/kern/386/devether.c index 06d5102..6fd819c 100644 --- a/sys/src/kern/386/devether.c +++ b/sys/src/kern/386/devether.c @@ -56,13 +56,13 @@ etherstat(Chan* chan, uint8_t* dp, long n) } static Chan* -etheropen(Chan* chan, int omode) +etheropen(Chan* chan, unsigned long omode) { return netifopen(ðerxx[chan->devno]->netif, chan, omode); } static Chan* -ethercreate(Chan* _1, char* _2, int _3, int _4) +ethercreate(Chan* _1, char* _2, unsigned long _3, unsigned long _4) { error(Eperm); return nil; diff --git a/sys/src/kern/386/devrtc.c b/sys/src/kern/386/devrtc.c index d85ad0c..1008c49 100644 --- a/sys/src/kern/386/devrtc.c +++ b/sys/src/kern/386/devrtc.c @@ -80,7 +80,7 @@ rtcstat(Chan* c, uint8_t* dp, long n) } static Chan* -rtcopen(Chan* c, int omode) +rtcopen(Chan* c, unsigned long omode) { return devopen(c, openmode(omode), rtcdir, nelem(rtcdir), devgen); } diff --git a/sys/src/kern/amd64/build.json b/sys/src/kern/amd64/build.json index 5075646..605ae8b 100644 --- a/sys/src/kern/amd64/build.json +++ b/sys/src/kern/amd64/build.json @@ -29,7 +29,7 @@ "ether", "ip", "kprof", - "mnt", + "ninep", "pci", "pipe", "proc", diff --git a/sys/src/kern/amd64/devacpi.c b/sys/src/kern/amd64/devacpi.c index b5decd9..c63ca93 100644 --- a/sys/src/kern/amd64/devacpi.c +++ b/sys/src/kern/amd64/devacpi.c @@ -419,7 +419,7 @@ acpistat(Chan *c, uint8_t *dp, long n) } static Chan* -acpiopen(Chan *c, int omode) +acpiopen(Chan *c, unsigned long omode) { c = devopen(c, omode, acpidir, nelem(acpidir), acpigen); switch((uint32_t)c->qid.path){ @@ -480,7 +480,7 @@ acpiread(Chan *c, void *a, long n, int64_t off) p = seprint(p, e, "ngpe %d\n", ngpe); USED(p); return readstr(off, a, n, buf); - + case Qevent: return qread(aconf.event, a, n); } diff --git a/sys/src/kern/amd64/devarch.c b/sys/src/kern/amd64/devarch.c index ef63f4c..ccbd91c 100644 --- a/sys/src/kern/amd64/devarch.c +++ b/sys/src/kern/amd64/devarch.c @@ -328,7 +328,7 @@ archstat(Chan* c, uint8_t* dp, long n) } static Chan* -archopen(Chan* c, int omode) +archopen(Chan* c, unsigned long omode) { return devopen(c, omode, archdir, narchdir, devgen); } diff --git a/sys/src/kern/amd64/devvga.c b/sys/src/kern/amd64/devvga.c index 2551fba..1a552ef 100644 --- a/sys/src/kern/amd64/devvga.c +++ b/sys/src/kern/amd64/devvga.c @@ -124,9 +124,9 @@ vgareset(void) { /* reserve the 'standard' vga registers */ if(ioalloc(0x2b0, 0x2df-0x2b0+1, 0, "vga") < 0) - panic("vga ports already allocated"); + panic("vga ports already allocated"); if(ioalloc(0x3c0, 0x3da-0x3c0+1, 0, "vga") < 0) - panic("vga ports already allocated"); + panic("vga ports already allocated"); addarchfile("realmodemem", 0660, rmemread, rmemwrite); } @@ -151,7 +151,7 @@ vgastat(Chan* c, uint8_t* dp, long n) } static Chan* -vgaopen(Chan* c, int omode) +vgaopen(Chan* c, unsigned long omode) { VGAscr *scr; static char *openctl = "openctl\n"; @@ -160,7 +160,7 @@ vgaopen(Chan* c, int omode) if ((uint32_t)c->qid.path == Qvgaovlctl) { if (scr->dev && scr->dev->ovlctl) scr->dev->ovlctl(scr, c, openctl, strlen(openctl)); - else + else error(Enonexist); } return devopen(c, omode, vgadir, nelem(vgadir), devgen); @@ -230,7 +230,7 @@ vgaread(Chan* c, void* a, long n, int64_t off) scr->gscreen->r.max.x, scr->gscreen->r.max.y, scr->gscreen->depth, chantostr(chbuf, scr->gscreen->chan)); - if(Dx(scr->gscreen->r) != Dx(physgscreenr) + if(Dx(scr->gscreen->r) != Dx(physgscreenr) || Dy(scr->gscreen->r) != Dy(physgscreenr)) len += snprint(p+len, READSTR-len, "actualsize %dx%d\n", physgscreenr.max.x, physgscreenr.max.y); @@ -381,7 +381,7 @@ vgactl(Cmdbuf *cb) physgscreenr = Rect(0,0,x,y); scr->gscreen->clipr = physgscreenr; return; - + case CMpalettedepth: x = strtoul(cb->f[1], &p, 0); if(x != 8 && x != 6) @@ -396,7 +396,7 @@ vgactl(Cmdbuf *cb) if(scr->dev && scr->dev->drawinit) scr->dev->drawinit(scr); return; - + case CMlinear: if(cb->nf!=2 && cb->nf!=3) error(Ebadarg); @@ -408,7 +408,7 @@ vgactl(Cmdbuf *cb) if(screenaperture(size, align) < 0) error("not enough free address space"); return; -/* +/* case CMmemset: memset((void*)strtoul(cb->f[1], 0, 0), atoi(cb->f[2]), atoi(cb->f[3])); return; @@ -417,11 +417,11 @@ vgactl(Cmdbuf *cb) case CMblank: drawblankscreen(1); return; - + case CMunblank: drawblankscreen(0); return; - + case CMblanktime: blanktime = strtoul(cb->f[1], 0, 0); return; @@ -450,7 +450,7 @@ vgactl(Cmdbuf *cb) else break; return; - + case CMhwblank: if(strcmp(cb->f[1], "on") == 0) hwblank = 1; diff --git a/sys/src/kern/amd64/laptop.json b/sys/src/kern/amd64/laptop.json index a87ec18..b163b89 100644 --- a/sys/src/kern/amd64/laptop.json +++ b/sys/src/kern/amd64/laptop.json @@ -29,14 +29,13 @@ "ether", "ip", "kprof", - "mnt", + "ninep", "pci", "pipe", "proc", "root", "rtc", "sd", - "segment", "shr", "srv", "ssl", diff --git a/sys/src/kern/amd64/workhorse.json b/sys/src/kern/amd64/workhorse.json index 4ad9061..1617a82 100644 --- a/sys/src/kern/amd64/workhorse.json +++ b/sys/src/kern/amd64/workhorse.json @@ -26,7 +26,7 @@ "env", "ether", "ip", - "mnt", + "ninep", "pci", "pipe", "proc", diff --git a/sys/src/kern/boot/aux.c b/sys/src/kern/boot/aux.c index 300fd06..9520658 100644 --- a/sys/src/kern/boot/aux.c +++ b/sys/src/kern/boot/aux.c @@ -139,7 +139,7 @@ setenv(char *name, char *val) char ename[64]; snprint(ename, sizeof ename, "#e/%s", name); - f = create(ename, 1, 0666); + f = create(ename, OWRITE, 0666); if(f < 0){ fprint(2, "create %s: %r\n", ename); return; @@ -162,7 +162,7 @@ srvcreate(char *name, int fd) srvname = name; snprint(buf, sizeof buf, "#s/%s", srvname); - f = create(buf, 1, 0600); + f = create(buf, OWRITE, 0600); if(f < 0) fatal(buf); sprint(buf, "%d", fd); diff --git a/sys/src/kern/boot/boot.c b/sys/src/kern/boot/boot.c index c70667c..a385c1a 100644 --- a/sys/src/kern/boot/boot.c +++ b/sys/src/kern/boot/boot.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "../boot/boot.h" char cputype[64]; @@ -153,7 +153,7 @@ print("\n"); if(ai == nil) print("authentication failed (%r), trying mount anyways\n"); } - if(mount(fd, afd, "/root", MREPL|MCREATE, rp, 'M') < 0) + if(mount(fd, afd, "/root", MREPL|MCREATE, rp, '9') < 0) fatal("mount /"); rsp = rp; rp = getenv("rootdir"); @@ -364,7 +364,7 @@ startconsole(void) /* replace 0, 1 and 2 */ if((i = open("#s/screenconsole", ORDWR)) < 0) fatal("open #s/screenconsole"); - if(mount(i, -1, "/dev", MBEFORE, "", 'M') < 0) + if(mount(i, -1, "/dev", MBEFORE, "", '9') < 0) fatal("mount /dev"); if((i = open("/dev/cons", OREAD))<0) fatal("open /dev/cons, OREAD"); @@ -419,7 +419,7 @@ startcomconsole(void) /* replace 0, 1 and 2 */ if((i = open("#s/comconsole", ORDWR)) < 0) fatal("open #s/comconsole"); - if(mount(i, -1, "/dev", MBEFORE, "", 'M') < 0) + if(mount(i, -1, "/dev", MBEFORE, "", '9') < 0) fatal("mount /dev"); if((i = open("/dev/cons", OREAD))<0) fatal("open /dev/cons, OREAD"); diff --git a/sys/src/kern/boot/bootauth.c b/sys/src/kern/boot/bootauth.c index 94369c3..94ad43b 100644 --- a/sys/src/kern/boot/bootauth.c +++ b/sys/src/kern/boot/bootauth.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "../boot/boot.h" char *authaddr; @@ -56,7 +56,7 @@ authentication(int cpuflag) } /* wait for agent to really be there */ - while(access("/mnt/factotum", 0) < 0) + while(access("/mnt/factotum", AEXIST) < 0) sleep(250); if(cpuflag) diff --git a/sys/src/kern/boot/bootip.c b/sys/src/kern/boot/bootip.c index a9388fc..d637fa7 100644 --- a/sys/src/kern/boot/bootip.c +++ b/sys/src/kern/boot/bootip.c @@ -64,13 +64,13 @@ print("ipconfig..."); if(access(ipconfigPath, AEXEC) < 0) fatal("cannot access ipconfig"); - if(access("#l0", 0) == 0 && bind("#l0", mpoint, MAFTER) < 0) + if(access("#l0", AEXIST) == 0 && bind("#l0", mpoint, MAFTER) < 0) print("bind #l0: %r\n"); - if(access("#l1", 0) == 0 && bind("#l1", mpoint, MAFTER) < 0) + if(access("#l1", AEXIST) == 0 && bind("#l1", mpoint, MAFTER) < 0) print("bind #l1: %r\n"); - if(access("#l2", 0) == 0 && bind("#l2", mpoint, MAFTER) < 0) + if(access("#l2", AEXIST) == 0 && bind("#l2", mpoint, MAFTER) < 0) print("bind #l2: %r\n"); - if(access("#l3", 0) == 0 && bind("#l3", mpoint, MAFTER) < 0) + if(access("#l3", AEXIST) == 0 && bind("#l3", mpoint, MAFTER) < 0) print("bind #l3: %r\n"); werrstr(""); diff --git a/sys/src/kern/boot/nopsession.c b/sys/src/kern/boot/nopsession.c index 7b33911..0a67495 100644 --- a/sys/src/kern/boot/nopsession.c +++ b/sys/src/kern/boot/nopsession.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "../boot/boot.h" static Fcall hdr; diff --git a/sys/src/kern/boot/settime.c b/sys/src/kern/boot/settime.c index 8f77e40..e36dac9 100644 --- a/sys/src/kern/boot/settime.c +++ b/sys/src/kern/boot/settime.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include <9P2000.h> #include "../boot/boot.h" static int32_t lusertime(char*); @@ -59,7 +59,7 @@ settime(int islocal, int afd, char *rp) f = open(timeserver, ORDWR); if(f < 0) return; - if(mount(f, afd, "/tmp", MREPL, rp, 'M') < 0){ + if(mount(f, afd, "/tmp", MREPL, rp, '9') < 0){ warning("settime mount"); close(f); if((!islocal) && (setlocaltime(timebuf, sizeof(timebuf)) == 0)) diff --git a/sys/src/kern/ip/devip.c b/sys/src/kern/ip/devip.c index 77b96a3..6a1e83e 100644 --- a/sys/src/kern/ip/devip.c +++ b/sys/src/kern/ip/devip.c @@ -349,7 +349,7 @@ static int m2p[] = { }; static Chan* -ipopen(Chan* c, int omode) +ipopen(Chan* c, unsigned long omode) { Conv *cv, *nc; Proto *p; @@ -501,7 +501,7 @@ ipopen(Chan* c, int omode) } static Chan* -ipcreate(Chan* _1, char* _2, int _3, int _4) +ipcreate(Chan* _1, char* _2, unsigned long _3, unsigned long _4) { error(Eperm); return nil; @@ -819,7 +819,7 @@ setlport(Conv* c) * if we do (and we're a cpu server), we might as well restart * since we're now unable to service new connections. */ - print("setlport: %s: %s: %I!%ud -> %I out of ports\n", + print("setlport: %s: %s: %I!%ud -> %I out of ports\n", p->name, c->restricted? "restrict": "", c->raddr, c->rport, c->laddr); return "no ports available"; diff --git a/sys/src/kern/port/chan.c b/sys/src/kern/port/chan.c index 5844d2e..945e18b 100644 --- a/sys/src/kern/port/chan.c +++ b/sys/src/kern/port/chan.c @@ -1285,7 +1285,7 @@ namec(char *aname, int amode, int omode, int perm) n = chartorune(&r, up->genbuf+1)+1; } /* actually / is caught by parsing earlier */ - if(utfrune("M", r)) + if(utfrune("9", r)) error(Enoattach); /* * noattach is sandboxing. diff --git a/sys/src/kern/port/dev.c b/sys/src/kern/port/dev.c index a273efe..42263a0 100644 --- a/sys/src/kern/port/dev.c +++ b/sys/src/kern/port/dev.c @@ -352,8 +352,8 @@ devdirread(Chan *c, char *d, long n, Dirtab *tab, int ntab, Devgen *gen) void devpermcheck(char *fileuid, int perm, int omode) { - int t; - static int access[] = { 0400, 0200, 0600, 0100 }; + int required; + static int access[] = { 0000, 0400, 0200, 0600, 0100, 0xff, 0xff, 0xff }; if(strcmp(up->user, fileuid) == 0) perm <<= 0; @@ -362,13 +362,13 @@ devpermcheck(char *fileuid, int perm, int omode) else perm <<= 6; - t = access[omode&7]; - if((t&perm) != t) + required = access[omode&7]; + if((required&perm) != required) error(Eperm); } Chan* -devopen(Chan *c, int omode, Dirtab *tab, int ntab, Devgen *gen) +devopen(Chan *c, unsigned long omode, Dirtab *tab, int ntab, Devgen *gen) { int i; Dir dir; @@ -397,7 +397,7 @@ Return: } Chan* -devcreate(Chan* _1, char* _2, int _3, int _4) +devcreate(Chan* _1, char* _2, unsigned long _3, unsigned long _4) { error(Eperm); return nil; diff --git a/sys/src/kern/port/devmnt.c b/sys/src/kern/port/dev9p.c similarity index 92% rename from sys/src/kern/port/devmnt.c rename to sys/src/kern/port/dev9p.c index 8acd8e2..8128f67 100644 --- a/sys/src/kern/port/devmnt.c +++ b/sys/src/kern/port/dev9p.c @@ -359,7 +359,7 @@ mntchan(void) { Chan *c; - c = devattach('M', 0); + c = devattach('9', 0); lock(&mntalloc); c->devno = mntalloc.id++; unlock(&mntalloc); @@ -486,8 +486,75 @@ mntstat(Chan *c, uint8_t *dp, long n) return nstat; } +static unsigned long +ninep2mode(int omode9p) +{ + unsigned long mode = 0; + + /* 9P2000 allows a single byte for open mode and all the + * constants are hardcoded in the protocol + * see http://man.cat-v.org/9front/5/open + */ + if((omode9p&~0xff) || (omode9p&NP_OZEROES)) + error("invalid 9P2000 open mode"); + + switch(omode9p & ~(NP_OTRUNC|NP_ORCLOSE)){ + case NP_OREAD: + return OREAD; + case NP_OWRITE: + mode = OWRITE; + break; + case NP_ORDWR: + mode = ORDWR; + break; + case NP_OEXEC: + mode = OEXEC; + break; + default: + error("invalid 9P2000 open mode"); + } + if(omode9p & NP_OTRUNC) + mode |= OTRUNC; + if(omode9p & NP_ORCLOSE) + mode |= ORCLOSE; + + return mode; +} + +static int +mode2ninep(unsigned long mode) +{ + int omode9p = 0; + + openmode(mode); /* error check only */ + + /* 9P2000 allows a single byte for open mode and all the + * constants are hardcoded in the protocol + * see http://man.cat-v.org/9front/5/open + */ + if((mode&OKMODE) == OREAD) + return NP_OREAD; + if((mode&ORDWR) == ORDWR) + omode9p |= NP_ORDWR; + else if(mode & OWRITE) + omode9p |= NP_OWRITE; + else if(mode & OEXEC) + omode9p |= NP_OEXEC; + if(mode & ORCLOSE) + omode9p |= NP_ORCLOSE; + + /* this is an approssimation: in Jehanne this bit might means + * something different to a server, but then the + * server should not use 9P2000 + */ + if(mode & OTRUNC) + omode9p |= NP_OTRUNC; + + return omode9p; +} + static Chan* -mntopencreate(int type, Chan *c, char *name, int omode, int perm) +mntopencreate(int type, Chan *c, char *name, unsigned long omode, int perm) { Mnt *mnt; Mntrpc *r; @@ -500,7 +567,7 @@ mntopencreate(int type, Chan *c, char *name, int omode, int perm) } r->request.type = type; r->request.fid = c->fid; - r->request.mode = omode; + r->request.mode = mode2ninep(omode); if(type == Tcreate){ r->request.perm = perm; r->request.name = name; @@ -509,7 +576,7 @@ mntopencreate(int type, Chan *c, char *name, int omode, int perm) c->qid = r->reply.qid; c->offset = 0; - c->mode = openmode(omode); + c->mode = ninep2mode(mode2ninep(omode)); // discards unsopported flags c->iounit = r->reply.iounit; if(c->iounit == 0 || c->iounit > mnt->msize-IOHDRSZ) c->iounit = mnt->msize-IOHDRSZ; @@ -524,13 +591,13 @@ mntopencreate(int type, Chan *c, char *name, int omode, int perm) } static Chan* -mntopen(Chan *c, int omode) +mntopen(Chan *c, unsigned long omode) { return mntopencreate(Topen, c, nil, omode, 0); } static Chan* -mntcreate(Chan *c, char *name, int omode, int perm) +mntcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) { return mntopencreate(Tcreate, c, name, omode, perm); } @@ -1171,9 +1238,9 @@ rpcattn(void *v) return r->done || r->m->rip == 0; } -Dev mntdevtab = { - 'M', - "mnt", +Dev ninepdevtab = { + '9', + "ninep", mntreset, devinit, diff --git a/sys/src/kern/port/devbridge.c b/sys/src/kern/port/devbridge.c index f211499..94b1adb 100644 --- a/sys/src/kern/port/devbridge.c +++ b/sys/src/kern/port/devbridge.c @@ -120,11 +120,11 @@ struct Port Chan *data[2]; // channel to data Proc *readp; // read proc - + // the following uniquely identifies the port int type; char name[KNAMELEN]; - + // owner hash - avoids bind/unbind races uint32_t ownhash; @@ -231,7 +231,7 @@ bridgestat(Chan* c, uint8_t* db, long n) } static Chan* -bridgeopen(Chan* c, int omode) +bridgeopen(Chan* c, unsigned long omode) { Bridge *b; @@ -352,7 +352,7 @@ bridgewrite(Chan *c, void *a, long n, int64_t off) Bridge *b = bridgetab + c->devno; Cmdbuf *cb; char *arg0, *p; - + USED(off); switch(TYPE(c->qid)) { default: @@ -435,7 +435,7 @@ bridgegen(Chan *c, char* _1, Dirtab* _2, int _3, int s, Dir *dp) default: /* non-directory entries end up here */ if(c->qid.type & QTDIR) - panic("bridgegen: unexpected directory"); + panic("bridgegen: unexpected directory"); if(s != 0) return -1; dt = dirtab[TYPE(c->qid)]; @@ -563,7 +563,7 @@ portbind(Bridge *b, int argc, char *argv[]) port->data[1] = port->data[0]; poperror(); - cclose(ctl); + cclose(ctl); break; case Ttun: @@ -686,7 +686,7 @@ cacheupdate(Bridge *b, uint8_t d[Eaddrlen], int port) log(b, Logcache, "bad source address: %E\n", d); return; } - + h = 0; for(i=0; iexpire == 0) - continue; + continue; c = (sec < ce->expire)?'v':'e'; p += snprint(p, ep-p, "%E %2d %10ld %10ld %10ld %c\n", ce->d, ce->port, ce->src, ce->dst, ce->expire+off, c); @@ -789,7 +789,7 @@ ethermultiwrite(Bridge *b, Block *bp, Port *port) freeb(bp); nexterror(); } - + ep = (Etherpkt*)bp->rp; mcast = ep->d[0] & 1; /* multicast bit of ethernet address */ @@ -926,7 +926,7 @@ etherread(void *a) Etherpkt *ep; Centry *ce; int32_t md; - + qlock(&b->ql); port->readp = up; /* hide identity under a rock for unbind */ @@ -1048,7 +1048,7 @@ etherwrite(Port *port, Block *bp) } port->outfrag++; if(waserror()){ - freeblist(bp); + freeblist(bp); nexterror(); } @@ -1067,13 +1067,13 @@ etherwrite(Port *port, Block *bp) xp = xp->next; } xp->rp += offset; - + if(0) print("seglen=%d, dlen=%d, mf=%x, frag=%d\n", seglen, dlen, mf, frag); for(fragoff = 0; fragoff < dlen; fragoff += seglen) { nb = allocb(ETHERHDRSIZE+IPHDR+seglen); - + feh = (Iphdr*)(nb->wp+ETHERHDRSIZE); memmove(nb->wp, epkt, ETHERHDRSIZE+IPHDR); @@ -1083,7 +1083,7 @@ etherwrite(Port *port, Block *bp) seglen = dlen - fragoff; hnputs(feh->frag, (frag+fragoff)>>3 | mf); } - else + else hnputs(feh->frag, (frag+fragoff>>3) | IP_MF); hnputs(feh->length, seglen + IPHDR); @@ -1101,19 +1101,19 @@ etherwrite(Port *port, Block *bp) chunk -= blklen; if(xp->rp == xp->wp) xp = xp->next; - } + } feh->cksum[0] = 0; feh->cksum[1] = 0; hnputs(feh->cksum, ipcsum(&feh->vihl)); - + /* don't generate small packets */ if(BLEN(nb) < ETHERMINTU) nb->wp = nb->rp + ETHERMINTU; devtab[port->data[1]->qid.type]->bwrite(port->data[1], nb, 0); } poperror(); - freeblist(bp); + freeblist(bp); } // hold b lock diff --git a/sys/src/kern/port/devcap.c b/sys/src/kern/port/devcap.c index a2e29d8..888dd90 100644 --- a/sys/src/kern/port/devcap.c +++ b/sys/src/kern/port/devcap.c @@ -80,7 +80,7 @@ capstat(Chan *c, uint8_t *db, long n) * if the stream doesn't exist, create it */ static Chan* -capopen(Chan *c, int omode) +capopen(Chan *c, unsigned long omode) { if(c->qid.type & QTDIR){ if(omode != OREAD) diff --git a/sys/src/kern/port/devcons.c b/sys/src/kern/port/devcons.c index e7ddca3..3d49ab2 100644 --- a/sys/src/kern/port/devcons.c +++ b/sys/src/kern/port/devcons.c @@ -787,7 +787,7 @@ consstat(Chan *c, uint8_t *dp, long n) } static Chan* -consopen(Chan *c, int omode) +consopen(Chan *c, unsigned long omode) { c->aux = nil; c = devopen(c, omode, consdir, nelem(consdir), devgen); diff --git a/sys/src/kern/port/devdraw.c b/sys/src/kern/port/devdraw.c index 31a6957..4c508d0 100644 --- a/sys/src/kern/port/devdraw.c +++ b/sys/src/kern/port/devdraw.c @@ -1046,7 +1046,7 @@ drawstat(Chan *c, uint8_t *db, long n) } static Chan* -drawopen(Chan *c, int omode) +drawopen(Chan *c, unsigned long omode) { Client *cl; DName *dn; diff --git a/sys/src/kern/port/devdup.c b/sys/src/kern/port/devdup.c index af50c74..770860d 100644 --- a/sys/src/kern/port/devdup.c +++ b/sys/src/kern/port/devdup.c @@ -58,7 +58,7 @@ dupstat(Chan *c, uint8_t *db, long n) } static Chan* -dupopen(Chan *c, int omode) +dupopen(Chan *c, unsigned long omode) { Chan *f; int fd, twicefd; diff --git a/sys/src/kern/port/devenv.c b/sys/src/kern/port/devenv.c index 9897305..dd78473 100644 --- a/sys/src/kern/port/devenv.c +++ b/sys/src/kern/port/devenv.c @@ -90,7 +90,7 @@ envstat(Chan *c, uint8_t *db, long n) } static Chan* -envopen(Chan *c, int omode) +envopen(Chan *c, unsigned long omode) { Egrp *eg; Evalue *e; @@ -137,7 +137,7 @@ envopen(Chan *c, int omode) } static Chan* -envcreate(Chan *c, char *name, int omode, int _1) +envcreate(Chan *c, char *name, unsigned long omode, unsigned long _1) { Egrp *eg; Evalue *e; diff --git a/sys/src/kern/port/devfs.c b/sys/src/kern/port/devfs.c index a9b7d57..fd334d4 100644 --- a/sys/src/kern/port/devfs.c +++ b/sys/src/kern/port/devfs.c @@ -897,7 +897,7 @@ mstat(Chan *c, uint8_t *db, long n) } static Chan* -mopen(Chan *c, int omode) +mopen(Chan *c, unsigned long omode) { int q; Fsdev *mp; diff --git a/sys/src/kern/port/devkprof.c b/sys/src/kern/port/devkprof.c index 7a76758..608fce4 100644 --- a/sys/src/kern/port/devkprof.c +++ b/sys/src/kern/port/devkprof.c @@ -90,7 +90,7 @@ kprofstat(Chan *c, uint8_t *db, long n) } static Chan* -kprofopen(Chan *c, int omode) +kprofopen(Chan *c, unsigned long omode) { if(c->qid.type & QTDIR){ if(omode != OREAD) diff --git a/sys/src/kern/port/devmouse.c b/sys/src/kern/port/devmouse.c index ac0a18f..48743dc 100644 --- a/sys/src/kern/port/devmouse.c +++ b/sys/src/kern/port/devmouse.c @@ -180,7 +180,7 @@ mousestat(Chan *c, uint8_t *db, long n) } static Chan* -mouseopen(Chan *c, int omode) +mouseopen(Chan *c, unsigned long omode) { switch((uint32_t)c->qid.path){ case Qdir: @@ -212,7 +212,7 @@ mouseopen(Chan *c, int omode) } static Chan* -mousecreate(Chan *c, char *j, int i, int u) +mousecreate(Chan *c, char *j, unsigned long i, unsigned long u) { error(Eperm); return nil; diff --git a/sys/src/kern/port/devpci.c b/sys/src/kern/port/devpci.c index a4f092c..23c4c90 100644 --- a/sys/src/kern/port/devpci.c +++ b/sys/src/kern/port/devpci.c @@ -117,7 +117,7 @@ pcistat(Chan* c, uint8_t* dp, long n) } static Chan* -pciopen(Chan *c, int omode) +pciopen(Chan *c, unsigned long omode) { return devopen(c, omode, nil, 0, pcigen); } diff --git a/sys/src/kern/port/devpipe.c b/sys/src/kern/port/devpipe.c index 5a30500..8f4cb62 100644 --- a/sys/src/kern/port/devpipe.c +++ b/sys/src/kern/port/devpipe.c @@ -171,7 +171,7 @@ pipestat(Chan *c, uint8_t *db, long n) * if the stream doesn't exist, create it */ static Chan* -pipeopen(Chan *c, int omode) +pipeopen(Chan *c, unsigned long omode) { Pipe *p; diff --git a/sys/src/kern/port/devproc.c b/sys/src/kern/port/devproc.c index 422812a..4aa3b7e 100644 --- a/sys/src/kern/port/devproc.c +++ b/sys/src/kern/port/devproc.c @@ -294,7 +294,7 @@ nonone(Proc *p) } static Chan* -procopen(Chan *c, int omode) +procopen(Chan *c, unsigned long omode) { Proc *p; Pgrp *pg; diff --git a/sys/src/kern/port/devroot.c b/sys/src/kern/port/devroot.c index c3c1be2..16456df 100644 --- a/sys/src/kern/port/devroot.c +++ b/sys/src/kern/port/devroot.c @@ -176,7 +176,7 @@ rootstat(Chan *c, uint8_t *dp, long n) } static Chan* -rootopen(Chan *c, int omode) +rootopen(Chan *c, unsigned long omode) { return devopen(c, omode, nil, 0, devgen); } diff --git a/sys/src/kern/port/devsd.c b/sys/src/kern/port/devsd.c index 130aa12..0921651 100644 --- a/sys/src/kern/port/devsd.c +++ b/sys/src/kern/port/devsd.c @@ -654,7 +654,7 @@ sdstat(Chan* c, uint8_t* db, long n) } static Chan* -sdopen(Chan* c, int omode) +sdopen(Chan* c, unsigned long omode) { SDpart *pp; SDunit *unit; diff --git a/sys/src/kern/port/devshr.c b/sys/src/kern/port/devshr.c index 90f579f..28e3e6d 100644 --- a/sys/src/kern/port/devshr.c +++ b/sys/src/kern/port/devshr.c @@ -393,7 +393,7 @@ shrstat(Chan *c, uint8_t *db, long n) } static Chan* -shropen(Chan *c, int omode) +shropen(Chan *c, unsigned long omode) { Chan *nc; Sch *sch; @@ -448,7 +448,7 @@ shropen(Chan *c, int omode) Chan* createdir(Chan *c, Mhead *m); static Chan* -shrcreate(Chan *c, char *name, int omode, int perm) +shrcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) { Sch *sch; Shr *shr; diff --git a/sys/src/kern/port/devsrv.c b/sys/src/kern/port/devsrv.c index f83e706..666f67a 100644 --- a/sys/src/kern/port/devsrv.c +++ b/sys/src/kern/port/devsrv.c @@ -111,7 +111,7 @@ srvname(Chan *c) } static Chan* -srvopen(Chan *c, int omode) +srvopen(Chan *c, unsigned long omode) { Srv *sp; Chan *nc; @@ -153,12 +153,14 @@ srvopen(Chan *c, int omode) } static Chan* -srvcreate(Chan *c, char *name, int omode, int perm) +srvcreate(Chan *c, char *name, unsigned long omode, unsigned long perm) { Srv *sp; - if(openmode(omode) != OWRITE) - error(Eperm); + if(openmode(omode & ~ORCLOSE) != OWRITE){ + errorf("srvcreate: omode %#p openmode %#p", omode, openmode(omode & ~ORCLOSE)); + //error(Eperm); + } if(strlen(name) >= sizeof(up->genbuf)) error(Etoolong); diff --git a/sys/src/kern/port/devssl.c b/sys/src/kern/port/devssl.c index 1f713fa..23803b1 100644 --- a/sys/src/kern/port/devssl.c +++ b/sys/src/kern/port/devssl.c @@ -254,7 +254,7 @@ sslstat(Chan *c, uint8_t *db, long n) } static Chan* -sslopen(Chan *c, int omode) +sslopen(Chan *c, unsigned long omode) { Dstate *s, **pp; int perm; diff --git a/sys/src/kern/port/devtls.c b/sys/src/kern/port/devtls.c index a4ee77d..dff663d 100644 --- a/sys/src/kern/port/devtls.c +++ b/sys/src/kern/port/devtls.c @@ -399,7 +399,7 @@ tlsstat(Chan *c, uint8_t *db, long n) } static Chan* -tlsopen(Chan *c, int omode) +tlsopen(Chan *c, unsigned long omode) { TlsRec *tr, **pp; int t, perm; diff --git a/sys/src/kern/port/devtrace.c b/sys/src/kern/port/devtrace.c index 4205940..882693e 100644 --- a/sys/src/kern/port/devtrace.c +++ b/sys/src/kern/port/devtrace.c @@ -471,7 +471,7 @@ tracestat(Chan *c, uint8_t *db, long n) } static Chan* -traceopen(Chan *c, int omode) +traceopen(Chan *c, unsigned long omode) { /* if there is no tracelog, allocate one. Open always fails diff --git a/sys/src/kern/port/devuart.c b/sys/src/kern/port/devuart.c index 88bd8a1..1cb42f5 100644 --- a/sys/src/kern/port/devuart.c +++ b/sys/src/kern/port/devuart.c @@ -273,7 +273,7 @@ uartstat(Chan *c, uint8_t *dp, long n) } static Chan* -uartopen(Chan *c, int omode) +uartopen(Chan *c, unsigned long omode) { Uart *p; diff --git a/sys/src/kern/port/devusb.c b/sys/src/kern/port/devusb.c index 02cb49e..feff38d 100644 --- a/sys/src/kern/port/devusb.c +++ b/sys/src/kern/port/devusb.c @@ -817,7 +817,7 @@ usbload(int speed, int maxpkt) } static Chan* -usbopen(Chan *c, int omode) +usbopen(Chan *c, unsigned long omode) { int q; Ep *ep; diff --git a/sys/src/kern/port/include.json b/sys/src/kern/port/include.json index 2ba0d6a..5340a0b 100644 --- a/sys/src/kern/port/include.json +++ b/sys/src/kern/port/include.json @@ -30,7 +30,7 @@ "../port/devenv.c", "../port/devfs.c", "../port/devkprof.c", - "../port/devmnt.c", + "../port/dev9p.c", "../port/devpci.c", "../port/devpipe.c", "../port/devproc.c", diff --git a/sys/src/kern/port/initcode.c b/sys/src/kern/port/initcode.c index df92628..1654552 100644 --- a/sys/src/kern/port/initcode.c +++ b/sys/src/kern/port/initcode.c @@ -77,7 +77,7 @@ initboot(void) } if((i = open(bootfs, ORDWR)) < 0) return -1; - if(mount(i, -1, bootdir, MREPL, "", 'M') < 0) + if(mount(i, -1, bootdir, MREPL, "", '9') < 0) return -1; remove(bootfs); return access(boot, AEXEC); diff --git a/sys/src/kern/port/lib.h b/sys/src/kern/port/lib.h index 66f81b2..64c73e0 100644 --- a/sys/src/kern/port/lib.h +++ b/sys/src/kern/port/lib.h @@ -192,15 +192,19 @@ extern uint64_t strtoull(char*, char**, int); #define MCACHE 0x0010 /* cache some data */ #define MMASK 0x0017 /* all bits on */ -#define OREAD 0 /* open for read */ -#define OWRITE 1 /* write */ -#define ORDWR 2 /* read and write */ -#define OSTAT 4 /* open for stat/wstat */ -#define OEXEC 7 /* execute, == read but check execute permission */ -#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */ -#define OCEXEC 32 /* or'ed in, close on exec */ -#define ORCLOSE 64 /* or'ed in, remove on close */ -#define OEXCL 0x1000 /* or'ed in, exclusive create */ +/* OPEN MODES: Kernel reserved flags */ +#define OSTAT 0x00 /* open for stat/wstat */ +#define OREAD 0x01 /* open for read */ +#define OWRITE 0x02 /* write */ +#define ORDWR (OREAD|OWRITE) /* read and write */ +#define OEXEC 0x04 /* execute, == read but check execute permission */ +#define OCEXEC 0x08 /* or'ed in, close on exec */ +#define ORCLOSE 0x10 /* or'ed in, remove on close */ +#define OKMODE 0xff /* least significant byte reserved for kernel use */ + +/* OPEN MODES: Popular flags among filesystems */ +#define OTRUNC 0x0100 /* or'ed in (except for exec), truncate file first */ +#define OEXCL 0x0200 /* or'ed in, exclusive create */ #define NCONT 0 /* continue after note */ #define NDFLT 1 /* terminate after note */ diff --git a/sys/src/kern/port/netif.c b/sys/src/kern/port/netif.c index f2a4512..03001ed 100644 --- a/sys/src/kern/port/netif.c +++ b/sys/src/kern/port/netif.c @@ -534,7 +534,7 @@ Lock netlock; static int netown(Netfile *p, char *o, int omode) { - static int access[] = { 0400, 0200, 0600, 0100 }; + static int access[] = { 0000, 0400, 0200, 0600, 0100, 0xff, 0xff, 0xff }; int mode; int t; diff --git a/sys/src/kern/port/portdat.h b/sys/src/kern/port/portdat.h index a3ebb85..d754110 100644 --- a/sys/src/kern/port/portdat.h +++ b/sys/src/kern/port/portdat.h @@ -72,7 +72,7 @@ typedef int Devgen(Chan*, char*, Dirtab*, int, int, Dir*); #pragma incomplete Queue #pragma incomplete Timers -#include +#include <9P2000.h> struct Ref { @@ -202,7 +202,7 @@ struct Chan int64_t devoffset; /* in underlying device; see read */ Dev* dev; uint32_t devno; - uint16_t mode; /* read/write */ + uint64_t mode; /* read/write */ uint16_t flag; Qid qid; int fid; /* for devmnt */ @@ -251,8 +251,8 @@ struct Dev Chan* (*attach)(Chan *c, Chan *ac, char *spec, int flags); Walkqid*(*walk)(Chan*, Chan*, char**, int); long (*stat)(Chan*, uint8_t*, long); - Chan* (*open)(Chan*, int); - Chan* (*create)(Chan*, char*, int, int); + Chan* (*open)(Chan*, unsigned long); + Chan* (*create)(Chan*, char*, unsigned long, unsigned long); void (*close)(Chan*); long (*read)(Chan*, void*, long, int64_t); Block* (*bread)(Chan*, long, int64_t); diff --git a/sys/src/kern/port/portfns.h b/sys/src/kern/port/portfns.h index 108e8b5..3537f52 100644 --- a/sys/src/kern/port/portfns.h +++ b/sys/src/kern/port/portfns.h @@ -90,12 +90,12 @@ long devbwrite(Chan*, Block*, int64_t); Dev* devbyname(char*); Chan* devclone(Chan*); int devconfig(int, char *, DevConf *); -Chan* devcreate(Chan*, char*, int, int); +Chan* devcreate(Chan*, char*, unsigned long, unsigned long); void devdir(Chan*, Qid, char*, int64_t, char*, long, Dir*); long devdirread(Chan*, char*, long, Dirtab*, int, Devgen*); Devgen devgen; void devinit(void); -Chan* devopen(Chan*, int, Dirtab*, int, Devgen*); +Chan* devopen(Chan*, unsigned long, Dirtab*, int, Devgen*); void devpermcheck(char*, int, int); void devpower(int); long devreadv(Chan*, IOchunk*, long, long, int64_t); @@ -133,7 +133,7 @@ uint64_t fastticks2us(uint64_t); uint64_t fastticks2ns(uint64_t); int fault(uintptr_t, uintptr_t, int); void fdclose(int, int); -Chan* fdtochan(int, int, int, int); +Chan* fdtochan(int, unsigned long, int, int); int findmount(Chan**, Mhead**, int, uint32_t, Qid); int fixfault(ProcSegment*, uintptr_t, int, int); void fmtinit(void); @@ -230,7 +230,7 @@ void notedefer(void); int nrand(int); uint64_t ns2fastticks(uint64_t); int okaddr(uintptr_t, long, int); -int openmode(int); +unsigned long openmode(unsigned long); int ownlock(Lock*); Block* packblock(Block*); Block* padblock(Block*, int); diff --git a/sys/src/kern/port/sysfile.c b/sys/src/kern/port/sysfile.c index 2388c2b..e5e45ee 100644 --- a/sys/src/kern/port/sysfile.c +++ b/sys/src/kern/port/sysfile.c @@ -134,7 +134,7 @@ newfd2(int fd[2], Chan *c[2]) } Chan* -fdtochan(int fd, int mode, int chkmnt, int iref) +fdtochan(int fd, unsigned long mode, int chkmnt, int iref) { Chan *c; Fgrp *f; @@ -157,16 +157,21 @@ fdtochan(int fd, int mode, int chkmnt, int iref) error(Ebadusefd); } - if(mode<0 || c->mode==ORDWR) + if(mode==~0 || c->mode==ORDWR) return c; + /* In Jehanne OTRUNC is not a "kernel reserved flag" (see libc.h): + * it's up to the server/device handing the request to ensure + * that OREAD|OTRUNC or any other combination produce an error... + * if((mode&OTRUNC) && c->mode==OREAD) { if(iref) cclose(c); error(Ebadusefd); } + */ - if((mode&~OTRUNC) != c->mode) { + if((mode&c->mode) != mode) { if(iref) cclose(c); error(Ebadusefd); @@ -175,14 +180,14 @@ fdtochan(int fd, int mode, int chkmnt, int iref) return c; } -int -openmode(int omode) +unsigned long +openmode(unsigned long omode) { - omode &= ~(OTRUNC|OCEXEC|ORCLOSE); - if(omode > OEXEC) + if((omode&OEXEC) && (omode&ORDWR)) error(Ebadarg); - if(omode == OEXEC) - return OREAD; + + if((omode&OKMODE) == OEXEC) + return (omode|OREAD)&~OEXEC; return omode; } @@ -291,7 +296,7 @@ sysopen(char *aname, uint32_t omode) nexterror(); } aname = validaddr(aname, 1, 0); - if((omode&OEXEC) == OSTAT) + if((omode&OKMODE) == OSTAT) c = namec(aname, Aaccess, 0, 0); else c = namec(aname, Aopen, omode, 0); @@ -937,7 +942,7 @@ syschdir(char *aname) */ static int dcok[] = { - 'M' + '9' }; static int checkdc(int dc) { diff --git a/sys/src/lib/9p/auth.c b/sys/src/lib/9p/auth.c index fe6cef7..9ecf418 100644 --- a/sys/src/lib/9p/auth.c +++ b/sys/src/lib/9p/auth.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/dirread.c b/sys/src/lib/9p/dirread.c index ce283bc..a313b3a 100644 --- a/sys/src/lib/9p/dirread.c +++ b/sys/src/lib/9p/dirread.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/fid.c b/sys/src/lib/9p/fid.c index 9ee6461..be80341 100644 --- a/sys/src/lib/9p/fid.c +++ b/sys/src/lib/9p/fid.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "9p.h" diff --git a/sys/src/lib/9p/file.c b/sys/src/lib/9p/file.c index effa2ff..c5931bc 100644 --- a/sys/src/lib/9p/file.c +++ b/sys/src/lib/9p/file.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/ftest.c b/sys/src/lib/9p/ftest.c index 6692b7f..f1c01df 100644 --- a/sys/src/lib/9p/ftest.c +++ b/sys/src/lib/9p/ftest.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include "9p.h" void diff --git a/sys/src/lib/9p/intmap.c b/sys/src/lib/9p/intmap.c index 991f4f1..4428e37 100644 --- a/sys/src/lib/9p/intmap.c +++ b/sys/src/lib/9p/intmap.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/listen.c b/sys/src/lib/9p/listen.c index afce495..c5f6fe3 100644 --- a/sys/src/lib/9p/listen.c +++ b/sys/src/lib/9p/listen.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/mem.c b/sys/src/lib/9p/mem.c index d5877c2..7c8c477 100644 --- a/sys/src/lib/9p/mem.c +++ b/sys/src/lib/9p/mem.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "9p.h" diff --git a/sys/src/lib/9p/parse.c b/sys/src/lib/9p/parse.c index fcd59c0..f084632 100644 --- a/sys/src/lib/9p/parse.c +++ b/sys/src/lib/9p/parse.c @@ -1,6 +1,6 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/post.c b/sys/src/lib/9p/post.c index 8abddfb..f8be9d9 100644 --- a/sys/src/lib/9p/post.c +++ b/sys/src/lib/9p/post.c @@ -1,6 +1,6 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> #include diff --git a/sys/src/lib/9p/queue.c b/sys/src/lib/9p/queue.c index e7a45f3..f557ea8 100644 --- a/sys/src/lib/9p/queue.c +++ b/sys/src/lib/9p/queue.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include <9p.h> static void diff --git a/sys/src/lib/9p/ramfs.c b/sys/src/lib/9p/ramfs.c index 989c4b5..ae52a47 100644 --- a/sys/src/lib/9p/ramfs.c +++ b/sys/src/lib/9p/ramfs.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> @@ -91,7 +91,7 @@ fsopen(Req *r) rf = r->fid->file->aux; - if(rf && (r->ifcall.mode&OTRUNC)){ + if(rf && (r->ifcall.mode&NP_OTRUNC)){ rf->ndata = 0; r->fid->file->length = 0; } diff --git a/sys/src/lib/9p/req.c b/sys/src/lib/9p/req.c index e819590..a3efd5b 100644 --- a/sys/src/lib/9p/req.c +++ b/sys/src/lib/9p/req.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/rfork.c b/sys/src/lib/9p/rfork.c index 45bf593..12493da 100644 --- a/sys/src/lib/9p/rfork.c +++ b/sys/src/lib/9p/rfork.c @@ -1,6 +1,6 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/srv.c b/sys/src/lib/9p/srv.c index 8377dd5..9937971 100644 --- a/sys/src/lib/9p/srv.c +++ b/sys/src/lib/9p/srv.c @@ -1,7 +1,24 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2016 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> @@ -23,6 +40,7 @@ static char Eperm[] = "permission denied"; static char Eunknownfid[] = "unknown fid"; static char Ebaddir[] = "bad directory in wstat"; static char Ewalknodir[] = "walk in non-directory"; +static char Etruncread[] = "truncate on read open"; static void setfcallerror(Fcall *f, char *err) @@ -98,7 +116,7 @@ if(chatty9p) if(chatty9p) if(r->error) fprint(2, "<-%d- %F: %s\n", s->infd, &r->ifcall, r->error); - else + else fprint(2, "<-%d- %F\n", s->infd, &r->ifcall); return r; @@ -392,31 +410,43 @@ sopen(Srv *srv, Req *r) respond(r, Ebotch); return; } - if((r->fid->qid.type&QTDIR) && (r->ifcall.mode&~ORCLOSE) != OREAD){ + if((r->fid->qid.type&QTDIR) && (r->ifcall.mode&~ORCLOSE) != NP_OREAD){ respond(r, Eisdir); return; } r->ofcall.qid = r->fid->qid; - switch(r->ifcall.mode&7){ + switch(r->ifcall.mode&3){ default: assert(0); - case OREAD: - p = AREAD; + case NP_OREAD: + p = AREAD; break; - case OWRITE: + case NP_OWRITE: p = AWRITE; break; - case ORDWR: + case NP_ORDWR: p = AREAD|AWRITE; break; - case OEXEC: - p = AEXEC; - break; - case OSTAT: - p = AEXIST; + case NP_OEXEC: + p = AEXEC; break; } - if(r->ifcall.mode&OTRUNC) + if(r->ifcall.mode&NP_OZEROES){ + /* According to http://man.cat-v.org/9front/5/open + * all bits in NP_ZEROES should be zero + */ + respond(r, Ebotch); + return; + } + if((r->ifcall.mode&NP_OTRUNC) && (r->ifcall.mode&NP_OREAD)){ + /* In Jehanne the kernel doesn't check OTRUNC invariants: + * it's up to the receiving server/device to ensure that + * a call to NP_OREAD|NP_OTRUNC will fail + */ + respond(r, Etruncread); + return; + } + if(r->ifcall.mode&NP_OTRUNC) p |= AWRITE; if((r->fid->qid.type&QTDIR) && p!=AREAD && p!=AEXIST){ respond(r, Eperm); @@ -427,7 +457,7 @@ sopen(Srv *srv, Req *r) respond(r, Eperm); return; } - if((r->ifcall.mode&ORCLOSE) && !dirwritable(r->fid)){ + if((r->ifcall.mode&NP_ORCLOSE) && !dirwritable(r->fid)){ respond(r, Eperm); return; } @@ -508,7 +538,7 @@ sread(Srv *srv, Req *r) r->rbuf = emalloc9p(r->ifcall.count); r->ofcall.data = r->rbuf; o = r->fid->omode & 7; - if(o != OREAD && o != ORDWR && o != OEXEC){ + if(o != NP_OREAD && o != NP_ORDWR && o != NP_OEXEC){ respond(r, Ebotch); return; } @@ -550,7 +580,7 @@ swrite(Srv *srv, Req *r) if(r->ifcall.count > srv->msize - IOHDRSZ) r->ifcall.count = srv->msize - IOHDRSZ; o = r->fid->omode & 7; - if(o != OWRITE && o != ORDWR){ + if(o != NP_OWRITE && o != NP_ORDWR){ snprint(e, sizeof e, "write on fid with open mode 0x%ux", r->fid->omode); respond(r, e); return; @@ -605,7 +635,7 @@ rremove(Req *r, char *error, char *errbuf) return; if(r->fid->file){ if(removefile(r->fid->file) < 0){ - snprint(errbuf, ERRMAX, "remove %s: %r", + snprint(errbuf, ERRMAX, "remove %s: %r", r->fid->file->name); r->error = errbuf; } @@ -632,8 +662,8 @@ sstat(Srv *srv, Req *r) if(r->d.muid) r->d.muid = estrdup9p(r->d.muid); } - if(srv->stat) - srv->stat(r); + if(srv->stat) + srv->stat(r); else if(r->fid->file) respond(r, nil); else @@ -728,7 +758,7 @@ srvwork(void *v) incref(&srv->rref); if(r->error){ respond(r, r->error); - continue; + continue; } qlock(&srv->slock); switch(r->ifcall.type){ @@ -908,7 +938,7 @@ void responderror(Req *r) { char errbuf[ERRMAX]; - + rerrstr(errbuf, sizeof errbuf); respond(r, errbuf); } diff --git a/sys/src/lib/9p/thread.c b/sys/src/lib/9p/thread.c index 445791b..ad0931d 100644 --- a/sys/src/lib/9p/thread.c +++ b/sys/src/lib/9p/thread.c @@ -1,6 +1,6 @@ #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/uid.c b/sys/src/lib/9p/uid.c index 4b7ee64..c892fdc 100644 --- a/sys/src/lib/9p/uid.c +++ b/sys/src/lib/9p/uid.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include <9p.h> diff --git a/sys/src/lib/9p/util.c b/sys/src/lib/9p/util.c index 2c24729..6ac79f5 100644 --- a/sys/src/lib/9p/util.c +++ b/sys/src/lib/9p/util.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include "9p.h" diff --git a/sys/src/lib/9p2000/convM2S.c b/sys/src/lib/9p2000/convM2S.c index 6b3eba2..2fe4e1e 100644 --- a/sys/src/lib/9p2000/convM2S.c +++ b/sys/src/lib/9p2000/convM2S.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> static uint8_t* diff --git a/sys/src/lib/9p2000/convS2M.c b/sys/src/lib/9p2000/convS2M.c index 4bb4ce0..b2b4160 100644 --- a/sys/src/lib/9p2000/convS2M.c +++ b/sys/src/lib/9p2000/convS2M.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> static uint8_t* diff --git a/sys/src/lib/9p2000/fcallfmt.c b/sys/src/lib/9p2000/fcallfmt.c index bf35f60..bf69778 100644 --- a/sys/src/lib/9p2000/fcallfmt.c +++ b/sys/src/lib/9p2000/fcallfmt.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> static uint32_t dumpsome(char*, char*, char*, int32_t); static void fdirconv(char*, char*, Dir*); diff --git a/sys/src/lib/9p2000/read9pmsg.c b/sys/src/lib/9p2000/read9pmsg.c index 87435c3..b1f8b45 100644 --- a/sys/src/lib/9p2000/read9pmsg.c +++ b/sys/src/lib/9p2000/read9pmsg.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> int read9pmsg(int fd, void *abuf, uint32_t n) diff --git a/sys/src/lib/auth/amount.c b/sys/src/lib/auth/amount.c index 694e772..5492a07 100644 --- a/sys/src/lib/auth/amount.c +++ b/sys/src/lib/auth/amount.c @@ -15,7 +15,7 @@ amount(int fd, char *mntpt, int flags, char *aname) if(ai != nil) auth_freeAI(ai); } - rv = mount(fd, afd, mntpt, flags, aname, 'M'); + rv = mount(fd, afd, mntpt, flags, aname, '9'); if(afd >= 0) close(afd); return rv; diff --git a/sys/src/lib/auth/auth_chuid.c b/sys/src/lib/auth/auth_chuid.c index 47745d4..dd7fb26 100644 --- a/sys/src/lib/auth/auth_chuid.c +++ b/sys/src/lib/auth/auth_chuid.c @@ -31,7 +31,7 @@ auth_chuid(AuthInfo *ai, char *ns) /* get a link to factotum as new user */ fd = open("/srv/factotum", ORDWR); if(fd >= 0) - mount(fd, -1, "/mnt", MREPL, "", 'M'); + mount(fd, -1, "/mnt", MREPL, "", '9'); /* set up new namespace */ return newns(ai->cuid, ns); diff --git a/sys/src/lib/auth/auth_proxy.c b/sys/src/lib/auth/auth_proxy.c index 8e0657d..3785293 100644 --- a/sys/src/lib/auth/auth_proxy.c +++ b/sys/src/lib/auth/auth_proxy.c @@ -1,6 +1,6 @@ #include #include -#include +#include <9P2000.h> #include #include "authlocal.h" diff --git a/sys/src/lib/auth/newns.c b/sys/src/lib/auth/newns.c index 4a41ac0..8d7ac32 100644 --- a/sys/src/lib/auth/newns.c +++ b/sys/src/lib/auth/newns.c @@ -134,7 +134,7 @@ famount(int fd, AuthRpc *rpc, char *mntpt, int flags, char *aname) if(ai != nil) auth_freeAI(ai); } - ret = mount(fd, afd, mntpt, flags, aname, 'M'); + ret = mount(fd, afd, mntpt, flags, aname, '9'); if(afd >= 0) close(afd); return ret; diff --git a/sys/src/lib/c/9sys/access.c b/sys/src/lib/c/9sys/access.c index 92723df..8a39b5f 100644 --- a/sys/src/lib/c/9sys/access.c +++ b/sys/src/lib/c/9sys/access.c @@ -15,16 +15,7 @@ access(const char *name, int mode) { int fd; Dir *db; - static char omode[] = { - 0, - OEXEC, - OWRITE, - ORDWR, - OREAD, - OEXEC, /* only approximate */ - ORDWR, - ORDWR /* only approximate */ - }; + mode &= AMASK; if(mode == AEXIST){ db = dirstat(name); @@ -33,7 +24,7 @@ access(const char *name, int mode) return 0; return -1; } - fd = open(name, omode[mode&7]); + fd = open(name, mode); if(fd >= 0){ close(fd); return 0; diff --git a/sys/src/lib/c/9sys/convD2M.c b/sys/src/lib/c/9sys/convD2M.c index a872a2a..66b3a17 100644 --- a/sys/src/lib/c/9sys/convD2M.c +++ b/sys/src/lib/c/9sys/convD2M.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> uint32_t sizeD2M(Dir *d) diff --git a/sys/src/lib/c/9sys/convM2D.c b/sys/src/lib/c/9sys/convM2D.c index 7e2432e..d2ae4bc 100644 --- a/sys/src/lib/c/9sys/convM2D.c +++ b/sys/src/lib/c/9sys/convM2D.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> int statcheck(uint8_t *buf, uint32_t nbuf) diff --git a/sys/src/lib/c/9sys/dirfstat.c b/sys/src/lib/c/9sys/dirfstat.c index 2f3eee4..9af440f 100644 --- a/sys/src/lib/c/9sys/dirfstat.c +++ b/sys/src/lib/c/9sys/dirfstat.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> enum { diff --git a/sys/src/lib/c/9sys/dirfwstat.c b/sys/src/lib/c/9sys/dirfwstat.c index 193a0d9..569bbda 100644 --- a/sys/src/lib/c/9sys/dirfwstat.c +++ b/sys/src/lib/c/9sys/dirfwstat.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> int dirfwstat(int fd, Dir *d) diff --git a/sys/src/lib/c/9sys/dirmodefmt.c b/sys/src/lib/c/9sys/dirmodefmt.c index 3d25d69..0f83f81 100644 --- a/sys/src/lib/c/9sys/dirmodefmt.c +++ b/sys/src/lib/c/9sys/dirmodefmt.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> static char *modes[] = { diff --git a/sys/src/lib/c/9sys/dirread.c b/sys/src/lib/c/9sys/dirread.c index 80a27fe..aad441d 100644 --- a/sys/src/lib/c/9sys/dirread.c +++ b/sys/src/lib/c/9sys/dirread.c @@ -9,7 +9,7 @@ #define PORTABLE_SYSCALLS #include #include -#include +#include <9P2000.h> static int32_t diff --git a/sys/src/lib/c/9sys/dirstat.c b/sys/src/lib/c/9sys/dirstat.c index 75116b7..2291264 100644 --- a/sys/src/lib/c/9sys/dirstat.c +++ b/sys/src/lib/c/9sys/dirstat.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> enum { diff --git a/sys/src/lib/c/9sys/dirwstat.c b/sys/src/lib/c/9sys/dirwstat.c index f6c19eb..90c8831 100644 --- a/sys/src/lib/c/9sys/dirwstat.c +++ b/sys/src/lib/c/9sys/dirwstat.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> int dirwstat(const char *name, Dir *d) diff --git a/sys/src/lib/c/9sys/wait.c b/sys/src/lib/c/9sys/wait.c index 3694901..b60a930 100644 --- a/sys/src/lib/c/9sys/wait.c +++ b/sys/src/lib/c/9sys/wait.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> Waitmsg* wait(void) diff --git a/sys/src/lib/c/9sys/waitpid.c b/sys/src/lib/c/9sys/waitpid.c index c96384a..95f9d6a 100644 --- a/sys/src/lib/c/9sys/waitpid.c +++ b/sys/src/lib/c/9sys/waitpid.c @@ -9,7 +9,7 @@ #include #include -#include +#include <9P2000.h> int waitpid(void) diff --git a/sys/src/lib/c/port/mktemp.c b/sys/src/lib/c/port/mktemp.c index 4aec614..b181359 100644 --- a/sys/src/lib/c/port/mktemp.c +++ b/sys/src/lib/c/port/mktemp.c @@ -29,7 +29,7 @@ mktemp(char *as) } s++; i = 'a'; - while(access(as, 0) != -1) { + while(access(as, AEXIST) != -1) { if (i == 'z') return "/"; *s = i++; diff --git a/sys/src/lib/disk/proto.c b/sys/src/lib/disk/proto.c index 6f08a01..fe3c987 100644 --- a/sys/src/lib/disk/proto.c +++ b/sys/src/lib/disk/proto.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include <9P2000.h> #include #include diff --git a/sys/src/lib/draw/newwindow.c b/sys/src/lib/draw/newwindow.c index 8fa38d2..40bb524 100644 --- a/sys/src/lib/draw/newwindow.c +++ b/sys/src/lib/draw/newwindow.c @@ -31,6 +31,6 @@ newwindow(char *str) snprint(buf, sizeof buf, "new %s", str); else strcpy(buf, "new"); - return mount(fd, -1, "/dev", MBEFORE, buf, 'M'); + return mount(fd, -1, "/dev", MBEFORE, buf, '9'); } diff --git a/sys/src/lib/ndb/dnsquery.c b/sys/src/lib/ndb/dnsquery.c index 54872d2..e0bbb67 100644 --- a/sys/src/lib/ndb/dnsquery.c +++ b/sys/src/lib/ndb/dnsquery.c @@ -50,7 +50,7 @@ dnsquery(char *net, char *val, char *type) fd = open(rip, ORDWR); if(fd < 0) return nil; - if(mount(fd, -1, net, MBEFORE, "", 'M') < 0){ + if(mount(fd, -1, net, MBEFORE, "", '9') < 0){ close(fd); return nil; } diff --git a/sys/src/lib/plumb/mesg.c b/sys/src/lib/plumb/mesg.c index 55d6195..2ca85ad 100644 --- a/sys/src/lib/plumb/mesg.c +++ b/sys/src/lib/plumb/mesg.c @@ -36,7 +36,7 @@ plumbopen(char *name, int omode) free(s); if(f < 0) return -1; - if(mount(f, -1, "/mnt/plumb", MREPL, "", 'M') < 0){ + if(mount(f, -1, "/mnt/plumb", MREPL, "", '9') < 0){ close(f); return -1; } diff --git a/sys/src/lib/stdio/tmpfile.c b/sys/src/lib/stdio/tmpfile.c index ef50439..bc462ba 100644 --- a/sys/src/lib/stdio/tmpfile.c +++ b/sys/src/lib/stdio/tmpfile.c @@ -32,7 +32,7 @@ FILE *tmpfile(void){ FILE *f; static char name[]="/tmp/tf0000000000000"; char *p; - while(access(name, 0)==0){ + while(access(name, AEXIST)==0){ p=name+7; while(*p=='9') *p++='0'; if(*p=='\0') return NULL; @@ -51,7 +51,7 @@ static void rmtmps(void) { int i; - + for(i=0; i