summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-05-07 19:05:12 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2017-05-07 19:05:12 +0200
commitbff4fad52a4c3387db54195c9fc20fb69247c43c (patch)
tree49f4ef1dd6587abb727a15f536451719071c9eb9 /sys/src
parent7327bd43c039d0ce2f4052afac04204718d9e69c (diff)
rio: implement writable and truncatable /dev/text
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/rio/dat.h1
-rw-r--r--sys/src/cmd/rio/fsys.c10
-rw-r--r--sys/src/cmd/rio/wind.c3
-rw-r--r--sys/src/cmd/rio/xfid.c5
4 files changed, 15 insertions, 4 deletions
diff --git a/sys/src/cmd/rio/dat.h b/sys/src/cmd/rio/dat.h
index f97049889..72d2023cb 100644
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -68,6 +68,7 @@ enum /* control messages */
Rawoff,
Holdon,
Holdoff,
+ Truncate,
Deleted,
Exited,
};
diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c
index afc247bf1..ebcdde17a 100644
--- a/sys/src/cmd/rio/fsys.c
+++ b/sys/src/cmd/rio/fsys.c
@@ -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:
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 7dc9e30e2..0cbcfc7a8 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -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)
diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c
index f0bd5a488..3985bea00 100644
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -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;