aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9p.c
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2021-02-18 20:21:24 +0100
committerPetter Rodhelind <petter.rodhelind@gmail.com>2021-02-18 20:21:24 +0100
commit181d56ee64da53279bb6ecf49c24ab54cfb7193f (patch)
treefc6c8736bb97790a257c5514998c583ffce7c41c /src/cmd/9p.c
parent94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14 (diff)
parent90971376a5e8620fc62579aa1b3be26245ec8c06 (diff)
downloadplan9port-master.tar.gz
plan9port-master.tar.bz2
plan9port-master.zip
Merge remote-tracking branch 'upstream/master'HEADmaster
Diffstat (limited to 'src/cmd/9p.c')
-rw-r--r--src/cmd/9p.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/cmd/9p.c b/src/cmd/9p.c
index 75511a19..a5b97f85 100644
--- a/src/cmd/9p.c
+++ b/src/cmd/9p.c
@@ -302,8 +302,10 @@ void
xrdwr(int argc, char **argv)
{
char buf[4096];
+ char *p;
int n;
CFid *fid;
+ Biobuf *b;
ARGBEGIN{
default:
@@ -313,6 +315,8 @@ xrdwr(int argc, char **argv)
if(argc != 1)
usage();
+ if((b = Bfdopen(0, OREAD)) == nil)
+ sysfatal("out of memory");
fid = xopen(argv[0], ORDWR);
for(;;){
fsseek(fid, 0, 0);
@@ -322,15 +326,15 @@ xrdwr(int argc, char **argv)
if(write(1, buf, n) < 0 || write(1, "\n", 1) < 0)
sysfatal("write error: %r");
}
- n = read(0, buf, sizeof buf);
- if(n <= 0)
+ if((p = Brdstr(b, '\n', 1)) == nil)
break;
- if(buf[n-1] == '\n')
- n--;
- if(fswrite(fid, buf, n) != n)
+ n = strlen(p);
+ if(fswrite(fid, p, n) != n)
fprint(2, "write: %r\n");
+ free(p);
}
fsclose(fid);
+ Bterm(b);
threadexitsall(0);
}