Last change
on this file since 1333 was 821, checked in by Bruno Cornec, 19 years ago |
Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)
|
File size:
775 bytes
|
Line | |
---|
1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * Utility routines.
|
---|
4 | *
|
---|
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
---|
6 | *
|
---|
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include <stdio.h>
|
---|
11 | #include <unistd.h>
|
---|
12 | #include "libbb.h"
|
---|
13 |
|
---|
14 | /*
|
---|
15 | * Read all of the supplied buffer from a file.
|
---|
16 | * This does multiple reads as necessary.
|
---|
17 | * Returns the amount read, or -1 on an error.
|
---|
18 | * A short read is returned on an end of file.
|
---|
19 | */
|
---|
20 | ssize_t bb_full_read(int fd, void *buf, size_t len)
|
---|
21 | {
|
---|
22 | ssize_t cc;
|
---|
23 | ssize_t total;
|
---|
24 |
|
---|
25 | total = 0;
|
---|
26 |
|
---|
27 | while (len > 0) {
|
---|
28 | cc = safe_read(fd, buf, len);
|
---|
29 |
|
---|
30 | if (cc < 0)
|
---|
31 | return cc; /* read() returns -1 on failure. */
|
---|
32 |
|
---|
33 | if (cc == 0)
|
---|
34 | break;
|
---|
35 |
|
---|
36 | buf = ((char *)buf) + cc;
|
---|
37 | total += cc;
|
---|
38 | len -= cc;
|
---|
39 | }
|
---|
40 |
|
---|
41 | return total;
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.