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