purge syscall macros

This commit is contained in:
Giacomo Tesio 2019-11-26 02:25:23 +01:00
parent 5f095a9605
commit f104c46858
427 changed files with 2938 additions and 2940 deletions

View File

@ -309,5 +309,3 @@
#define sizeD2M jehanne_sizeD2M
#define dirmodefmt jehanne_dirmodefmt
#define chartorune jehanne_chartorune
#define read(fd, buf, size) jehanne_pread(fd, buf, size, -1)
#define write(fd, buf, size) jehanne_pwrite(fd, buf, size, -1)

View File

@ -70,7 +70,7 @@ threadmain(int argc, char *argv[])
Display *d;
//
rfork(RFENVG|RFNAMEG);
sys_rfork(RFENVG|RFNAMEG);
ncol = -1;
@ -138,12 +138,12 @@ threadmain(int argc, char *argv[])
if(loadfile)
rowloadfonts(loadfile);
putenv("font", fontnames[0]);
snarffd = open("/dev/snarf", OREAD|OCEXEC);
snarffd = sys_open("/dev/snarf", OREAD|OCEXEC);
if(cputype){
sprint(buf, "/arch/%s/aux/acme", cputype);
bind(buf, "/cmd", MBEFORE);
sys_bind(buf, "/cmd", MBEFORE);
}
bind("/arch/rc/aux/acme", "/cmd", MBEFORE);
sys_bind("/arch/rc/aux/acme", "/cmd", MBEFORE);
getwd(wdir, sizeof wdir);
if(geninitdraw(nil, derror, fontnames[0], "acme", nil, Refnone) < 0){
@ -307,7 +307,7 @@ killprocs(void)
for(c=command; c; c=c->next)
postnote(PNGROUP, c->pid, "hangup");
remove(acmeerrorfile);
sys_remove(acmeerrorfile);
}
static int errorfd;
@ -320,7 +320,7 @@ acmeerrorproc(void *v)
threadsetname("acmeerrorproc");
buf = emalloc(8192+1);
while((n=read(errorfd, buf, 8192)) >= 0){
while((n=jehanne_read(errorfd, buf, 8192)) >= 0){
buf[n] = '\0';
sendp(cerr, estrdup(buf));
}
@ -337,21 +337,21 @@ acmeerrorinit(void)
sprint(acmeerrorfile, "/srv/acme.%s.%d", getuser(), mainpid);
fd = ocreate(acmeerrorfile, OWRITE, 0666);
if(fd < 0){
remove(acmeerrorfile);
sys_remove(acmeerrorfile);
fd = ocreate(acmeerrorfile, OWRITE, 0666);
if(fd < 0)
error("can't create acmeerror file");
}
sprint(buf, "%d", pfd[0]);
write(fd, buf, strlen(buf));
close(fd);
jehanne_write(fd, buf, strlen(buf));
sys_close(fd);
/* reopen pfd[1] close on exec */
sprint(buf, "/fd/%d", pfd[1]);
errorfd = open(buf, OREAD|OCEXEC);
errorfd = sys_open(buf, OREAD|OCEXEC);
if(errorfd < 0)
error("can't re-open acmeerror file");
close(pfd[1]);
close(pfd[0]);
sys_close(pfd[1]);
sys_close(pfd[0]);
proccreate(acmeerrorproc, nil, STACK);
}
@ -935,7 +935,7 @@ putsnarf(void)
return;
if(snarfbuf.nc > MAXSNARF)
return;
fd = open("/dev/snarf", OWRITE);
fd = sys_open("/dev/snarf", OWRITE);
if(fd < 0)
return;
for(i=0; i<snarfbuf.nc; i+=n){
@ -946,7 +946,7 @@ putsnarf(void)
if(fprint(fd, "%.*S", n, snarfrune) < 0)
break;
}
close(fd);
sys_close(fd);
}
void
@ -958,7 +958,7 @@ getsnarf()
return;
if(snarffd < 0)
return;
seek(snarffd, 0, 0);
sys_seek(snarffd, 0, 0);
bufreset(&snarfbuf);
bufload(&snarfbuf, 0, snarffd, &nulls);
}

View File

@ -11,8 +11,8 @@
#include <lib9.h>
/*
* like fprint but be sure to deliver as a single write.
* (fprint uses a small write buffer.)
* like fprint but be sure to deliver as a single jehanne_write.
* (fprint uses a small jehanne_write buffer.)
*/
void
xfprint(int fd, char *fmt, ...)
@ -25,7 +25,7 @@ xfprint(int fd, char *fmt, ...)
va_end(arg);
if(s == nil)
sysfatal("smprint: %r");
write(fd, s, strlen(s));
jehanne_write(fd, s, strlen(s));
free(s);
}
@ -35,7 +35,7 @@ main(int argc, char **argv)
int fd;
char dir[512];
fd = open("/dev/acme/ctl", OWRITE);
fd = sys_open("/dev/acme/ctl", OWRITE);
if(fd < 0)
exits(0);
getwd(dir, 512);

