diff options
author | phk <phk@FreeBSD.org> | 2002-10-23 19:52:32 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-10-23 19:52:32 +0000 |
commit | 3c688df1144b5bdaff8d7a1bb0a2b070aeb58570 (patch) | |
tree | 8f96ba2125f5c49c01733b91085df28bc416b157 /lib/libdisk/blocks.c | |
parent | a422fc77aed8e1bd796a01b2de09138e90fabad5 (diff) | |
download | FreeBSD-src-3c688df1144b5bdaff8d7a1bb0a2b070aeb58570.zip FreeBSD-src-3c688df1144b5bdaff8d7a1bb0a2b070aeb58570.tar.gz |
Untangle #ifdefs in the write-end of things by giving each arch its
own file and own copy of WriteDisk() to do things in.
This should have happened years ago, instead of adding #ifdefs all
over the place.
Diffstat (limited to 'lib/libdisk/blocks.c')
-rw-r--r-- | lib/libdisk/blocks.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libdisk/blocks.c b/lib/libdisk/blocks.c index a630675..682a54b 100644 --- a/lib/libdisk/blocks.c +++ b/lib/libdisk/blocks.c @@ -19,6 +19,7 @@ void * read_block(int fd, daddr_t block, u_long sector_size) { void *foo; + int i; foo = malloc(sector_size); if (!foo) @@ -27,7 +28,8 @@ read_block(int fd, daddr_t block, u_long sector_size) free (foo); return NULL; } - if (sector_size != read(fd, foo, sector_size)) { + i = read(fd, foo, sector_size); + if ((int)sector_size != i) { free (foo); return NULL; } @@ -37,10 +39,12 @@ read_block(int fd, daddr_t block, u_long sector_size) int write_block(int fd, daddr_t block, const void *foo, u_long sector_size) { + int i; if (-1 == lseek(fd, (off_t)block * sector_size, SEEK_SET)) return -1; - if (sector_size != write(fd, foo, sector_size)) + i = write(fd, foo, sector_size); + if ((int)sector_size != i) return -1; return 0; } |