decouple Jehanne from 9P2000 (as much as needed)

Jehanne is going to use a new file protocol, but Plan 9 is really
coupled with 9P2000.

Renamed fcall.h as 9P2000.h and introduced specific constants such
as NP_OREAD, NP_OWRITE and so on, so that we can use different values
in the kernel and new protocol.

Renamed devmnt to devninep, since it's actually a device serving 9P2000
file systems.

Also, fixed 9P2000 support in Jehanne, that was broken with the introduction
of OSTAT.
This commit is contained in:
Giacomo Tesio 2016-12-01 00:09:42 +01:00
parent bbb375a585
commit f52a185030
199 changed files with 649 additions and 512 deletions

View File

@ -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){

View File

@ -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 */
};

View File

@ -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 */

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#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();

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -9,7 +9,7 @@
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9P2000.h>
#include <thread.h>
#include <9p.h>
#include "dat.h"

View File

@ -11,7 +11,7 @@
#include <libc.h>
#include <bio.h>
#include <thread.h>
#include <fcall.h>
#include <9P2000.h>
#include <9p.h>
#include <ctype.h>
#include "dat.h"

View File

@ -9,7 +9,7 @@
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9P2000.h>
#include <thread.h>
#include <9p.h>
#include "dat.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "edit.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "edit.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#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);

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#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;
}

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#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;

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <plumb.h>
#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,

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include <complete.h>
#include "dat.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -15,7 +15,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -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;
}

View File

@ -6,7 +6,7 @@
#include <libsec.h>
#include <String.h>
#include <thread.h> /* only for 9p.h */
#include <fcall.h>
#include <9P2000.h>
#include <9p.h>
#pragma varargck type "N" Attr*

View File

@ -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;
}

View File

@ -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);
}

View File

@ -3,7 +3,7 @@
*/
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <ndb.h>
#include <libsec.h>

View File

@ -5,7 +5,7 @@
#include <libc.h>
#include <ctype.h>
#include <authsrv.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <mp.h>
#include <libsec.h>
@ -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";

View File

@ -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 */

View File

@ -1,3 +1,4 @@
#define PORTABLE_SYSCALLS
#include <u.h>
#include <libc.h>
#include <mp.h>

View File

@ -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 <u.h>
#include <libc.h>
#include <mp.h>

View File

@ -1,4 +1,5 @@
/* secstore - network login client */
#define PORTABLE_SYSCALLS
#include <u.h>
#include <libc.h>
#include <mp.h>

View File

@ -1,4 +1,5 @@
/* secstored - secure store daemon */
#define PORTABLE_SYSCALLS
#include <u.h>
#include <libc.h>
#include <bio.h>

View File

@ -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]);

View File

@ -18,7 +18,7 @@
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <libsec.h>
#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;

View File

@ -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");

View File

@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <mp.h>
#include <libsec.h>
@ -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)

View File

@ -10,7 +10,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#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

View File

@ -11,7 +11,7 @@
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include "iotrack.h"
#include "dat.h"
#include "fns.h"

View File

@ -10,7 +10,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include "iotrack.h"
#include "dat.h"
#include "dosfs.h"

View File

@ -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++;

View File

@ -13,7 +13,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <libsec.h>
#include "exportfs.h"

View File

@ -10,7 +10,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#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);

View File

@ -9,7 +9,7 @@
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <regexp.h>
#include "exportfs.h"

View File

@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <fcall.h>
#include <9P2000.h>
#include <9p.h>
#include "dat.h"
#include "fns.h"

View File

@ -1,5 +1,6 @@
#include <u.h>
#include <libc.h>
#include <9P2000.h>
#include <thread.h>
#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);
}

View File

@ -1,6 +1,7 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <9P2000.h>
#include <bio.h>
#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;
}

View File

@ -1,6 +1,7 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
#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;

View File

@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <fcall.h>
#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);

View File

@ -1,13 +1,13 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <fcall.h>
#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)

View File

@ -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);
}

View File

@ -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 {

View File

@ -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);
}

View File

@ -17,7 +17,7 @@
*/
#include <u.h>
#include <libc.h>
#include <fcall.h>
#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];
}

