rio: implement writable and truncatable /dev/text
This commit is contained in:
parent
7327bd43c0
commit
bff4fad52a
|
@ -68,6 +68,7 @@ enum /* control messages */
|
||||||
Rawoff,
|
Rawoff,
|
||||||
Holdon,
|
Holdon,
|
||||||
Holdoff,
|
Holdoff,
|
||||||
|
Truncate,
|
||||||
Deleted,
|
Deleted,
|
||||||
Exited,
|
Exited,
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ Dirtab dirtab[]=
|
||||||
{ "mouse", QTFILE, Qmouse, 0600 },
|
{ "mouse", QTFILE, Qmouse, 0600 },
|
||||||
{ "screen", QTFILE, Qscreen, 0400 },
|
{ "screen", QTFILE, Qscreen, 0400 },
|
||||||
{ "snarf", QTFILE, Qsnarf, 0600 },
|
{ "snarf", QTFILE, Qsnarf, 0600 },
|
||||||
{ "text", QTFILE, Qtext, 0400 },
|
{ "text", QTFILE, Qtext, 0600 },
|
||||||
{ "wdir", QTFILE, Qwdir, 0600 },
|
{ "wdir", QTFILE, Qwdir, 0600 },
|
||||||
{ "wctl", QTFILE, Qwctl, 0600 },
|
{ "wctl", QTFILE, Qwctl, 0600 },
|
||||||
{ "window", QTFILE, Qwindow, 0400 },
|
{ "window", QTFILE, Qwindow, 0400 },
|
||||||
|
@ -494,12 +494,14 @@ filsysopen(Filsys *fs, Xfid *x, Fid *f)
|
||||||
Fcall t;
|
Fcall t;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
/* can't truncate anything, so just disregard */
|
/* can't truncate anything but Qtext, so just disregard */
|
||||||
x->mode &= ~(OTRUNC|OCEXEC);
|
if(FILE(f->qid) != Qtext)
|
||||||
|
x->mode &= ~OTRUNC;
|
||||||
|
x->mode &= ~OCEXEC;
|
||||||
/* can't execute or remove anything */
|
/* can't execute or remove anything */
|
||||||
if(x->mode==OEXEC || (x->mode&ORCLOSE))
|
if(x->mode==OEXEC || (x->mode&ORCLOSE))
|
||||||
goto Deny;
|
goto Deny;
|
||||||
switch(x->mode){
|
switch(x->mode & ~OTRUNC){
|
||||||
default:
|
default:
|
||||||
goto Deny;
|
goto Deny;
|
||||||
case OREAD:
|
case OREAD:
|
||||||
|
|
|
@ -1198,6 +1198,9 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
|
||||||
wrepaint(w);
|
wrepaint(w);
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
break;
|
break;
|
||||||
|
case Truncate:
|
||||||
|
wdelete(w, 0, w->nr);
|
||||||
|
break;
|
||||||
case Deleted:
|
case Deleted:
|
||||||
wclunk(w);
|
wclunk(w);
|
||||||
if(w->notefd >= 0)
|
if(w->notefd >= 0)
|
||||||
|
|
|
@ -250,6 +250,10 @@ xfidopen(Xfid *x)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(FILE(x->f->qid)){
|
switch(FILE(x->f->qid)){
|
||||||
|
case Qtext:
|
||||||
|
if(x->mode&OTRUNC)
|
||||||
|
wsendctlmesg(w, Truncate, ZR, nil);
|
||||||
|
break;
|
||||||
case Qconsctl:
|
case Qconsctl:
|
||||||
if(w->ctlopen){
|
if(w->ctlopen){
|
||||||
filsysrespond(x->fs, x, &t, Einuse);
|
filsysrespond(x->fs, x, &t, Einuse);
|
||||||
|
@ -386,6 +390,7 @@ xfidwrite(Xfid *x)
|
||||||
x->data[cnt] = 0;
|
x->data[cnt] = 0;
|
||||||
switch(qid){
|
switch(qid){
|
||||||
case Qcons:
|
case Qcons:
|
||||||
|
case Qtext:
|
||||||
alts[CWdata].c = w->conswrite;
|
alts[CWdata].c = w->conswrite;
|
||||||
alts[CWdata].v = &cwm;
|
alts[CWdata].v = &cwm;
|
||||||
alts[CWdata].op = CHANRCV;
|
alts[CWdata].op = CHANRCV;
|
||||||
|
|
Loading…
Reference in a new issue