merge
This commit is contained in:
commit
b3c9249500
28 changed files with 87 additions and 88 deletions
|
@ -118,37 +118,27 @@ cexecpipe(int *p0, int *p1)
|
||||||
Filsys*
|
Filsys*
|
||||||
filsysinit(Channel *cxfidalloc)
|
filsysinit(Channel *cxfidalloc)
|
||||||
{
|
{
|
||||||
int n, fd, pid, p0;
|
int p0;
|
||||||
Filsys *fs;
|
Filsys *fs;
|
||||||
Channel *c;
|
Channel *c;
|
||||||
char buf[128];
|
|
||||||
|
|
||||||
fs = emalloc(sizeof(Filsys));
|
fs = emalloc(sizeof(Filsys));
|
||||||
if(cexecpipe(&fs->cfd, &fs->sfd) < 0)
|
if(cexecpipe(&fs->cfd, &fs->sfd) < 0)
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
fmtinstall('F', fcallfmt);
|
fmtinstall('F', fcallfmt);
|
||||||
clockfd = open("/dev/time", OREAD|OCEXEC);
|
clockfd = open("/dev/time", OREAD|OCEXEC);
|
||||||
fd = open("/dev/user", OREAD);
|
fs->user = getuser();
|
||||||
strcpy(buf, "Jean-Paul_Belmondo");
|
|
||||||
if(fd >= 0){
|
|
||||||
n = read(fd, buf, sizeof buf-1);
|
|
||||||
if(n > 0)
|
|
||||||
buf[n] = 0;
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
fs->user = estrdup(buf);
|
|
||||||
fs->csyncflush = chancreate(sizeof(int), 0);
|
fs->csyncflush = chancreate(sizeof(int), 0);
|
||||||
if(fs->csyncflush == nil)
|
if(fs->csyncflush == nil)
|
||||||
error("chancreate syncflush");
|
error("chancreate syncflush");
|
||||||
fs->cxfidalloc = cxfidalloc;
|
fs->cxfidalloc = cxfidalloc;
|
||||||
pid = getpid();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create and post wctl pipe
|
* Create and post wctl pipe
|
||||||
*/
|
*/
|
||||||
if(cexecpipe(&p0, &wctlfd) < 0)
|
if(cexecpipe(&p0, &wctlfd) < 0)
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
snprint(srvwctl, sizeof(srvwctl), "/srv/riowctl.%s.%d", fs->user, pid);
|
snprint(srvwctl, sizeof(srvwctl), "/srv/riowctl.%s.%lud", fs->user, (ulong)getpid());
|
||||||
post(srvwctl, "wctl", p0);
|
post(srvwctl, "wctl", p0);
|
||||||
close(p0);
|
close(p0);
|
||||||
|
|
||||||
|
@ -165,7 +155,7 @@ filsysinit(Channel *cxfidalloc)
|
||||||
/*
|
/*
|
||||||
* Post srv pipe
|
* Post srv pipe
|
||||||
*/
|
*/
|
||||||
snprint(srvpipe, sizeof(srvpipe), "/srv/rio.%s.%d", fs->user, pid);
|
snprint(srvpipe, sizeof(srvpipe), "/srv/rio.%s.%lud", fs->user, (ulong)getpid());
|
||||||
post(srvpipe, "wsys", fs->cfd);
|
post(srvpipe, "wsys", fs->cfd);
|
||||||
|
|
||||||
return fs;
|
return fs;
|
||||||
|
@ -234,7 +224,7 @@ filsysmount(Filsys *fs, int id)
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
close(fs->sfd); /* close server end so mount won't hang if exiting */
|
close(fs->sfd); /* close server end so mount won't hang if exiting */
|
||||||
sprint(buf, "%d", id);
|
snprint(buf, sizeof buf, "%d", id);
|
||||||
if(mount(fs->cfd, -1, "/mnt/wsys", MREPL, buf) == -1){
|
if(mount(fs->cfd, -1, "/mnt/wsys", MREPL, buf) == -1){
|
||||||
fprint(2, "mount failed: %r\n");
|
fprint(2, "mount failed: %r\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -244,7 +244,7 @@ putsnarf(void)
|
||||||
|
|
||||||
if(snarffd<0 || nsnarf==0)
|
if(snarffd<0 || nsnarf==0)
|
||||||
return;
|
return;
|
||||||
fd = open("/dev/snarf", OWRITE);
|
fd = open("/dev/snarf", OWRITE|OCEXEC);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
/* snarf buffer could be huge, so fprint will truncate; do it in blocks */
|
/* snarf buffer could be huge, so fprint will truncate; do it in blocks */
|
||||||
|
|
|
@ -1420,7 +1420,7 @@ wclosewin(Window *w)
|
||||||
void
|
void
|
||||||
wsetpid(Window *w, int pid, int dolabel)
|
wsetpid(Window *w, int pid, int dolabel)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[32];
|
||||||
int ofd;
|
int ofd;
|
||||||
|
|
||||||
ofd = w->notefd;
|
ofd = w->notefd;
|
||||||
|
@ -1428,11 +1428,11 @@ wsetpid(Window *w, int pid, int dolabel)
|
||||||
w->notefd = -1;
|
w->notefd = -1;
|
||||||
else {
|
else {
|
||||||
if(dolabel){
|
if(dolabel){
|
||||||
snprint(buf, sizeof(buf), "rc %d", pid);
|
snprint(buf, sizeof(buf), "rc %lud", (ulong)pid);
|
||||||
free(w->label);
|
free(w->label);
|
||||||
w->label = estrdup(buf);
|
w->label = estrdup(buf);
|
||||||
}
|
}
|
||||||
snprint(buf, sizeof(buf), "/proc/%d/notepg", pid);
|
snprint(buf, sizeof(buf), "/proc/%lud/notepg", (ulong)pid);
|
||||||
w->notefd = open(buf, OWRITE|OCEXEC);
|
w->notefd = open(buf, OWRITE|OCEXEC);
|
||||||
}
|
}
|
||||||
if(ofd >= 0)
|
if(ofd >= 0)
|
||||||
|
|
|
@ -24,7 +24,7 @@ access(char *name, int mode)
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = open(name, omode[mode&7]);
|
fd = open(name, omode[mode&7]|OCEXEC);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -18,7 +18,8 @@ getenv(char *name)
|
||||||
snprint(s, HUNK, "/env/%s", name);
|
snprint(s, HUNK, "/env/%s", name);
|
||||||
n = 0;
|
n = 0;
|
||||||
r = -1;
|
r = -1;
|
||||||
if((f = open(s, OREAD)) >= 0){
|
f = open(s, OREAD|OCEXEC);
|
||||||
|
if(f >= 0){
|
||||||
while((r = read(f, s+n, HUNK)) > 0){
|
while((r = read(f, s+n, HUNK)) > 0){
|
||||||
n += r;
|
n += r;
|
||||||
r = -1;
|
r = -1;
|
||||||
|
|
|
@ -13,7 +13,7 @@ getendpoint(char *dir, char *file, char **sysp, char **servp)
|
||||||
sys = serv = 0;
|
sys = serv = 0;
|
||||||
|
|
||||||
snprint(buf, sizeof buf, "%s/%s", dir, file);
|
snprint(buf, sizeof buf, "%s/%s", dir, file);
|
||||||
fd = open(buf, OREAD);
|
fd = open(buf, OREAD|OCEXEC);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
n = read(fd, buf, sizeof(buf)-1);
|
n = read(fd, buf, sizeof(buf)-1);
|
||||||
if(n>0){
|
if(n>0){
|
||||||
|
@ -41,7 +41,6 @@ getnetconninfo(char *dir, int fd)
|
||||||
NetConnInfo *nci;
|
NetConnInfo *nci;
|
||||||
char *cp;
|
char *cp;
|
||||||
Dir *d;
|
Dir *d;
|
||||||
char spec[10];
|
|
||||||
char path[128];
|
char path[128];
|
||||||
char netname[128], *p;
|
char netname[128], *p;
|
||||||
|
|
||||||
|
@ -76,10 +75,8 @@ getnetconninfo(char *dir, int fd)
|
||||||
|
|
||||||
/* figure out bind spec */
|
/* figure out bind spec */
|
||||||
d = dirstat(nci->dir);
|
d = dirstat(nci->dir);
|
||||||
if(d != nil){
|
if(d != nil)
|
||||||
sprint(spec, "#%C%d", d->type, d->dev);
|
nci->spec = smprint("#%C%d", d->type, d->dev);
|
||||||
nci->spec = strdup(spec);
|
|
||||||
}
|
|
||||||
if(nci->spec == nil)
|
if(nci->spec == nil)
|
||||||
nci->spec = unknown;
|
nci->spec = unknown;
|
||||||
free(d);
|
free(d);
|
||||||
|
|
|
@ -8,7 +8,7 @@ getppid(void)
|
||||||
int f;
|
int f;
|
||||||
|
|
||||||
memset(b, 0, sizeof(b));
|
memset(b, 0, sizeof(b));
|
||||||
f = open("/dev/ppid", 0);
|
f = open("/dev/ppid", OREAD|OCEXEC);
|
||||||
if(f >= 0) {
|
if(f >= 0) {
|
||||||
read(f, b, sizeof(b));
|
read(f, b, sizeof(b));
|
||||||
close(f);
|
close(f);
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
|
||||||
static char *nsgetwd(char*, int);
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
getwd(char *buf, int nbuf)
|
getwd(char *buf, int nbuf)
|
||||||
{
|
{
|
||||||
int n, fd;
|
int n, fd;
|
||||||
|
|
||||||
fd = open(".", OREAD);
|
fd = open(".", OREAD|OCEXEC);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return nil;
|
return nil;
|
||||||
n = fd2path(fd, buf, nbuf);
|
n = fd2path(fd, buf, nbuf);
|
||||||
|
|
|
@ -13,7 +13,7 @@ iounit(int fd)
|
||||||
char buf[128], *args[10];
|
char buf[128], *args[10];
|
||||||
|
|
||||||
snprint(buf, sizeof buf, "#d/%dctl", fd);
|
snprint(buf, sizeof buf, "#d/%dctl", fd);
|
||||||
cfd = open(buf, OREAD);
|
cfd = open(buf, OREAD|OCEXEC);
|
||||||
if(cfd < 0)
|
if(cfd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
i = read(cfd, buf, sizeof buf-1);
|
i = read(cfd, buf, sizeof buf-1);
|
||||||
|
|
|
@ -4,21 +4,21 @@
|
||||||
int
|
int
|
||||||
postnote(int group, int pid, char *note)
|
postnote(int group, int pid, char *note)
|
||||||
{
|
{
|
||||||
char file[128];
|
char file[32];
|
||||||
int f, r;
|
int f, r;
|
||||||
|
|
||||||
switch(group) {
|
switch(group) {
|
||||||
case PNPROC:
|
case PNPROC:
|
||||||
sprint(file, "/proc/%d/note", pid);
|
snprint(file, sizeof(file), "/proc/%lud/note", (ulong)pid);
|
||||||
break;
|
break;
|
||||||
case PNGROUP:
|
case PNGROUP:
|
||||||
sprint(file, "/proc/%d/notepg", pid);
|
snprint(file, sizeof(file), "/proc/%lud/notepg", (ulong)pid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = open(file, OWRITE);
|
f = open(file, OWRITE|OCEXEC);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,9 @@ procsetname(char *fmt, ...)
|
||||||
char buf[128];
|
char buf[128];
|
||||||
va_list arg;
|
va_list arg;
|
||||||
|
|
||||||
snprint(buf, sizeof buf, "#p/%lud/args", (ulong)getpid());
|
snprint(buf, sizeof buf, "/proc/%lud/args", (ulong)getpid());
|
||||||
if((fd = open(buf, OWRITE)) < 0)
|
fd = open(buf, OWRITE|OCEXEC);
|
||||||
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
va_start(arg, fmt);
|
va_start(arg, fmt);
|
||||||
n = vsnprint(buf, sizeof buf, fmt, arg);
|
n = vsnprint(buf, sizeof buf, fmt, arg);
|
||||||
|
|
|
@ -11,7 +11,7 @@ int
|
||||||
pushssl(int fd, char *alg, char *secin, char *secout, int *cfd)
|
pushssl(int fd, char *alg, char *secin, char *secout, int *cfd)
|
||||||
{
|
{
|
||||||
char buf[8];
|
char buf[8];
|
||||||
char dname[64];
|
char dname[32];
|
||||||
int n, data, ctl;
|
int n, data, ctl;
|
||||||
|
|
||||||
ctl = open("#D/ssl/clone", ORDWR);
|
ctl = open("#D/ssl/clone", ORDWR);
|
||||||
|
@ -21,7 +21,7 @@ pushssl(int fd, char *alg, char *secin, char *secout, int *cfd)
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
goto error;
|
goto error;
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
sprint(dname, "#D/ssl/%s/data", buf);
|
snprint(dname, sizeof(dname), "#D/ssl/%s/data", buf);
|
||||||
data = open(dname, ORDWR);
|
data = open(dname, ORDWR);
|
||||||
if(data < 0)
|
if(data < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -42,14 +42,14 @@ int
|
||||||
pushtls(int fd, char *hashalg, char *encalg, int isclient, char *secret, char *dir)
|
pushtls(int fd, char *hashalg, char *encalg, int isclient, char *secret, char *dir)
|
||||||
{
|
{
|
||||||
char buf[8];
|
char buf[8];
|
||||||
char dname[64];
|
char dname[32];
|
||||||
int n, data, ctl, hand;
|
int n, data, ctl, hand;
|
||||||
|
|
||||||
// open a new filter; get ctl fd
|
// open a new filter; get ctl fd
|
||||||
data = hand = -1;
|
data = hand = -1;
|
||||||
// /net/tls uses decimal file descriptors to name channels, hence a
|
// /net/tls uses decimal file descriptors to name channels, hence a
|
||||||
// user-level file server can't stand in for #a; may as well hard-code it.
|
// user-level file server can't stand in for #a; may as well hard-code it.
|
||||||
ctl = open("#a/tls/clone", ORDWR);
|
ctl = open("#a/tls/clone", ORDWR|OCEXEC);
|
||||||
if(ctl < 0)
|
if(ctl < 0)
|
||||||
goto error;
|
goto error;
|
||||||
n = read(ctl, buf, sizeof(buf)-1);
|
n = read(ctl, buf, sizeof(buf)-1);
|
||||||
|
@ -60,14 +60,14 @@ pushtls(int fd, char *hashalg, char *encalg, int isclient, char *secret, char *d
|
||||||
sprint(dir, "#a/tls/%s", buf);
|
sprint(dir, "#a/tls/%s", buf);
|
||||||
|
|
||||||
// get application fd
|
// get application fd
|
||||||
sprint(dname, "#a/tls/%s/data", buf);
|
snprint(dname, sizeof(dname), "#a/tls/%s/data", buf);
|
||||||
data = open(dname, ORDWR);
|
data = open(dname, ORDWR);
|
||||||
if(data < 0)
|
if(data < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
// get handshake fd
|
// get handshake fd
|
||||||
sprint(dname, "#a/tls/%s/hand", buf);
|
snprint(dname, sizeof(dname), "#a/tls/%s/hand", buf);
|
||||||
hand = open(dname, ORDWR);
|
hand = open(dname, ORDWR|OCEXEC);
|
||||||
if(hand < 0)
|
if(hand < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ putenv(char *name, char *val)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprint(ename, sizeof(ename), "/env/%s", name);
|
snprint(ename, sizeof(ename), "/env/%s", name);
|
||||||
f = create(ename, OWRITE, 0664);
|
f = create(ename, OWRITE|OCEXEC, 0664);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
return -1;
|
return -1;
|
||||||
n = strlen(val);
|
n = strlen(val);
|
||||||
|
|
|
@ -10,7 +10,7 @@ sysname(void)
|
||||||
if(b[0])
|
if(b[0])
|
||||||
return b;
|
return b;
|
||||||
|
|
||||||
f = open("#c/sysname", 0);
|
f = open("/dev/sysname", OREAD|OCEXEC);
|
||||||
if(f >= 0) {
|
if(f >= 0) {
|
||||||
n = read(f, b, sizeof(b)-1);
|
n = read(f, b, sizeof(b)-1);
|
||||||
if(n > 0)
|
if(n > 0)
|
||||||
|
|
|
@ -174,11 +174,12 @@ loadzone(Tzone *tz, char *name)
|
||||||
else
|
else
|
||||||
snprint(path, sizeof(path), "/adm/timezone/%s", name);
|
snprint(path, sizeof(path), "/adm/timezone/%s", name);
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
if((f = open(path, 0)) == -1)
|
f = open(path, OREAD|OCEXEC);
|
||||||
|
if(f < 0)
|
||||||
return -1;
|
return -1;
|
||||||
r = read(f, buf, sizeof(buf));
|
r = read(f, buf, sizeof(buf));
|
||||||
close(f);
|
close(f);
|
||||||
if(r == sizeof(buf) || r == -1)
|
if(r < 0 || r >= sizeof(buf))
|
||||||
return -1;
|
return -1;
|
||||||
buf[r] = 0;
|
buf[r] = 0;
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
|
@ -8,7 +8,7 @@ getuser(void)
|
||||||
int fd;
|
int fd;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
fd = open("/dev/user", OREAD);
|
fd = open("/dev/user", OREAD|OCEXEC);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return "none";
|
return "none";
|
||||||
n = read(fd, user, (sizeof user)-1);
|
n = read(fd, user, (sizeof user)-1);
|
||||||
|
|
|
@ -99,13 +99,13 @@ checkenv(void)
|
||||||
{
|
{
|
||||||
int n, fd;
|
int n, fd;
|
||||||
char buf[20];
|
char buf[20];
|
||||||
fd = open("/env/MALLOCFD", OREAD);
|
fd = open("/env/MALLOCFD", OREAD|OCEXEC);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if((n = read(fd, buf, sizeof buf)) < 0) {
|
n = read(fd, buf, sizeof buf);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
if(n < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
if(n >= sizeof buf)
|
if(n >= sizeof buf)
|
||||||
n = sizeof(buf)-1;
|
n = sizeof(buf)-1;
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
|
|
|
@ -137,7 +137,7 @@ _profdump(void)
|
||||||
snprint(filename, sizeof filename - 1, "prof.%ld", _tos->prof.pid);
|
snprint(filename, sizeof filename - 1, "prof.%ld", _tos->prof.pid);
|
||||||
else
|
else
|
||||||
snprint(filename, sizeof filename - 1, "prof.out");
|
snprint(filename, sizeof filename - 1, "prof.out");
|
||||||
f = create(filename, 1, 0666);
|
f = create(filename, OWRITE|OCEXEC, 0666);
|
||||||
if(f < 0) {
|
if(f < 0) {
|
||||||
perror("create prof.out");
|
perror("create prof.out");
|
||||||
return;
|
return;
|
||||||
|
@ -245,7 +245,7 @@ _profmain(void)
|
||||||
khz = _tos->cyclefreq / 1000; /* Report times in milliseconds */
|
khz = _tos->cyclefreq / 1000; /* Report times in milliseconds */
|
||||||
havecycles = 1;
|
havecycles = 1;
|
||||||
}
|
}
|
||||||
f = open("/env/profsize", OREAD);
|
f = open("/env/profsize", OREAD|OCEXEC);
|
||||||
if(f >= 0) {
|
if(f >= 0) {
|
||||||
memset(ename, 0, sizeof(ename));
|
memset(ename, 0, sizeof(ename));
|
||||||
read(f, ename, sizeof(ename)-1);
|
read(f, ename, sizeof(ename)-1);
|
||||||
|
@ -253,7 +253,7 @@ _profmain(void)
|
||||||
n = atol(ename);
|
n = atol(ename);
|
||||||
}
|
}
|
||||||
_tos->prof.what = Profuser;
|
_tos->prof.what = Profuser;
|
||||||
f = open("/env/proftype", OREAD);
|
f = open("/env/proftype", OREAD|OCEXEC);
|
||||||
if(f >= 0) {
|
if(f >= 0) {
|
||||||
memset(ename, 0, sizeof(ename));
|
memset(ename, 0, sizeof(ename));
|
||||||
read(f, ename, sizeof(ename)-1);
|
read(f, ename, sizeof(ename)-1);
|
||||||
|
|
|
@ -22,7 +22,7 @@ _getsubfont(Display *d, char *name)
|
||||||
if(dolock)
|
if(dolock)
|
||||||
unlockdisplay(d);
|
unlockdisplay(d);
|
||||||
|
|
||||||
fd = open(name, OREAD);
|
fd = open(name, OREAD|OCEXEC);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
fprint(2, "getsubfont: can't open %s: %r\n", name);
|
fprint(2, "getsubfont: can't open %s: %r\n", name);
|
||||||
f = nil;
|
f = nil;
|
||||||
|
|
|
@ -49,7 +49,7 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(fontname == nil){
|
if(fontname == nil){
|
||||||
fd = open("/env/font", OREAD);
|
fd = open("/env/font", OREAD|OCEXEC);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
n = read(fd, buf, sizeof(buf));
|
n = read(fd, buf, sizeof(buf));
|
||||||
if(n>0 && n<sizeof buf-1){
|
if(n>0 && n<sizeof buf-1){
|
||||||
|
@ -82,11 +82,11 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l
|
||||||
*/
|
*/
|
||||||
if(label != nil){
|
if(label != nil){
|
||||||
snprint(buf, sizeof buf, "%s/label", display->windir);
|
snprint(buf, sizeof buf, "%s/label", display->windir);
|
||||||
fd = open(buf, OREAD);
|
fd = open(buf, OREAD|OCEXEC);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
read(fd, display->oldlabel, (sizeof display->oldlabel)-1);
|
read(fd, display->oldlabel, (sizeof display->oldlabel)-1);
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = create(buf, OWRITE, 0666);
|
fd = create(buf, OWRITE|OCEXEC, 0666);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
write(fd, label, strlen(label));
|
write(fd, label, strlen(label));
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -125,7 +125,7 @@ gengetwindow(Display *d, char *winname, Image **winp, Screen **scrp, int ref)
|
||||||
|
|
||||||
obuf[0] = 0;
|
obuf[0] = 0;
|
||||||
retry:
|
retry:
|
||||||
fd = open(winname, OREAD);
|
fd = open(winname, OREAD|OCEXEC);
|
||||||
if(fd<0 || (n=read(fd, buf, sizeof buf-1))<=0){
|
if(fd<0 || (n=read(fd, buf, sizeof buf-1))<=0){
|
||||||
if(fd >= 0) close(fd);
|
if(fd >= 0) close(fd);
|
||||||
strcpy(buf, "noborder");
|
strcpy(buf, "noborder");
|
||||||
|
@ -345,7 +345,7 @@ _closedisplay(Display *disp, int isshutdown)
|
||||||
display = nil;
|
display = nil;
|
||||||
if(disp->oldlabel[0]){
|
if(disp->oldlabel[0]){
|
||||||
snprint(buf, sizeof buf, "%s/label", disp->windir);
|
snprint(buf, sizeof buf, "%s/label", disp->windir);
|
||||||
fd = open(buf, OWRITE);
|
fd = open(buf, OWRITE|OCEXEC);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
write(fd, disp->oldlabel, strlen(disp->oldlabel));
|
write(fd, disp->oldlabel, strlen(disp->oldlabel));
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -13,7 +13,7 @@ newwindow(char *str)
|
||||||
wsys = getenv("wsys");
|
wsys = getenv("wsys");
|
||||||
if(wsys == nil)
|
if(wsys == nil)
|
||||||
return -1;
|
return -1;
|
||||||
fd = open(wsys, ORDWR);
|
fd = open(wsys, ORDWR|OCEXEC);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
free(wsys);
|
free(wsys);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -12,7 +12,7 @@ readfile(char *name)
|
||||||
n = 0;
|
n = 0;
|
||||||
r = -1;
|
r = -1;
|
||||||
if((s = malloc(HUNK)) != nil){
|
if((s = malloc(HUNK)) != nil){
|
||||||
if((f = open(name, OREAD)) >= 0){
|
if((f = open(name, OREAD|OCEXEC)) >= 0){
|
||||||
while((r = read(f, s+n, HUNK)) > 0){
|
while((r = read(f, s+n, HUNK)) > 0){
|
||||||
n += r;
|
n += r;
|
||||||
r = -1;
|
r = -1;
|
||||||
|
|
|
@ -90,7 +90,6 @@ freescreen(Screen *s)
|
||||||
d = s->display;
|
d = s->display;
|
||||||
a = bufimage(d, 1+4);
|
a = bufimage(d, 1+4);
|
||||||
if(a == nil){
|
if(a == nil){
|
||||||
Error:
|
|
||||||
free(s);
|
free(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ writecolmap(Display *d, RGB *m)
|
||||||
ulong r, g, b;
|
ulong r, g, b;
|
||||||
|
|
||||||
sprint(buf, "/dev/draw/%d/colormap", d->dirno);
|
sprint(buf, "/dev/draw/%d/colormap", d->dirno);
|
||||||
fd = open(buf, OWRITE);
|
fd = open(buf, OWRITE|OCEXEC);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
drawerror(d, "writecolmap: open colormap failed");
|
drawerror(d, "writecolmap: open colormap failed");
|
||||||
t = malloc(8192);
|
t = malloc(8192);
|
||||||
|
|
|
@ -59,7 +59,7 @@ void
|
||||||
threadsetname(char *fmt, ...)
|
threadsetname(char *fmt, ...)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char buf[128];
|
char buf[32];
|
||||||
va_list arg;
|
va_list arg;
|
||||||
Proc *p;
|
Proc *p;
|
||||||
Thread *t;
|
Thread *t;
|
||||||
|
@ -72,8 +72,8 @@ threadsetname(char *fmt, ...)
|
||||||
t->cmdname = vsmprint(fmt, arg);
|
t->cmdname = vsmprint(fmt, arg);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
if(t->cmdname && p->nthreads == 1){
|
if(t->cmdname && p->nthreads == 1){
|
||||||
snprint(buf, sizeof buf, "#p/%lud/args", _tos->pid); //getpid());
|
snprint(buf, sizeof buf, "/proc/%lud/args", (ulong)getpid());
|
||||||
if((fd = open(buf, OWRITE)) >= 0){
|
if((fd = open(buf, OWRITE|OCEXEC)) >= 0){
|
||||||
write(fd, t->cmdname, strlen(t->cmdname)+1);
|
write(fd, t->cmdname, strlen(t->cmdname)+1);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,15 @@ iointerrupt(Ioproc *io)
|
||||||
qunlock(io);
|
qunlock(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
openprocctl(void)
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
snprint(buf, sizeof(buf), "/proc/%lud/ctl", (ulong)getpid());
|
||||||
|
return open(buf, OWRITE|OCEXEC);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xioproc(void *a)
|
xioproc(void *a)
|
||||||
{
|
{
|
||||||
|
@ -28,15 +37,11 @@ xioproc(void *a)
|
||||||
|
|
||||||
c = a;
|
c = a;
|
||||||
if(io = mallocz(sizeof(*io), 1)){
|
if(io = mallocz(sizeof(*io), 1)){
|
||||||
char buf[128];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* open might fail, ignore it for programs like factotum
|
* open might fail, ignore it for programs like factotum
|
||||||
* that don't use iointerrupt() anyway.
|
* that don't use iointerrupt() anyway.
|
||||||
*/
|
*/
|
||||||
snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
|
io->ctl = openprocctl();
|
||||||
io->ctl = open(buf, OWRITE);
|
|
||||||
|
|
||||||
if((io->creply = chancreate(sizeof(void*), 0)) == nil){
|
if((io->creply = chancreate(sizeof(void*), 0)) == nil){
|
||||||
if(io->ctl >= 0)
|
if(io->ctl >= 0)
|
||||||
close(io->ctl);
|
close(io->ctl);
|
||||||
|
|
|
@ -76,24 +76,31 @@ threadint(int id)
|
||||||
threadxxx(id, 0);
|
threadxxx(id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
writeprocctl(int pid, char *ctl)
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
snprint(buf, sizeof(buf), "/proc/%lud/ctl", (ulong)pid);
|
||||||
|
fd = open(buf, OWRITE|OCEXEC);
|
||||||
|
if(fd < 0)
|
||||||
|
return -1;
|
||||||
|
if(write(fd, ctl, strlen(ctl)) < 0){
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tinterrupt(Proc *p, Thread *t)
|
tinterrupt(Proc *p, Thread *t)
|
||||||
{
|
{
|
||||||
char buf[64];
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
switch(t->state){
|
switch(t->state){
|
||||||
case Running:
|
case Running:
|
||||||
snprint(buf, sizeof(buf), "/proc/%d/ctl", p->pid);
|
if(writeprocctl(p->pid, "interrupt") < 0)
|
||||||
fd = open(buf, OWRITE|OCEXEC);
|
postnote(PNPROC, p->pid, "threadint");
|
||||||
if(fd >= 0){
|
|
||||||
if(write(fd, "interrupt", 9) == 9){
|
|
||||||
close(fd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
postnote(PNPROC, p->pid, "threadint");
|
|
||||||
break;
|
break;
|
||||||
case Rendezvous:
|
case Rendezvous:
|
||||||
_threadflagrendez(t);
|
_threadflagrendez(t);
|
||||||
|
|
Loading…
Reference in a new issue