View File

@ -17,7 +17,7 @@
*/
#include <u.h>
#include <libc.h>
#include <fcall.h>
#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:

View File

@ -5,7 +5,7 @@
/* for fs */
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <thread.h>
#include <9p.h>

View File

@ -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);

View File

@ -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;
}

View File

@ -11,7 +11,7 @@
#include <libc.h>
#include <ctype.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <draw.h>
#include <event.h>
#include <ip.h>

View File

@ -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);
}

View File

@ -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");

View File

@ -11,7 +11,7 @@
#include <libc.h>
#include <bio.h>
#include <ndb.h>
#include <fcall.h>
#include <9P2000.h>
enum
{

View File

@ -10,7 +10,7 @@
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <fcall.h>
#include <9P2000.h>
typedef struct NDir NDir;
struct NDir

View File

@ -9,7 +9,7 @@
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9P2000.h>
#include <thread.h>
#include <9p.h>
#include <mp.h>
@ -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);

View File

@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <ctype.h>
#include <ndb.h>
@ -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);
}

View File

@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#include <bio.h>
#include <ip.h>
#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);
}

View File

@ -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)

View File

@ -11,7 +11,7 @@
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include <fcall.h>
#include <9P2000.h>
#pragma varargck type "P" char*

View File

@ -10,7 +10,7 @@
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#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){

View File

@ -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){

View File

@ -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;

View File

@ -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);

View File

@ -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; r<nwaitpids; r++)
if(waitpids[r] != pid)
waitpids[w++] = waitpids[r];

View File

@ -189,7 +189,7 @@ mkenv(void)
}
*ep = 0;
qsort((void *)env, nvar, sizeof ep[0], cmpenv);
return env;
return env;
}
char *sigmsg[] = {
/* 0 normal */ 0,
@ -448,7 +448,7 @@ int32_t cnt;
Executable(file)
char *file;
{
return(access(file, 01)==0);
return(access(file, AEXEC)==0);
}
Creat(file)
char *file;
@ -512,7 +512,7 @@ execumask(void) /* wrong -- should fork before writing */
case 2:
umask(octal(runq->argv->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<nwaitpids; r++)
if(waitpids[r] != pid)
waitpids[w++] = waitpids[r];

View File

@ -259,7 +259,7 @@ fprint(2, "forkexec %s", file);
for(i = 0; argv[i]; i++)fprint(2, " %s", argv[i]);
fprint(2, " %d %d %d\n", sin, sout, serr);
}
if(access(file, 1) != 0)
if(access(file, AEXEC) != 0)
return -1;
fprint(2, "forking\n");
switch(pid = fork()){
@ -375,7 +375,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
@ -395,7 +395,7 @@ Again:
n = trimdirs(dir[f].dbuf, n);
if(n == 0)
goto Again;
}
}
dir[f].n = n;
}else
dir[f].n = 0;

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include "dat.h"
#include "fns.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#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;

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include "dat.h"
#include "fns.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include "dat.h"
#include "fns.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include "dat.h"
#include "fns.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include "dat.h"
#include "fns.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#include <complete.h>
#include "dat.h"

View File

@ -6,7 +6,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <9P2000.h>
#include <plumb.h>
#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;

View File

@ -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)

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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')

View File

@ -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]);

View File

@ -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);

View File

@ -10,7 +10,7 @@
#include <u.h>
#include <libc.h>
//#include <sys.h>
#include <fcall.h>
#include <9P2000.h>
char buf[1048576];
#define NARG 5

View File

@ -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);

View File

@ -9,7 +9,7 @@
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include <fcall.h> /* for %M */
#include <9P2000.h> /* for %M */
#include <String.h>
/*

View File

@ -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);

View File

@ -1,6 +1,6 @@
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9P2000.h>
#include <thread.h>
#include <9p.h>
#include "usb.h"

View File

@ -7,7 +7,7 @@
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include <fcall.h>
#include <9P2000.h>
#include <thread.h>
#include <9p.h>
#include "scsireq.h"

Some files were not shown because too many files have changed in this diff Show More