diff options
| author | Charles.Forsyth <devnull@localhost> | 2007-07-14 10:41:18 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2007-07-14 10:41:18 +0000 |
| commit | a6011949be081a8fe1bec0713ce60c36beb3a351 (patch) | |
| tree | 0855fa75f38a7361a9b7a9fe12608bd99761add0 /appl/lib | |
| parent | d42218ac2785e9e4bea53ec499f563cab5747959 (diff) | |
20070714-1142
Diffstat (limited to 'appl/lib')
| -rw-r--r-- | appl/lib/auth9.b | 8 | ||||
| -rw-r--r-- | appl/lib/disks.b | 20 | ||||
| -rw-r--r-- | appl/lib/scsiio.b | 16 |
3 files changed, 6 insertions, 38 deletions
diff --git a/appl/lib/auth9.b b/appl/lib/auth9.b index 06accb53..d9f38c71 100644 --- a/appl/lib/auth9.b +++ b/appl/lib/auth9.b @@ -288,12 +288,8 @@ decrypt(key: array of byte, data: array of byte, n: int) readn(fd: ref Sys->FD, nb: int): array of byte { buf:= array[nb] of byte; - for(n:=0; n<nb;){ - m := sys->read(fd, buf[n:], nb-n); - if(m <= 0) - return nil; - n += m; - } + if(sys->readn(fd, buf, nb) != nb) + return nil; return buf; } diff --git a/appl/lib/disks.b b/appl/lib/disks.b index ac718af1..2918b2cc 100644 --- a/appl/lib/disks.b +++ b/appl/lib/disks.b @@ -72,14 +72,14 @@ partitiongeometry(d: ref Disk): int rawfd := sys->open(d.prefix+"data", Sys->OREAD); if(rawfd != nil && sys->seek(rawfd, big 0, 0) == big 0 - && readn(rawfd, buf, 512) == 512 + && sys->readn(rawfd, buf, 512) == 512 && int t[Omagic] == Magic0 && int t[Omagic+1] == Magic1) { rawfd = nil; }else{ rawfd = nil; if(sys->seek(d.fd, big 0, 0) < big 0 - || readn(d.fd, buf, 512) != 512 + || sys->readn(d.fd, buf, 512) != 512 || int t[Omagic] != Magic0 || int t[Omagic+1] != Magic1) return -1; @@ -350,7 +350,7 @@ putle32(p: array of byte, i: big) Disk.readn(d: self ref Disk, buf: array of byte, nb: int): int { - return readn(d.fd, buf, nb); + return sys->readn(d.fd, buf, nb); } chstext(p: array of byte): string @@ -361,17 +361,3 @@ chstext(p: array of byte): string s := (int p[1] & 16r3F); return sys->sprint("%d/%d/%d", c, h, s); } - -readn(fd: ref Sys->FD, buf: array of byte, nb: int): int -{ - for(nr := 0; nr < nb;){ - n := sys->read(fd, buf[nr:], nb-nr); - if(n <= 0){ - if(nr == 0) - return n; - break; - } - nr += n; - } - return nr; -} diff --git a/appl/lib/scsiio.b b/appl/lib/scsiio.b index 152a22dd..3b4ce115 100644 --- a/appl/lib/scsiio.b +++ b/appl/lib/scsiio.b @@ -264,7 +264,7 @@ Scsi.open(dev: string): ref Scsi return nil; buf := array[512] of byte; - n := readn(ctlfd, buf, len buf); + n := sys->readn(ctlfd, buf, len buf); if(n < 8){ if(n >= 0) sys->werrstr("error reading ctl file"); @@ -301,17 +301,3 @@ qunlock(s: ref Scsi) { <-s.lock; } - -readn(fd: ref Sys->FD, buf: array of byte, nb: int): int -{ - for(nr := 0; nr < nb;){ - n := sys->read(fd, buf[nr:], nb-nr); - if(n <= 0){ - if(nr == 0) - return n; - break; - } - nr += n; - } - return nr; -} |