View File

@ -36,16 +36,16 @@ main(int argc, char *argv[])
else
snprint(wdir, sizeof wdir, "%s/-win", wdir);
if((fd = open("/dev/wnew", ORDWR)) < 0)
if((fd = sys_open("/dev/wnew", ORDWR)) < 0)
sysfatal("wnew: can't open /dev/wnew: %r");
if(fprint(fd, "%d %s", pid, wdir+dflag) < 0)
sysfatal("wnew: can't create window: %r");
if(seek(fd, 0, 0) != 0)
if(sys_seek(fd, 0, 0) != 0)
sysfatal("wnew: can't seek: %r");
if((n=read(fd, wdir, sizeof wdir-1)) < 0)
if((n=jehanne_read(fd, wdir, sizeof wdir-1)) < 0)
sysfatal("wnew: can't read window id: %r");
wdir[n] = '\0';

View File

@ -43,7 +43,7 @@ threadmain(int argc, char *argv[])
char buf[1024], **av;
quotefmtinstall();
rfork(RFNAMEG);
sys_rfork(RFNAMEG);
ARGBEGIN{
case 'd':
debug = 1;
@ -117,7 +117,7 @@ command(Window *w, char *s)
while(*s==' ' || *s=='\t' || *s=='\n')
s++;
if(strcmp(s, "Delete")==0 || strcmp(s, "Del")==0){
write(notepg, "hangup", 6);
jehanne_write(notepg, "hangup", 6);
windel(w, 1);
threadexitsall(nil);
return 1;
@ -247,7 +247,7 @@ _sendinput(Window *w, uint32_t q0, uint32_t *q1)
/* erase q0 to q0+n */
sprint(buf, "#%lud,#%lud", q0, q0+n);
winsetaddr(w, buf, 0);
write(w->data, buf, 0);
jehanne_write(w->data, buf, 0);
*q1 -= n;
return 0;
}
@ -309,20 +309,20 @@ sendit(char *s)
{
// char tmp[32];
write(win->body, s, strlen(s));
jehanne_write(win->body, s, strlen(s));
/*
* RSC: The problem here is that other procs can call sendit,
* so we lose our single-threadedness if we call sendinput.
* In fact, we don't even have the right queue memory,
* I think that we'll get a write event from the body write above,
* I think that we'll get a jehanne_write event from the body jehanne_write above,
* and we can do the sendinput then, from our single thread.
*
* I still need to figure out how to test this assertion for
* programs that use /srv/win*
*
winselect(win, "$", 0);
seek(win->addr, 0UL, 0);
if(read(win->addr, tmp, 2*12) == 2*12)
sys_seek(win->addr, 0UL, 0);
if(jehanne_read(win->addr, tmp, 2*12) == 2*12)
hostpt += sendinput(win, hostpt, atol(tmp), );
*/
}
@ -446,11 +446,11 @@ mainctl(void *v)
case 'S': /* output to stdout */
sprint(tmp, "#%lud", hostpt);
winsetaddr(w, tmp, 0);
write(w->data, e->b, e->nb);
jehanne_write(w->data, e->b, e->nb);
pendingS += e->nr;
break;
case 'E': /* write to tag or body; body happens due to sendit */
case 'E': /* jehanne_write to tag or body; body happens due to sendit */
delta = e->q1-e->q0;
if(e->c2=='I'){
endpt += delta;
@ -509,7 +509,7 @@ mainctl(void *v)
if(e->q0 < hostpt)
hostpt += delta;
if(e->nr>0 && e->r[e->nr-1]==0x7F){
write(notepg, "interrupt", 9);
jehanne_write(notepg, "interrupt", 9);
hostpt = endpt;
break;
}
@ -617,12 +617,12 @@ execproc(void *v)
Channel *cpid;
e = v;
rfork(RFCFDG|RFNOTEG);
sys_rfork(RFCFDG|RFNOTEG);
av = e->argv;
close(0);
open("/dev/cons", OREAD);
close(1);
open("/dev/cons", OWRITE);
sys_close(0);
sys_open("/dev/cons", OREAD);
sys_close(1);
sys_open("/dev/cons", OWRITE);
dup(1, 2);
cpid = e->cpid;
free(e);
@ -647,11 +647,11 @@ startcmd(char *argv[], int *notepg)
cpid = chancreate(sizeof(uint32_t), 0);
e->cpid = cpid;
sprint(buf, "/mnt/wsys/%d", win->id);
bind(buf, "/dev/acme", MREPL);
sys_bind(buf, "/dev/acme", MREPL);
proccreate(execproc, e, EXECSTACK);
do
pid = recvul(cpid);
while(pid == -1);
sprint(buf, "/proc/%d/notepg", pid);
*notepg = open(buf, OWRITE);
*notepg = sys_open(buf, OWRITE);
}

View File

@ -72,20 +72,20 @@ pipecommand(Window *w, char *s)
if(w->addr < 0)
w->addr = winopenfile(w, "addr");
ctlprint(w->ctl, "addr=dot\n");
seek(w->addr, 0UL, 0);
if(read(w->addr, tmp, 2*12) == 2*12){
sys_seek(w->addr, 0UL, 0);
if(jehanne_read(w->addr, tmp, 2*12) == 2*12){
q0 = atol(tmp+0*12);
q1 = atol(tmp+1*12);
if(q0 == q1){
t = nil;
k = 0;
if(snarffd > 0){
seek(0, snarffd, 0);
sys_seek(0, snarffd, 0);
for(;;){
t = realloc(t, k+8192+2);
if(t == nil)
error("alloc failed: %r\n");
n = read(snarffd, t+k, 8192);
n = jehanne_read(snarffd, t+k, 8192);
if(n <= 0)
break;
k += n;
@ -180,5 +180,5 @@ startpipe(void)
{
newpipechan = chancreate(sizeof(Window*), 0);
threadcreate(newpipethread, nil, STACK);
snarffd = open("/dev/snarf", OREAD|OCEXEC);
snarffd = sys_open("/dev/snarf", OREAD|OCEXEC);
}

View File

@ -20,8 +20,8 @@ newwindow(void)
Window *w;
w = emalloc(sizeof(Window));
w->ctl = open("/mnt/wsys/new/ctl", ORDWR|OCEXEC);
if(w->ctl<0 || read(w->ctl, buf, 12)!=12)
w->ctl = sys_open("/mnt/wsys/new/ctl", ORDWR|OCEXEC);
if(w->ctl<0 || jehanne_read(w->ctl, buf, 12)!=12)
error("can't open window ctl file: %r");
ctlprint(w->ctl, "noscroll\n");
w->id = atoi(buf);
@ -64,7 +64,7 @@ winopenfile(Window *w, char *f)
int fd;
sprint(buf, "/mnt/wsys/%d/%s", w->id, f);
fd = open(buf, ORDWR|OCEXEC);
fd = sys_open(buf, ORDWR|OCEXEC);
if(fd < 0)
error("can't open window file %s: %r", f);
return fd;
@ -76,9 +76,9 @@ wintagwrite(Window *w, char *s, int n)
int fd;
fd = winopenfile(w, "tag");
if(write(fd, s, n) != n)
error("tag write: %r");
close(fd);
if(jehanne_write(fd, s, n) != n)
error("tag jehanne_write: %r");
sys_close(fd);
}
void
@ -91,7 +91,7 @@ int
wingetec(Window *w)
{
if(w->nbuf == 0){
w->nbuf = read(w->event, w->buf, sizeof w->buf);
w->nbuf = jehanne_read(w->event, w->buf, sizeof w->buf);
if(w->nbuf <= 0){
/* probably because window has exited, and only called by wineventproc, so just shut down */
threadexits(nil);
@ -189,9 +189,9 @@ winread(Window *w, uint32_t q0, uint32_t q1, char *data)
nb = 0;
while(m < q1){
n = sprint(buf, "#%d", m);
if(write(w->addr, buf, n) != n)
if(jehanne_write(w->addr, buf, n) != n)
error("error writing addr: %r");
n = read(w->data, buf, sizeof buf);
n = jehanne_read(w->data, buf, sizeof buf);
if(n < 0)
error("reading data: %r");
nr = nrunes(buf, n);
@ -214,15 +214,15 @@ void
windormant(Window *w)
{
if(w->addr >= 0){
close(w->addr);
sys_close(w->addr);
w->addr = -1;
}
if(w->body >= 0){
close(w->body);
sys_close(w->body);
w->body = -1;
}
if(w->data >= 0){
close(w->data);
sys_close(w->data);
w->data = -1;
}
}
@ -231,14 +231,14 @@ int
windel(Window *w, int sure)
{
if(sure)
write(w->ctl, "delete\n", 7);
else if(write(w->ctl, "del\n", 4) != 4)
jehanne_write(w->ctl, "delete\n", 7);
else if(jehanne_write(w->ctl, "del\n", 4) != 4)
return 0;
/* event proc will die due to read error from event file */
windormant(w);
close(w->ctl);
sys_close(w->ctl);
w->ctl = -1;
close(w->event);
sys_close(w->event);
w->event = -1;
return 1;
}
@ -254,7 +254,7 @@ winsetaddr(Window *w, char *addr, int errok)
{
if(w->addr < 0)
w->addr = winopenfile(w, "addr");
if(write(w->addr, addr, strlen(addr)) < 0){
if(jehanne_write(w->addr, addr, strlen(addr)) < 0){
if(!errok)
error("error writing addr(%s): %r", addr);
return 0;

View File

@ -257,7 +257,7 @@ loadfile(int fd, uint32_t q0, int *nulls, int(*f)(void*, uint32_t, Rune*, int),
* last pass, possibly representing a partial rune.
*/
while(n > 0){
n = read(fd, p+m, Maxblock);
n = jehanne_read(fd, p+m, Maxblock);
if(n < 0){
warning(nil, "read error in Buffer.load");
break;

View File

@ -121,7 +121,7 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint32_t n)
b = disknewblock(d, n);
*bp = b;
}
if(pwrite(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
if(sys_pwrite(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
error("write error to temp file");
b->n = n;
}
@ -139,7 +139,7 @@ diskread(Disk *d, Block *b, Rune *r, uint32_t n)
n *= sizeof(Rune);
p = (char*)r;
for(tot = 0; tot < n; tot += nr){
nr = pread(d->fd, p+tot, n-tot, b->addr+tot);
nr = sys_pread(d->fd, p+tot, n-tot, b->addr+tot);
if(nr <= 0)
error("read error from temp file");
}

View File

@ -326,7 +326,7 @@ e_cmd(Text *t, Cmd *cp)
samename = runeeq(name, i, t->file->name, t->file->nname);
s = runetobyte(name, i);
free(name);
fd = open(s, OREAD);
fd = sys_open(s, OREAD);
if(fd < 0){
snprint(tmp, sizeof tmp, "can't open %s: %r", s);
free(s);
@ -336,7 +336,7 @@ e_cmd(Text *t, Cmd *cp)
isdir = (d!=nil && (d->qid.type&QTDIR));
free(d);
if(isdir){
close(fd);
sys_close(fd);
snprint(tmp, sizeof tmp, "%s is a directory", s);
free(s);
editerror(tmp);
@ -345,7 +345,7 @@ e_cmd(Text *t, Cmd *cp)
nulls = 0;
loadfile(fd, q1, &nulls, readloader, f);
free(s);
close(fd);
sys_close(fd);
if(nulls)
warning(nil, "%s: NUL bytes elided\n", s);
else if(allreplaced && samename)

View File

@ -616,7 +616,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
n = (BUFSIZE-1)/UTFmax;
bufread(f, q, r, n);
m = snprint(s, BUFSIZE, "%.*S", n, r);
if(write(fd, s, m) != m){
if(jehanne_write(fd, s, m) != m){
warning(nil, "can't write file %s: %r\n", name);
goto Rescue2;
}
@ -665,14 +665,14 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
free(d);
free(namer);
free(name);
close(fd);
sys_close(fd);
winsettag(w);
return;
Rescue2:
fbuffree(s);
fbuffree(r);
close(fd);
sys_close(fd);
/* fall through */
Rescue1:
@ -1267,7 +1267,7 @@ runproc(void *argvp)
if(activewin)
winid = activewin->id;
}
rfork(RFNAMEG|RFENVG|RFFDG|RFNOTEG);
sys_rfork(RFNAMEG|RFENVG|RFFDG|RFNOTEG);
sprint(buf, "%d", winid);
putenv("winid", buf);
@ -1280,13 +1280,13 @@ runproc(void *argvp)
fprint(2, "child: can't mount /dev/cons: %r\n");
threadexits("mount");
}
close(0);
sys_close(0);
if(winid>0 && (pipechar=='|' || pipechar=='>')){
sprint(buf, "/mnt/acme/%d/rdsel", winid);
open(buf, OREAD);
sys_open(buf, OREAD);
}else
open("/dev/null", OREAD);
close(1);
sys_open("/dev/null", OREAD);
sys_close(1);
if((winid>0 || iseditcmd) && (pipechar=='|' || pipechar=='<')){
if(iseditcmd){
if(winid > 0)
@ -1295,20 +1295,20 @@ runproc(void *argvp)
sprint(buf, "/mnt/acme/editout");
}else
sprint(buf, "/mnt/acme/%d/wrsel", winid);
open(buf, OWRITE);
close(2);
open("/dev/cons", OWRITE);
sys_open(buf, OWRITE);
sys_close(2);
sys_open("/dev/cons", OWRITE);
}else{
open("/dev/cons", OWRITE);
sys_open("/dev/cons", OWRITE);
dup(1, 2);
}
}else{
rfork(RFFDG|RFNOTEG);
sys_rfork(RFFDG|RFNOTEG);
fsysclose();
close(0);
open("/dev/null", OREAD);
close(1);
open(acmeerrorfile, OWRITE);
sys_close(0);
sys_open("/dev/null", OREAD);
sys_close(1);
sys_open(acmeerrorfile, OWRITE);
dup(1, 2);
}
@ -1437,7 +1437,7 @@ run(Window *win, char *s, Rune *rdir, int ndir, int newns,
arg[8] = cpid;
arg[9] = (void*)(uintptr_t)iseditcmd;
proccreate(runproc, arg, STACK);
/* mustn't block here because must be ready to answer mount() call in run() */
/* mustn't block here because must be ready to answer sys_mount() call in run() */
arg = emalloc(2*sizeof(void*));
arg[0] = c;
arg[1] = cpid;

View File

@ -135,15 +135,15 @@ fsysinit(void)
cfd = p[0];
sfd = p[1];
fmtinstall('F', fcallfmt);
clockfd = open("/dev/time", OREAD|OCEXEC);
fd = open("/dev/user", OREAD);
clockfd = sys_open("/dev/time", OREAD|OCEXEC);
fd = sys_open("/dev/user", OREAD);
if(fd >= 0){
n = read(fd, buf, sizeof buf-1);
n = jehanne_read(fd, buf, sizeof buf-1);
if(n > 0){
buf[n] = 0;
user = estrdup(buf);
}
close(fd);
sys_close(fd);
}
proccreate(fsysproc, nil, STACK);
}
@ -279,16 +279,16 @@ fsysmount(Rune *dir, int ndir, Rune **incl, int nincl)
Mntdir *m;
/* close server side so don't hang if acme is half-exited */
close(sfd);
sys_close(sfd);
m = fsysaddid(dir, ndir, incl, nincl);
sprint(buf, "%d", m->id);
if(mount(cfd, -1, "/mnt/acme", MREPL, buf, '9') < 0){
if(sys_mount(cfd, -1, "/mnt/acme", MREPL, buf, '9') < 0){
fsysdelid(m);
return nil;
}
close(cfd);
bind("/mnt/acme", "/mnt/wsys", MREPL);
if(bind("/mnt/acme", "/dev", MBEFORE) < 0){
sys_close(cfd);
sys_bind("/mnt/acme", "/mnt/wsys", MREPL);
if(sys_bind("/mnt/acme", "/dev", MBEFORE) < 0){
fsysdelid(m);
return nil;
}
@ -299,8 +299,8 @@ void
fsysclose(void)
{
closing = 1;
close(cfd);
close(sfd);
sys_close(cfd);
sys_close(sfd);
}
Xfid*
@ -320,7 +320,7 @@ respond(Xfid *x, Fcall *t, char *err)
n = convS2M(t, x->buf, messagesize);
if(n <= 0)
error("convert error in convS2M");
if(write(sfd, x->buf, n) != n)
if(jehanne_write(sfd, x->buf, n) != n)
error("write error in respond");
free(x->buf);
x->buf = nil;
@ -749,7 +749,7 @@ getclock()
char buf[32];
buf[0] = '\0';
pread(clockfd, buf, sizeof buf, 0);
sys_pread(clockfd, buf, sizeof buf, 0);
return atoi(buf);
}

View File

@ -431,7 +431,7 @@ rowdump(Row *row, char *file)
}
}
Bterm(b);
close(fd);
sys_close(fd);
free(b);
fbuffree(r);
@ -682,7 +682,7 @@ rowload(Row *row, char *file, int initing)
free(r);
Bterm(bout);
free(bout);
close(fd);
sys_close(fd);
goto Rescue2;
}
Bputrune(bout, rune);
@ -690,7 +690,7 @@ rowload(Row *row, char *file, int initing)
Bterm(bout);
free(bout);
textload(&w->body, 0, buf, 1);
close(fd);
sys_close(fd);
w->body.file->mod = TRUE;
for(n=0; n<w->body.file->ntext; n++)
w->body.file->text[n]->w->dirty = TRUE;

View File

@ -203,7 +203,7 @@ textload(Text *t, uint32_t q0, char *file, int setqid)
warning(nil, "empty directory name\n");
return 0;
}
fd = open(file, OREAD);
fd = sys_open(file, OREAD);
if(fd < 0){
warning(nil, "can't open %s: %r\n", file);
return 0;
@ -265,7 +265,7 @@ textload(Text *t, uint32_t q0, char *file, int setqid)
t->file->mtime = d->mtime;
t->file->qidpath = d->qid.path;
}
close(fd);
sys_close(fd);
rp = fbufalloc();
for(q=q0; q<q1; q+=n){
n = q1-q;
@ -296,7 +296,7 @@ textload(Text *t, uint32_t q0, char *file, int setqid)
return q1-q0;
Rescue:
close(fd);
sys_close(fd);
return 0;
}

View File

@ -52,7 +52,7 @@ timerproc(void*_)
uint32_t old, new;
threadsetname("timerproc");
rfork(RFFDG);
sys_rfork(RFFDG);
t = nil;
na = 0;
nt = 0;

View File

@ -60,7 +60,7 @@ void
error(char *s)
{
fprint(2, "acme: %s: %r\n", s);
remove(acmeerrorfile);
sys_remove(acmeerrorfile);
abort();
}

View File

@ -160,7 +160,7 @@ xfidopen(Xfid *x)
n = (BUFSIZE-1)/UTFmax;
bufread(t->file, q0, r, n);
m = snprint(s, BUFSIZE, "%.*S", n, r);
if(write(w->rdselfd, s, m) != m){
if(jehanne_write(w->rdselfd, s, m) != m){
warning(nil, "can't write temp file for pipe command %r\n");
break;
}
@ -244,7 +244,7 @@ xfidclose(Xfid *x)
}
break;
case QWrdsel:
close(w->rdselfd);
sys_close(w->rdselfd);
w->rdselfd = 0;
break;
case QWwrsel:
@ -355,12 +355,12 @@ xfidread(Xfid *x)
break;
case QWrdsel:
seek(w->rdselfd, off, 0);
sys_seek(w->rdselfd, off, 0);
n = x->count;
if(n > BUFSIZE)
n = BUFSIZE;
b = fbufalloc();
n = read(w->rdselfd, b, n);
n = jehanne_read(w->rdselfd, b, n);
if(n < 0){
respond(x, &fc, "I/O error in temp file");
break;

View File

@ -118,7 +118,7 @@ static int caphashfd;
void
initcap(void)
{
caphashfd = open("#¤/caphash", OCEXEC|OWRITE);
caphashfd = sys_open("#¤/caphash", OCEXEC|OWRITE);
if(caphashfd < 0)
fprint(2, "%s: opening #¤/caphash: %r\n", argv0);
}
@ -152,7 +152,7 @@ mkcap(char *from, char *to)
/* give the kernel the hash */
key[-1] = '@';
if(write(caphashfd, hash, SHA1dlen) < 0){
if(jehanne_write(caphashfd, hash, SHA1dlen) < 0){
free(cap);
return nil;
}
@ -165,11 +165,11 @@ usecap(char *cap)
{
int fd, rv;
fd = open("#¤/capuse", OWRITE);
fd = sys_open("#¤/capuse", OWRITE);
if(fd < 0)
return -1;
rv = write(fd, cap, strlen(cap));
close(fd);
rv = jehanne_write(fd, cap, strlen(cap));
sys_close(fd);
return rv;
}

View File

@ -49,7 +49,7 @@ main(int argc, char **argv)
fd = 0;
if(argc == 1){
if((fd = open(*argv, OREAD)) < 0)
if((fd = sys_open(*argv, OREAD)) < 0)
sysfatal("open %s: %r", *argv);
}
@ -59,7 +59,7 @@ main(int argc, char **argv)
buf = realloc(buf, tot+8192);
if(buf == nil)
sysfatal("realloc: %r");
if((n = read(fd, buf+tot, 8192)) < 0)
if((n = jehanne_read(fd, buf+tot, 8192)) < 0)
sysfatal("read: %r");
if(n == 0)
break;
@ -76,6 +76,6 @@ main(int argc, char **argv)
key->secret);
if(s == nil)
sysfatal("smprint: %r");
write(1, s, strlen(s));
jehanne_write(1, s, strlen(s));
exits(0);
}

View File

@ -55,7 +55,7 @@ main(int argc, char **argv)
else
file = "#d/0";
if((fd = open(file, OREAD)) < 0)
if((fd = sys_open(file, OREAD)) < 0)
sysfatal("open %s: %r", file);
buf = nil;
tot = 0;
@ -63,7 +63,7 @@ main(int argc, char **argv)
buf = realloc(buf, tot+8192);
if(buf == nil)
sysfatal("realloc: %r");
if((n = read(fd, buf+tot, 8192)) < 0)
if((n = jehanne_read(fd, buf+tot, 8192)) < 0)
sysfatal("read: %r");
if(n == 0)
break;
@ -81,6 +81,6 @@ main(int argc, char **argv)
key->kp, key->kq, key->c2);
if(s == nil)
sysfatal("smprint: %r");
write(1, s, strlen(s));
jehanne_write(1, s, strlen(s));
exits(0);
}

View File

@ -85,7 +85,7 @@ main(int argc, char *argv[])
if(argc >= 1)
getraddr(argv[argc-1]);
alarm(10*60*1000); /* kill a connection after 10 minutes */
sys_alarm(10*60*1000); /* kill a connection after 10 minutes */
private();
initkeyseed();
@ -151,7 +151,7 @@ pak1(char *u, Keyslot *k)
authpak_hash(k, k->id);
}
authpak_new(&p, k, y, 0);
if(write(1, y, PAKYLEN) != PAKYLEN)
if(jehanne_write(1, y, PAKYLEN) != PAKYLEN)
exits(0);
if(readn(0, y, PAKYLEN) != PAKYLEN)
exits(0);
@ -164,7 +164,7 @@ pak(Ticketreq *tr)
{
static uint8_t ok[1] = {AuthOK};
if(write(1, ok, 1) != 1)
if(jehanne_write(1, ok, 1) != 1)
exits(0);
/* invalidate pak keys */
@ -235,7 +235,7 @@ ticketrequest(Ticketreq *tr)
n += convT2M(&t, tbuf+n, sizeof(tbuf)-n, &hkey);
t.num = AuthTs;
n += convT2M(&t, tbuf+n, sizeof(tbuf)-n, &akey);
if(write(1, tbuf, n) != n)
if(jehanne_write(1, tbuf, n) != n)
exits(0);
syslog(0, AUTHLOG, "tr-ok %s@%s(%s) -> %s@%s", tr->uid, tr->hostid, raddr, tr->uid, tr->authid);
@ -272,7 +272,7 @@ challengebox(Ticketreq *tr)
buf[0] = AuthOK;
chal = nfastrand(MAXNETCHAL);
sprint(buf+1, "%lud", chal);
if(write(1, buf, NETCHLEN+1) != NETCHLEN+1)
if(jehanne_write(1, buf, NETCHLEN+1) != NETCHLEN+1)
exits(0);
if(readn(0, buf, NETCHLEN) != NETCHLEN)
exits(0);
@ -314,7 +314,7 @@ changepasswd(Ticketreq *tr)
n = 0;
tbuf[n++] = AuthOK;
n += convT2M(&t, tbuf+n, sizeof(tbuf)-n, &ukey);
if(write(1, tbuf, n) != n)
if(jehanne_write(1, tbuf, n) != n)
exits(0);
/* loop trying passwords out */
@ -363,7 +363,7 @@ changepasswd(Ticketreq *tr)
succeed(tr->uid);
prbuf[0] = AuthOK;
if(write(1, prbuf, 1) != 1)
if(jehanne_write(1, prbuf, 1) != 1)
exits(0);
}
@ -540,7 +540,7 @@ vnc(Ticketreq *tr)
genrandom(chal+6, VNCchallen);
chal[0] = AuthOKvar;
sprint((char*)chal+1, "%-5d", VNCchallen);
if(write(1, chal, sizeof(chal)) != sizeof(chal))
if(jehanne_write(1, chal, sizeof(chal)) != sizeof(chal))
exits(0);
/*
@ -596,7 +596,7 @@ chap(Ticketreq *tr)
* Create a challenge and send it.
*/
genrandom((uint8_t*)chal, sizeof(chal));
if(write(1, chal, sizeof(chal)) != sizeof(chal))
if(jehanne_write(1, chal, sizeof(chal)) != sizeof(chal))
exits(0);
/*
@ -701,7 +701,7 @@ mschap(Ticketreq *tr)
* Create a challenge and send it.
*/
genrandom(chal, sizeof(chal));
if(write(1, chal, sizeof(chal)) != sizeof(chal))
if(jehanne_write(1, chal, sizeof(chal)) != sizeof(chal))
exits(0);
/*
@ -838,7 +838,7 @@ mschap(Ticketreq *tr)
sha1(hash2, 16, 0, s);
sha1(chal, 8, digest, s);
if(write(1, digest, 16) != 16)
if(jehanne_write(1, digest, 16) != 16)
exits(0);
}
@ -990,7 +990,7 @@ replyerror(char *fmt, ...)
va_end(arg);
buf[AERRLEN] = 0;
buf[0] = AuthErr;
write(1, buf, AERRLEN+1);
jehanne_write(1, buf, AERRLEN+1);
syslog(0, AUTHLOG, buf+1);
}
@ -1080,7 +1080,7 @@ tickauthreply(Ticketreq *tr, Authkey *key)
genrandom(a.rand, NONCELEN);
a.num = AuthAc;
n += convA2M(&a, buf+n, sizeof(buf)-n, &t);
if(write(1, buf, n) != n)
if(jehanne_write(1, buf, n) != n)
exits(0);
}

View File

@ -41,7 +41,7 @@ main(int argc, char **argv)
if(argc != 1)
usage();
if((afd = open("/mnt/factotum/rpc", ORDWR)) < 0)
if((afd = sys_open("/mnt/factotum/rpc", ORDWR)) < 0)
sysfatal("open /mnt/factotum/rpc: %r");
rpc = auth_allocrpc(afd);
@ -53,14 +53,14 @@ main(int argc, char **argv)
print("challenge: %s\n", c->chal);
print("user:");
n = read(0, bufu, sizeof bufu);
n = jehanne_read(0, bufu, sizeof bufu);
if(n > 0){
bufu[n-1] = '\0';
c->user = bufu;
}
print("response: ");
n = read(0, buf, sizeof buf);
n = jehanne_read(0, buf, sizeof buf);
if(n < 0)
sysfatal("read: %r");
if(n == 0)

View File

@ -123,10 +123,10 @@ install(char *db, char *u, Authkey *key, int32_t t, int newkey)
if(!exists(db, u)){
sprint(buf, "%s/%s", db, u);
fd = create(buf, OREAD, 0777|DMDIR);
fd = sys_create(buf, OREAD, 0777|DMDIR);
if(fd < 0)
error("can't create user %s: %r", u);
close(fd);
sys_close(fd);
}
if(newkey){
@ -137,10 +137,10 @@ install(char *db, char *u, Authkey *key, int32_t t, int newkey)
if(t == -1)
return;
sprint(buf, "%s/%s/expire", db, u);
fd = open(buf, OWRITE);
fd = sys_open(buf, OWRITE);
if(fd < 0 || fprint(fd, "%ld", t) < 0)
error("can't write expiration time");
close(fd);
sys_close(fd);
}
int

View File

@ -72,7 +72,7 @@ main(int argc, char *argv[])
getpass(&nkey, nil, 0, 1);
}
fd = open(file, ORDWR);
fd = sys_open(file, ORDWR);
if(fd < 0)
error("can't open %s: %r\n", file);
d = dirfstat(fd);
@ -82,12 +82,12 @@ main(int argc, char *argv[])
p = malloc(len);
if(p == nil)
error("out of memory");
if(read(fd, p, len) != len)
if(jehanne_read(fd, p, len) != len)
error("can't read key file: %r\n");
len = convert(&p, len);
if(pwrite(fd, p, len, 0) != len)
if(sys_pwrite(fd, p, len, 0) != len)
error("can't write key file: %r\n");
close(fd);
sys_close(fd);
exits(nil);
}

View File

@ -153,7 +153,7 @@ mklock(char *file)
free(dir);
/* reopen in case it wasn't a lock file at last open */
close(fd);
sys_close(fd);
}
for (try = 0; try < 65 && (fd = openlock(file)) < 0; try++)
sleep(10*1000);
@ -244,8 +244,8 @@ main(int argc, char *argv[])
&& j->time.mon & t.mon)
rexec(&users[i], j);
}
seek(lock, 0, 0);
write(lock, "x", 1); /* keep the lock alive */
sys_seek(lock, 0, 0);
jehanne_write(lock, "x", 1); /* keep the lock alive */
/*
* if we're not at next minute yet, sleep until a second past
* (to allow for sleep intervals being approximate),
@ -265,13 +265,13 @@ createuser(void)
user = getuser();
snprint(file, sizeof file, "/cron/%s", user);
fd = create(file, OREAD, 0755|DMDIR);
fd = sys_create(file, OREAD, 0755|DMDIR);
if(fd < 0)
fatal("couldn't create %s: %r", file);
nulldir(&d);
d.gid = user;
dirfwstat(fd, &d);
close(fd);
sys_close(fd);
snprint(file, sizeof file, "/cron/%s/cron", user);
fd = ocreate(file, OREAD, 0644);
if(fd < 0)
@ -279,7 +279,7 @@ createuser(void)
nulldir(&d);
d.gid = user;
dirfwstat(fd, &d);
close(fd);
sys_close(fd);
}
void
@ -290,7 +290,7 @@ readalljobs(void)
char file[128];
int i, n, fd;
fd = open("/cron", OREAD);
fd = sys_open("/cron", OREAD);
if(fd < 0)
fatal("can't open /cron: %r");
while((n = dirread(fd, &d)) > 0){
@ -314,7 +314,7 @@ readalljobs(void)
}
free(d);
}
close(fd);
sys_close(fd);
}
/*
@ -441,7 +441,7 @@ getname(char **namep)
*namep = strdup(buf);
if(*namep == 0){
clog("internal error: strdup failure");
_exits(0);
sys__exits(0);
}
while(*savec == ' ' || *savec == '\t')
savec++;