diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /libbb/full_read.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'libbb/full_read.c')
-rw-r--r-- | libbb/full_read.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libbb/full_read.c b/libbb/full_read.c index ccf26fc3d..e75f967db 100644 --- a/libbb/full_read.c +++ b/libbb/full_read.c | |||
@@ -23,17 +23,16 @@ | |||
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include "libbb.h" | 24 | #include "libbb.h" |
25 | 25 | ||
26 | |||
27 | /* | 26 | /* |
28 | * Read all of the supplied buffer from a file. | 27 | * Read all of the supplied buffer from a file. |
29 | * This does multiple reads as necessary. | 28 | * This does multiple reads as necessary. |
30 | * Returns the amount read, or -1 on an error. | 29 | * Returns the amount read, or -1 on an error. |
31 | * A short read is returned on an end of file. | 30 | * A short read is returned on an end of file. |
32 | */ | 31 | */ |
33 | int full_read(int fd, char *buf, int len) | 32 | ssize_t bb_full_read(int fd, void *buf, size_t len) |
34 | { | 33 | { |
35 | int cc; | 34 | ssize_t cc; |
36 | int total; | 35 | ssize_t total; |
37 | 36 | ||
38 | total = 0; | 37 | total = 0; |
39 | 38 | ||
@@ -41,12 +40,12 @@ int full_read(int fd, char *buf, int len) | |||
41 | cc = read(fd, buf, len); | 40 | cc = read(fd, buf, len); |
42 | 41 | ||
43 | if (cc < 0) | 42 | if (cc < 0) |
44 | return -1; | 43 | return cc; /* read() returns -1 on failure. */ |
45 | 44 | ||
46 | if (cc == 0) | 45 | if (cc == 0) |
47 | break; | 46 | break; |
48 | 47 | ||
49 | buf += cc; | 48 | buf = ((char *)buf) + cc; |
50 | total += cc; | 49 | total += cc; |
51 | len -= cc; | 50 | len -= cc; |
52 | } | 51 | } |