aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9p.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-06-19 23:07:48 -0400
committerRuss Cox <rsc@swtch.com>2008-06-19 23:07:48 -0400
commitdfe57535afa96031add209ab71ef052178951aec (patch)
tree4f6130f124f6514b013728db993dabf986f3f193 /src/cmd/9p.c
parent3e4ceac760d5b2b7238cb27d13045df76c6d4c20 (diff)
downloadplan9port-dfe57535afa96031add209ab71ef052178951aec.tar.gz
plan9port-dfe57535afa96031add209ab71ef052178951aec.tar.bz2
plan9port-dfe57535afa96031add209ab71ef052178951aec.zip
9p: fix writen (sqweek)
Diffstat (limited to 'src/cmd/9p.c')
-rw-r--r--src/cmd/9p.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/cmd/9p.c b/src/cmd/9p.c
index 689e00ee..135d9c50 100644
--- a/src/cmd/9p.c
+++ b/src/cmd/9p.c
@@ -28,16 +28,21 @@ usage(void)
int
writen(int fd, void *buf, int n)
{
- long m, tot;
+ int m, tot;
- for(tot=0; tot<n; tot+=m){
- m = n - tot;
- if(m > 8192)
- m = 8192;
- if(write(fd, (uchar*)buf+tot, m) != m)
- break;
+ if(n < 0){
+ werrstr("bad count");
+ return -1;
}
- return tot;
+ if(n == 0)
+ return 0;
+
+ tot = 0;
+ while((m = write(fd, (char*)buf+tot, n-tot)) > 0)
+ tot += m;
+ if(tot < n)
+ return -1;
+ return n;
}
CFsys *(*nsmnt)(char*, char*) = nsamount;