lpd: spool mode added by Vladimir

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
This commit is contained in:
Denis Vlasenko
2008-02-25 20:30:24 +00:00
parent 38b8831b32
commit 394eebed66
11 changed files with 147 additions and 86 deletions

View File

@ -19,19 +19,26 @@
*/
static void get_response_or_say_and_die(const char *errmsg)
{
static const char newline = '\n';
char buf = ' ';
ssize_t sz;
char buf[128];
fflush(stdout);
safe_read(STDOUT_FILENO, &buf, 1);
if ('\0' != buf) {
buf[0] = ' ';
sz = safe_read(STDOUT_FILENO, buf, 1);
if ('\0' != buf[0]) {
// request has failed
bb_error_msg("error while %s. Server said:", errmsg);
safe_write(STDERR_FILENO, &buf, 1);
logmode = 0; /* no error messages from bb_copyfd_eof() pls */
bb_copyfd_eof(STDOUT_FILENO, STDERR_FILENO);
safe_write(STDERR_FILENO, &newline, 1);
// try to make sure last char is '\n', but do not add
// superfluous one
sz = full_read(STDOUT_FILENO, buf + 1, 126);
bb_error_msg("error while %s%s", errmsg,
(sz > 0 ? ". Server said:" : ""));
if (sz > 0) {
// sz = (bytes in buf) - 1
if (buf[sz] != '\n')
buf[++sz] = '\n';
safe_write(STDERR_FILENO, buf, sz + 1);
}
xfunc_die();
}
}