mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
394eebed66
lpr: more robust error reporting *: introduce and use xchroot libbb: full_read/write now will report partial data counts prior to error isdirectory.c: style fixes lpd_main 249 486 +237 xchroot - 29 +29 get_response_or_say_and_die 110 139 +29 full_write 52 60 +8 full_read 55 63 +8 static.newline 1 - -1 switch_root_main 404 400 -4 chpst_main 1089 1079 -10 getopt32 1370 1359 -11 chroot_main 115 101 -14 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 4/4 up/down: 311/-40) Total: 271 bytes text data bss dec hex filename 798472 728 7484 806684 c4f1c busybox_old 798775 728 7484 806987 c504b busybox_unstripped
43 lines
815 B
C
43 lines
815 B
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* Utility routines.
|
|
*
|
|
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
|
*
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
/*
|
|
* Write all of the supplied buffer out to a file.
|
|
* This does multiple writes as necessary.
|
|
* Returns the amount written, or -1 on an error.
|
|
*/
|
|
ssize_t full_write(int fd, const void *buf, size_t len)
|
|
{
|
|
ssize_t cc;
|
|
ssize_t total;
|
|
|
|
total = 0;
|
|
|
|
while (len) {
|
|
cc = safe_write(fd, buf, len);
|
|
|
|
if (cc < 0) {
|
|
if (total) {
|
|
/* we already wrote some! */
|
|
/* user can do another write to know the error code */
|
|
return total;
|
|
}
|
|
return cc; /* write() returns -1 on failure. */
|
|
}
|
|
|
|
total += cc;
|
|
buf = ((const char *)buf) + cc;
|
|
len -= cc;
|
|
}
|
|
|
|
return total;
|
|
}
|