From vda at busybox.net Sun Oct 1 03:58:54 2006 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Oct 2006 03:58:54 -0700 (PDT) Subject: svn commit: trunk/busybox/networking Message-ID: <20061001105854.9BA634856F@busybox.net> Author: vda Date: 2006-10-01 03:58:54 -0700 (Sun, 01 Oct 2006) New Revision: 16280 Log: wget: make progress bar and ETA work correctly with -c Modified: trunk/busybox/networking/wget.c Changeset: Modified: trunk/busybox/networking/wget.c =================================================================== --- trunk/busybox/networking/wget.c 2006-09-30 23:49:09 UTC (rev 16279) +++ trunk/busybox/networking/wget.c 2006-10-01 10:58:54 UTC (rev 16280) @@ -43,16 +43,16 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); /* Globals (can be accessed from signal handlers */ -static FILEOFF_TYPE filesize; /* content-length of the file */ +static FILEOFF_TYPE content_len; /* Content-length of the file */ +static FILEOFF_TYPE beg_range; /* Range at which continue begins */ +static FILEOFF_TYPE transferred; /* Number of bytes transferred so far */ static int chunked; /* chunked transfer encoding */ #ifdef CONFIG_FEATURE_WGET_STATUSBAR static void progressmeter(int flag); -static char *curfile; /* Name of current file being transferred. */ -static struct timeval start; /* Time a transfer started. */ -static FILEOFF_TYPE transferred; /* Number of bytes transferred so far. */ -/* For progressmeter() -- number of seconds before xfer considered "stalled" */ +static char *curfile; /* Name of current file being transferred */ +static struct timeval start; /* Time a transfer started */ enum { - STALLTIME = 5 + STALLTIME = 5 /* Seconds when xfer considered "stalled" */ }; #else static void progressmeter(int flag) {} @@ -139,7 +139,6 @@ FILE *sfp = NULL; /* socket to web/ftp server */ FILE *dfp = NULL; /* socket to ftp server (data) */ char *fname_out = NULL; /* where to direct output (-O) */ - FILEOFF_TYPE beg_range = 0; /* range at which continue begins */ int got_clen = 0; /* got content-length: from server */ int output_fd = -1; int use_proxy = 1; /* Use proxies if env vars are set */ @@ -232,7 +231,7 @@ if (output_fd >= 0) { beg_range = LSEEK(output_fd, 0, SEEK_END); if (beg_range == (FILEOFF_TYPE)-1) - bb_perror_msg_and_die("lseek64"); + bb_perror_msg_and_die("lseek"); } /* File doesn't exist. We do not create file here yet. We are not sure it exists on remove side */ @@ -337,7 +336,7 @@ */ while ((s = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) { if (strcasecmp(buf, "content-length") == 0) { - if (SAFE_STRTOOFF(s, &filesize) || filesize < 0) { + if (SAFE_STRTOOFF(s, &content_len) || content_len < 0) { bb_error_msg_and_die("content-length %s is garbage", s); } got_clen = 1; @@ -405,7 +404,7 @@ * Querying file size */ if (ftpcmd("SIZE ", target.path, sfp, buf) == 213) { - if (SAFE_STRTOOFF(buf+4, &filesize) || filesize < 0) { + if (SAFE_STRTOOFF(buf+4, &content_len) || content_len < 0) { bb_error_msg_and_die("SIZE value is garbage"); } got_clen = 1; @@ -427,7 +426,7 @@ if (beg_range) { sprintf(buf, "REST "FILEOFF_FMT, beg_range); if (ftpcmd(buf, NULL, sfp, buf) == 350) - filesize -= beg_range; + content_len -= beg_range; } if (ftpcmd("RETR ", target.path, sfp, buf) > 150) @@ -440,23 +439,26 @@ */ if (chunked) { fgets(buf, sizeof(buf), dfp); - filesize = STRTOOFF(buf, (char **) NULL, 16); + content_len = STRTOOFF(buf, (char **) NULL, 16); /* FIXME: error check?? */ } + /* Do it before progressmeter (want to have nice error message) */ + if (output_fd < 0) + output_fd = xopen3(fname_out, + O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_LARGEFILE, 0666); + if (!(opt & WGET_OPT_QUIET)) progressmeter(-1); do { - while (filesize > 0 || !got_clen) { + while (content_len > 0 || !got_clen) { unsigned rdsz = sizeof(buf); - if (filesize < sizeof(buf) && (chunked || got_clen)) - rdsz = (unsigned)filesize; + if (content_len < sizeof(buf) && (chunked || got_clen)) + rdsz = (unsigned)content_len; n = safe_fread(buf, 1, rdsz, dfp); if (n <= 0) break; - if (output_fd < 0) - output_fd = xopen3(fname_out, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_LARGEFILE, 0666); if (full_write(output_fd, buf, n) != n) { bb_perror_msg_and_die(bb_msg_write_error); } @@ -464,16 +466,16 @@ transferred += n; #endif if (got_clen) { - filesize -= n; + content_len -= n; } } if (chunked) { safe_fgets(buf, sizeof(buf), dfp); /* This is a newline */ safe_fgets(buf, sizeof(buf), dfp); - filesize = STRTOOFF(buf, (char **) NULL, 16); + content_len = STRTOOFF(buf, (char **) NULL, 16); /* FIXME: error check? */ - if (filesize == 0) { + if (content_len == 0) { chunked = 0; /* all done! */ } } @@ -636,10 +638,7 @@ #ifdef CONFIG_FEATURE_WGET_STATUSBAR /* Stuff below is from BSD rcp util.c, as added to openshh. * Original copyright notice is retained at the end of this file. - * */ - - static int getttywidth(void) { @@ -679,17 +678,17 @@ int elapsed, ratio, barlength, i; char buf[256]; - if (flag == -1) { + if (flag == -1) { /* first call to progressmeter */ (void) gettimeofday(&start, (struct timezone *) 0); lastupdate = start; lastsize = 0; - totalsize = filesize; /* as filesize changes.. */ + totalsize = content_len + beg_range; /* as content_len changes.. */ } (void) gettimeofday(&now, (struct timezone *) 0); ratio = 100; if (totalsize != 0 && !chunked) { - ratio = (int) (100 * transferred / totalsize); + ratio = (int) (100 * (transferred+beg_range) / totalsize); ratio = MIN(ratio, 100); } @@ -704,7 +703,7 @@ fprintf(stderr, "|%s|", buf); } i = 0; - abbrevsize = transferred; + abbrevsize = transferred + beg_range; while (abbrevsize >= 100000) { i++; abbrevsize >>= 10; @@ -725,23 +724,26 @@ if (tvwait.tv_sec >= STALLTIME) { fprintf(stderr, " - stalled -"); - } else if (transferred <= 0 || elapsed <= 0 || transferred > totalsize || chunked) { - fprintf(stderr, "--:--:-- ETA"); } else { - /* totalsize / (transferred/elapsed) - elapsed: */ - int eta = (int) (totalsize*elapsed/transferred - elapsed); - i = eta % 3600; - fprintf(stderr, "%02d:%02d:%02d ETA", eta / 3600, i / 60, i % 60); + FILEOFF_TYPE to_download = totalsize - beg_range; + if (transferred <= 0 || elapsed <= 0 || transferred > to_download || chunked) { + fprintf(stderr, "--:--:-- ETA"); + } else { + /* to_download / (transferred/elapsed) - elapsed: */ + int eta = (int) (to_download*elapsed/transferred - elapsed); + i = eta % 3600; + fprintf(stderr, "%02d:%02d:%02d ETA", eta / 3600, i / 60, i % 60); + } } - if (flag == -1) { + if (flag == -1) { /* first call to progressmeter */ struct sigaction sa; sa.sa_handler = updateprogressmeter; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; sigaction(SIGALRM, &sa, NULL); alarmtimer(1); - } else if (flag == 1) { + } else if (flag == 1) { /* last call to progressmeter */ alarmtimer(0); transferred = 0; putc('\n', stderr); From bugs at busybox.net Sun Oct 1 05:47:24 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 1 Oct 2006 05:47:24 -0700 Subject: [udhcp 0001032]: udhcp does not support ethernet aliases Message-ID: <75712d2f6207812c2b96000748700375@busybox.net> The following issue has been ASSIGNED. ====================================================================== http://busybox.net/bugs/view.php?id=1032 ====================================================================== Reported By: teg Assigned To: BusyBox ====================================================================== Project: udhcp Issue ID: 1032 Category: Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 09-19-2006 01:01 PDT Last Modified: 10-01-2006 05:47 PDT ====================================================================== Summary: udhcp does not support ethernet aliases Description: I have multiple aliases for eth0 (eth0:1, eth0:2, etc.) and I run invidual udhcpc for each interface. Every interface will get IP address, but after a while (lease time?) when renew(?) comes, every udhcpc dies. ====================================================================== ---------------------------------------------------------------------- teg - 09-19-06 01:38 ---------------------------------------------------------------------- When it dies, It reports: debug, Sending renew... error, FATAL: couldn't listen on socket, No such device ---------------------------------------------------------------------- bernhardf - 09-30-06 13:51 ---------------------------------------------------------------------- I recommend you to use the version of udhcp that is in busybox. AFAIK the stand-alone udhcpd currently isn't actively maintained as opposed to the version in busybox. If you do not need any other applets from busybox, then just turn them off. HTH ---------------------------------------------------------------------- teg - 10-01-06 03:15 ---------------------------------------------------------------------- I AM using busybox version. ---------------------------------------------------------------------- bernhardf - 10-01-06 05:47 ---------------------------------------------------------------------- Reported against wrong project; Assigning to busybox. Issue History Date Modified Username Field Change ====================================================================== 09-19-06 01:01 teg New Issue 09-19-06 01:01 teg Issue Monitored: teg 09-19-06 01:38 teg Note Added: 0001636 09-30-06 13:51 bernhardf Note Added: 0001669 10-01-06 03:15 teg Note Added: 0001679 10-01-06 05:47 bernhardf Note Added: 0001681 10-01-06 05:47 bernhardf Assigned To => BusyBox 10-01-06 05:47 bernhardf Status new => assigned ====================================================================== From vda at busybox.net Sun Oct 1 08:55:12 2006 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Oct 2006 08:55:12 -0700 (PDT) Subject: svn commit: trunk/busybox: archival archival/libunarchive coreutil etc... Message-ID: <20061001155512.5FDC4485BC@busybox.net> Author: vda Date: 2006-10-01 08:55:11 -0700 (Sun, 01 Oct 2006) New Revision: 16283 Log: g[un]zip: add support for -v (verbose). Add CONFIG_DESKTOP, almost all bloat from this change is hidden under that. Modified: trunk/busybox/Config.in trunk/busybox/archival/bunzip2.c trunk/busybox/archival/gunzip.c trunk/busybox/archival/gzip.c trunk/busybox/archival/libunarchive/decompress_bunzip2.c trunk/busybox/archival/libunarchive/decompress_uncompress.c trunk/busybox/archival/libunarchive/decompress_unlzma.c trunk/busybox/archival/libunarchive/decompress_unzip.c trunk/busybox/archival/libunarchive/get_header_tar_gz.c trunk/busybox/archival/libunarchive/open_transformer.c trunk/busybox/archival/rpm2cpio.c trunk/busybox/archival/unlzma.c trunk/busybox/coreutils/od.c trunk/busybox/include/libbb.h trunk/busybox/include/unarchive.h Changeset: Modified: trunk/busybox/Config.in =================================================================== --- trunk/busybox/Config.in 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/Config.in 2006-10-01 15:55:11 UTC (rev 16283) @@ -29,6 +29,14 @@ You have been warned. +config CONFIG_DESKTOP + bool "Enable options for full-blown desktop systems." + default n + help + Enable options and features which are not essential. + Select this only if you plan to use busybox on full-blown + desktop machine with common Linux distro, not on an ebmbedded box. + choice prompt "Buffer allocation policy" default CONFIG_FEATURE_BUFFERS_USE_MALLOC Modified: trunk/busybox/archival/bunzip2.c =================================================================== --- trunk/busybox/archival/bunzip2.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/bunzip2.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -14,9 +14,10 @@ int bunzip2_main(int argc, char **argv) { + USE_DESKTOP(long long) int status; char *filename; unsigned long opt; - int status, src_fd, dst_fd; + int src_fd, dst_fd; opt = bb_getopt_ulflags(argc, argv, "cf"); @@ -55,7 +56,7 @@ } else dst_fd = STDOUT_FILENO; status = uncompressStream(src_fd, dst_fd); if (filename) { - if (!status) filename[strlen(filename)] = '.'; + if (status >= 0) filename[strlen(filename)] = '.'; if (unlink(filename) < 0) { bb_error_msg_and_die("cannot remove %s", filename); } Modified: trunk/busybox/archival/gunzip.c =================================================================== --- trunk/busybox/archival/gunzip.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/gunzip.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -34,13 +34,15 @@ #define GUNZIP_OPT_FORCE 2 #define GUNZIP_OPT_TEST 4 #define GUNZIP_OPT_DECOMPRESS 8 +#define GUNZIP_OPT_VERBOSE 0x10 int gunzip_main(int argc, char **argv) { - char status = EXIT_SUCCESS; + USE_DESKTOP(long long) int status; + int exitcode = 0; unsigned long opt; - opt = bb_getopt_ulflags(argc, argv, "cftd"); + opt = bb_getopt_ulflags(argc, argv, "cftdv"); /* if called as zcat */ if (strcmp(bb_applet_name, "zcat") == 0) { opt |= GUNZIP_OPT_STDOUT; @@ -59,6 +61,8 @@ if (old_path == NULL || strcmp(old_path, "-") == 0) { src_fd = STDIN_FILENO; opt |= GUNZIP_OPT_STDOUT; + USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;) + optind = argc; /* we don't handle "gunzip - a.gz b.gz" */ } else { src_fd = xopen(old_path, O_RDONLY); @@ -67,9 +71,9 @@ } /* Check that the input is sane. */ - if (isatty(src_fd) && ((opt & GUNZIP_OPT_FORCE) == 0)) { + if (isatty(src_fd) && !(opt & GUNZIP_OPT_FORCE)) { bb_error_msg_and_die - ("compressed data not read from terminal. Use -f to force it."); + ("compressed data not read from terminal, use -f to force it"); } /* Set output filename and number */ @@ -94,7 +98,8 @@ extension[2] = 'a'; extension[3] = 'r'; } else { - bb_error_msg_and_die("Invalid extension"); + // FIXME: should we die or just skip to next? + bb_error_msg_and_die("invalid extension"); } /* Open output file (with correct permissions) */ @@ -105,30 +110,34 @@ delete_path = old_path; } + status = -1; /* do the decompression, and cleanup */ if (xread_char(src_fd) == 0x1f) { unsigned char magic2; magic2 = xread_char(src_fd); -#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS - if (magic2 == 0x9d) { + if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) { status = uncompress(src_fd, dst_fd); - } else -#endif - if (magic2 == 0x8b) { - check_header_gzip(src_fd); - status = inflate_gunzip(src_fd, dst_fd); - if (status != 0) { - bb_error_msg_and_die("error inflating"); - } - } else { - bb_error_msg_and_die("invalid magic"); - } + } else if (magic2 == 0x8b) { + check_header_gzip(src_fd); // FIXME: xfunc? _or_die? + status = inflate_gunzip(src_fd, dst_fd); + } else { + bb_error_msg("invalid magic"); + exitcode = 1; + } + if (status < 0) { + bb_error_msg("error inflating"); + exitcode = 1; + } + else if (ENABLE_DESKTOP && (opt & GUNZIP_OPT_VERBOSE)) { + fprintf(stderr, "%s: %u%% - replaced with %s\n", + // TODO: LARGEFILE support for stat_buf.st_size? + old_path, (unsigned)(stat_buf.st_size*100 / (status+1)), new_path); + } } else { - bb_error_msg_and_die("invalid magic"); + bb_error_msg("invalid magic"); exitcode = 1; } - - if ((status != EXIT_SUCCESS) && (new_path)) { + if (status < 0 && new_path) { /* Unzip failed, remove new path instead of old path */ delete_path = new_path; } @@ -142,12 +151,13 @@ /* delete_path will be NULL if in test mode or from stdin */ if (delete_path && (unlink(delete_path) == -1)) { - bb_error_msg_and_die("cannot remove %s", delete_path); + bb_error_msg("cannot remove %s", delete_path); + exitcode = 1; } free(new_path); } while (optind < argc); - return status; + return exitcode; } Modified: trunk/busybox/archival/gzip.c =================================================================== --- trunk/busybox/archival/gzip.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/gzip.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -16,6 +16,8 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ +// TODO: full support for -v for DESKTOP + #define SMALL_MEM #include @@ -1134,7 +1136,7 @@ struct stat statBuf; char *delFileName; - opt = bb_getopt_ulflags(argc, argv, "cf123456789q" USE_GUNZIP("d")); + opt = bb_getopt_ulflags(argc, argv, "cf123456789qv" USE_GUNZIP("d")); //if (opt & 0x1) // -c //if (opt & 0x2) // -f /* Ignore 1-9 (compression level) options */ @@ -1148,7 +1150,8 @@ //if (opt & 0x200) // -8 //if (opt & 0x400) // -9 //if (opt & 0x800) // -q - if (ENABLE_GUNZIP && (opt & 0x1000)) { // -d + //if (opt & 0x1000) // -v + if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d /* FIXME: bb_getopt_ulflags should not depend on optind */ optind = 1; return gunzip_main(argc, argv); Modified: trunk/busybox/archival/libunarchive/decompress_bunzip2.c =================================================================== --- trunk/busybox/archival/libunarchive/decompress_bunzip2.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/libunarchive/decompress_bunzip2.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -671,20 +671,24 @@ /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data, not end of file.) */ -int uncompressStream(int src_fd, int dst_fd) +USE_DESKTOP(long long) int +uncompressStream(int src_fd, int dst_fd) { + USE_DESKTOP(long long total_written = 0;) char *outbuf; bunzip_data *bd; int i; outbuf=xmalloc(IOBUF_SIZE); - if(!(i=start_bunzip(&bd,src_fd,0,0))) { + i=start_bunzip(&bd,src_fd,0,0); + if(!i) { for(;;) { if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break; if(i!=write(dst_fd,outbuf,i)) { i=RETVAL_UNEXPECTED_OUTPUT_EOF; break; } + USE_DESKTOP(total_written += i;) } } @@ -692,27 +696,27 @@ if(i==RETVAL_LAST_BLOCK) { if (bd->headerCRC!=bd->totalCRC) { - bb_error_msg("Data integrity error when decompressing."); + bb_error_msg("data integrity error when decompressing"); } else { i=RETVAL_OK; } } else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) { - bb_error_msg("Compressed file ends unexpectedly"); + bb_error_msg("compressed file ends unexpectedly"); } else { - bb_error_msg("Decompression failed"); + bb_error_msg("decompression failed"); } free(bd->dbuf); free(bd); free(outbuf); - return i; + return i ? i : USE_DESKTOP(total_written) + 0; } #ifdef TESTING static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data", "Unexpected input EOF","Unexpected output EOF","Data error", - "Out of memory","Obsolete (pre 0.9.5) bzip format not supported."}; + "Out of memory","Obsolete (pre 0.9.5) bzip format not supported."}; /* Dumb little test thing, decompress stdin to stdout */ int main(int argc, char *argv[]) @@ -720,8 +724,8 @@ int i=uncompressStream(0,1); char c; - if(i) fprintf(stderr,"%s\n", bunzip_errors[-i]); - else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n"); + if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]); + else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n"); return -i; } #endif Modified: trunk/busybox/archival/libunarchive/decompress_uncompress.c =================================================================== --- trunk/busybox/archival/libunarchive/decompress_uncompress.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/libunarchive/decompress_uncompress.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -86,8 +86,10 @@ * with those of the compress() routine. See the definitions above. */ -int uncompress(int fd_in, int fd_out) +USE_DESKTOP(long long) int +uncompress(int fd_in, int fd_out) { + USE_DESKTOP(long long total_written = 0;) unsigned char *stackp; long int code; int finchar; @@ -182,16 +184,16 @@ { unsigned char *p = &inbuf[posbits >> 3]; - code = - ((((long) (p[0])) | ((long) (p[1]) << 8) | - ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; + code = ((((long) (p[0])) | ((long) (p[1]) << 8) | + ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; } posbits += n_bits; if (oldcode == -1) { - outbuf[outpos++] = (unsigned char) (finchar = - (int) (oldcode = code)); + oldcode = code; + finchar = (int) oldcode; + outbuf[outpos++] = (unsigned char) finchar; continue; } @@ -255,6 +257,7 @@ if (outpos >= OBUFSIZ) { write(fd_out, outbuf, outpos); + USE_DESKTOP(total_written += outpos;) outpos = 0; } stackp += i; @@ -280,9 +283,10 @@ if (outpos > 0) { write(fd_out, outbuf, outpos); + USE_DESKTOP(total_written += outpos;) } RELEASE_CONFIG_BUFFER(inbuf); RELEASE_CONFIG_BUFFER(outbuf); - return 0; + return USE_DESKTOP(total_written) + 0; } Modified: trunk/busybox/archival/libunarchive/decompress_unlzma.c =================================================================== --- trunk/busybox/archival/libunarchive/decompress_unlzma.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/libunarchive/decompress_unlzma.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -211,9 +211,10 @@ #define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS) #define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS) - -int unlzma(int src_fd, int dst_fd) +USE_DESKTOP(long long) int +unlzma(int src_fd, int dst_fd) { + USE_DESKTOP(long long total_written = 0;) lzma_header_t header; int lc, pb, lp; uint32_t pos_state_mask; @@ -305,7 +306,9 @@ if (buffer_pos == header.dict_size) { buffer_pos = 0; global_pos += header.dict_size; + // FIXME: error check write(dst_fd, buffer, header.dict_size); + USE_DESKTOP(total_written += header.dict_size;) } if (state < 4) state = 0; @@ -345,7 +348,9 @@ if (buffer_pos == header.dict_size) { buffer_pos = 0; global_pos += header.dict_size; + // FIXME: error check write(dst_fd, buffer, header.dict_size); + USE_DESKTOP(total_written += header.dict_size;) } continue; } else { @@ -456,15 +461,18 @@ if (buffer_pos == header.dict_size) { buffer_pos = 0; global_pos += header.dict_size; + // FIXME: error check write(dst_fd, buffer, header.dict_size); + USE_DESKTOP(total_written += header.dict_size;) } len--; } while (len != 0 && buffer_pos < header.dst_size); } } + // FIXME: error check write(dst_fd, buffer, buffer_pos); + USE_DESKTOP(total_written += buffer_pos;) rc_free(&rc); - return 0; + return USE_DESKTOP(total_written) + 0; } - Modified: trunk/busybox/archival/libunarchive/decompress_unzip.c =================================================================== --- trunk/busybox/archival/libunarchive/decompress_unzip.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/libunarchive/decompress_unzip.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -835,8 +835,10 @@ free(bytebuffer); } -int inflate_unzip(int in, int out) +USE_DESKTOP(long long) int +inflate_unzip(int in, int out) { + USE_DESKTOP(long long total = 0;) ssize_t nwrote; typedef void (*sig_type) (int); @@ -864,6 +866,7 @@ bb_perror_msg("write"); return -1; } + USE_DESKTOP(total += nwrote;) if (ret == 0) break; } @@ -880,15 +883,17 @@ gunzip_bb >>= 8; gunzip_bk -= 8; } - return 0; + return USE_DESKTOP(total) + 0; } -int inflate_gunzip(int in, int out) +USE_DESKTOP(long long) int +inflate_gunzip(int in, int out) { uint32_t stored_crc = 0; unsigned int count; + USE_DESKTOP(long long total = )inflate_unzip(in, out); - inflate_unzip(in, out); + USE_DESKTOP(if (total < 0) return total;) /* top up the input buffer with the rest of the trailer */ count = bytebuffer_size - bytebuffer_offset; @@ -915,5 +920,5 @@ return -1; } - return 0; + return USE_DESKTOP(total) + 0; } Modified: trunk/busybox/archival/libunarchive/get_header_tar_gz.c =================================================================== --- trunk/busybox/archival/libunarchive/get_header_tar_gz.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/libunarchive/get_header_tar_gz.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -17,7 +17,7 @@ xread(archive_handle->src_fd, &magic, 2); if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { - bb_error_msg_and_die("Invalid gzip magic"); + bb_error_msg_and_die("invalid gzip magic"); } check_header_gzip(archive_handle->src_fd); Modified: trunk/busybox/archival/libunarchive/open_transformer.c =================================================================== --- trunk/busybox/archival/libunarchive/open_transformer.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/libunarchive/open_transformer.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -11,7 +11,8 @@ #include "unarchive.h" /* transformer(), more than meets the eye */ -int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd)) +int open_transformer(int src_fd, + USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)) { int fd_pipe[2]; int pid; @@ -28,6 +29,7 @@ if (pid == 0) { /* child process */ close(fd_pipe[0]); /* We don't wan't to read from the parent */ + // FIXME: error check? transformer(src_fd, fd_pipe[1]); close(fd_pipe[1]); /* Send EOF */ close(src_fd); @@ -38,5 +40,5 @@ /* parent process */ close(fd_pipe[1]); /* Don't want to write to the child */ - return(fd_pipe[0]); + return fd_pipe[0]; } Modified: trunk/busybox/archival/rpm2cpio.c =================================================================== --- trunk/busybox/archival/rpm2cpio.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/rpm2cpio.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -63,7 +63,7 @@ xread(rpm_fd, &lead, sizeof(struct rpm_lead)); if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { - bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ + bb_error_msg_and_die("invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ } /* Skip the signature header */ @@ -75,12 +75,12 @@ xread(rpm_fd, &magic, 2); if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { - bb_error_msg_and_die("Invalid gzip magic"); + bb_error_msg_and_die("invalid gzip magic"); } check_header_gzip(rpm_fd); - if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) { - bb_error_msg("Error inflating"); + if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) { + bb_error_msg("error inflating"); } close(rpm_fd); Modified: trunk/busybox/archival/unlzma.c =================================================================== --- trunk/busybox/archival/unlzma.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/archival/unlzma.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -8,6 +8,8 @@ * Licensed under GPL v2, see file LICENSE in this tarball for details. */ +/* Why our g[un]zip/bunzip2 are so ugly compared to this beauty? */ + #include "busybox.h" #include "unarchive.h" @@ -15,15 +17,16 @@ int unlzma_main(int argc, char **argv) { + USE_DESKTOP(long long) int status; char *filename; unsigned long opt; - int status, src_fd, dst_fd; + int src_fd, dst_fd; opt = bb_getopt_ulflags(argc, argv, "c"); /* Set input filename and number */ filename = argv[optind]; - if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) { + if (filename && (filename[0] != '-') && (filename[1] != '\0')) { /* Open input file */ src_fd = xopen(filename, O_RDONLY); } else { @@ -50,13 +53,12 @@ dst_fd = STDOUT_FILENO; status = unlzma(src_fd, dst_fd); if (filename) { - if (!status) + if (status >= 0) /* if success delete src, else delete dst */ filename[strlen(filename)] = '.'; if (unlink(filename) < 0) { bb_error_msg_and_die("cannot remove %s", filename); } } - return status; + return (status < 0); } - Modified: trunk/busybox/coreutils/od.c =================================================================== --- trunk/busybox/coreutils/od.c 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/coreutils/od.c 2006-10-01 15:55:11 UTC (rev 16283) @@ -11,6 +11,8 @@ * Original copyright notice is retained at the end of this file. */ +// TODO: -t. busybox's own build script needs it + #include #include #include Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/include/libbb.h 2006-10-01 15:55:11 UTC (rev 16283) @@ -339,7 +339,7 @@ char *fgets_str(FILE *file, const char *terminating_string); -extern int uncompress(int fd_in, int fd_out); +extern USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out); extern int inflate(int in, int out); extern struct hostent *xgethostbyname(const char *name); @@ -353,9 +353,9 @@ // This is declared here rather than #including in order to avoid // confusing the two versions of basename. See the dirname/basename man page // for details. -char *dirname (char *path); +char *dirname(char *path); -int bb_make_directory (char *path, long mode, int flags); +int bb_make_directory(char *path, long mode, int flags); int get_signum(const char *name); const char *get_signame(int number); Modified: trunk/busybox/include/unarchive.h =================================================================== --- trunk/busybox/include/unarchive.h 2006-10-01 15:17:52 UTC (rev 16282) +++ trunk/busybox/include/unarchive.h 2006-10-01 15:55:11 UTC (rev 16283) @@ -100,14 +100,15 @@ extern const llist_t *find_list_entry(const llist_t *list, const char *filename); extern const llist_t *find_list_entry2(const llist_t *list, const char *filename); -extern int uncompressStream(int src_fd, int dst_fd); +extern USE_DESKTOP(long long) int uncompressStream(int src_fd, int dst_fd); extern void inflate_init(unsigned int bufsize); extern void inflate_cleanup(void); -extern int inflate_unzip(int in, int out); -extern int inflate_gunzip(int in, int out); -extern int unlzma(int src_fd, int dst_fd); +extern USE_DESKTOP(long long) int inflate_unzip(int in, int out); +extern USE_DESKTOP(long long) int inflate_gunzip(int in, int out); +extern USE_DESKTOP(long long) int unlzma(int src_fd, int dst_fd); -extern int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd)); +extern int open_transformer(int src_fd, + USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)); #endif From vda at busybox.net Sun Oct 1 09:44:05 2006 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Oct 2006 09:44:05 -0700 (PDT) Subject: svn commit: trunk/busybox/archival Message-ID: <20061001164405.0BB644856E@busybox.net> Author: vda Date: 2006-10-01 09:44:04 -0700 (Sun, 01 Oct 2006) New Revision: 16284 Log: gzip: add a bit of comment. The code itself is too bloated to work on it... Modified: trunk/busybox/archival/gzip.c Changeset: Modified: trunk/busybox/archival/gzip.c =================================================================== --- trunk/busybox/archival/gzip.c 2006-10-01 15:55:11 UTC (rev 16283) +++ trunk/busybox/archival/gzip.c 2006-10-01 16:44:04 UTC (rev 16284) @@ -16,7 +16,12 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -// TODO: full support for -v for DESKTOP +/* TODO: full support for -v for DESKTOP +/usr/bin/gzip -v a bogus aa +a: 85.1% -- replaced with a.gz +gzip: bogus: No such file or directory +aa: 85.1% -- replaced with aa.gz +*/ #define SMALL_MEM @@ -125,8 +130,8 @@ #define ASCII 1 #ifndef WSIZE -# define WSIZE 0x8000 /* window size--must be a power of two, and */ -#endif /* at least 32K for zip's deflate method */ +# define WSIZE 0x8000 /* window size--must be a power of two, and */ +#endif /* at least 32K for zip's deflate method */ #define MIN_MATCH 3 #define MAX_MATCH 258 @@ -2402,7 +2407,6 @@ /* Write the header to the gzip file. See algorithm.doc for the format */ - method = DEFLATED; put_header_byte(GZIP_MAGIC[0]); /* magic header */ put_header_byte(GZIP_MAGIC[1]); From bugs at busybox.net Sun Oct 1 10:20:10 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 1 Oct 2006 10:20:10 -0700 Subject: [BusyBox 0001059]: Standalone not working ? Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1059 ====================================================================== Reported By: AndyUK123 Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1059 Category: Other Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 10-01-2006 10:20 PDT Last Modified: 10-01-2006 10:20 PDT ====================================================================== Summary: Standalone not working ? Description: When I compiled busybox static (including Standalone set to on) and used it for init I found that when executing rcS the system was unable to "find" any commands unless they were referenced directly. putting /bin/echo "$PATH" at the start showed the correct pathing which /should/ have ment that echo etc was found without an explicit PATH declaration but : echo "test" - FAILS /bin/echo "test" - Works backing off to v1.1.3 on the same setup (just replacing busybox) works fine both busybox versions & the kernel(2.4.29) were compiled with gcc version 3.4.6 20060404 (Red Hat 3.4.6-3) I may well be doing something silly here, but I can't see it! ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 10-01-06 10:20 AndyUK123 New Issue 10-01-06 10:20 AndyUK123 Status new => assigned 10-01-06 10:20 AndyUK123 Assigned To => BusyBox ====================================================================== From vda at busybox.net Sun Oct 1 14:05:13 2006 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Oct 2006 14:05:13 -0700 (PDT) Subject: svn commit: trunk/busybox: coreutils editors include libbb Message-ID: <20061001210513.272A2485E5@busybox.net> Author: vda Date: 2006-10-01 14:05:12 -0700 (Sun, 01 Oct 2006) New Revision: 16286 Log: sed: unbreak multiple -e, -f option handling (my fault) Modified: trunk/busybox/coreutils/od.c trunk/busybox/editors/sed.c trunk/busybox/include/dump.h trunk/busybox/libbb/get_line_from_file.c Changeset: Modified: trunk/busybox/coreutils/od.c =================================================================== --- trunk/busybox/coreutils/od.c 2006-10-01 18:34:45 UTC (rev 16285) +++ trunk/busybox/coreutils/od.c 2006-10-01 21:05:12 UTC (rev 16286) @@ -189,7 +189,7 @@ odoffset(argc, &argv); - return(bb_dump_dump(argv)); + return bb_dump_dump(argv); } /*- Modified: trunk/busybox/editors/sed.c =================================================================== --- trunk/busybox/editors/sed.c 2006-10-01 18:34:45 UTC (rev 16285) +++ trunk/busybox/editors/sed.c 2006-10-01 21:05:12 UTC (rev 16286) @@ -1087,8 +1087,8 @@ int sed_main(int argc, char **argv) { unsigned long opt; - char *opt_e, *opt_f; - int status = EXIT_SUCCESS, getpat = 1; + llist_t *opt_e, *opt_f; + int status = EXIT_SUCCESS; bbg.sed_cmd_tail=&bbg.sed_cmd_head; @@ -1102,6 +1102,8 @@ } /* do normal option parsing */ + opt_e = opt_f = NULL; + bb_opt_complementally = "e::f::"; /* can occur multiple times */ opt = bb_getopt_ulflags(argc, argv, "irne:f:", &opt_e, &opt_f); if (opt & 0x1) { // -i bbg.in_place++; @@ -1110,23 +1112,30 @@ if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r if (opt & 0x4) bbg.be_quiet++; // -n if (opt & 0x8) { // -e - add_cmd_block(opt_e); - getpat=0; + while (opt_e) { + llist_t *cur = opt_e; + add_cmd_block(cur->data); + opt_e = cur->link; + free(cur); + } } if (opt & 0x10) { // -f - FILE *cmdfile; - char *line; - cmdfile = xfopen(opt_f, "r"); - while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { - add_cmd(line); - getpat=0; - free(line); + while (opt_f) { + llist_t *cur = opt_f; + FILE *cmdfile; + char *line; + cmdfile = xfopen(cur->data, "r"); + while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { + add_cmd(line); + free(line); + } + xprint_and_close_file(cmdfile); + opt_f = cur->link; + free(cur); } - xprint_and_close_file(cmdfile); } - /* if we didn't get a pattern from -e or -f, use argv[optind] */ - if(getpat) { + if(!(opt & 0x18)) { if (argv[optind] == NULL) bb_show_usage(); else @@ -1136,7 +1145,7 @@ add_cmd(""); /* By default, we write to stdout */ - bbg.nonstdout=stdout; + bbg.nonstdout = stdout; /* argv[(optind)..(argc-1)] should be names of file to process. If no * files were specified or '-' was specified, take input from stdin. Modified: trunk/busybox/include/dump.h =================================================================== --- trunk/busybox/include/dump.h 2006-10-01 18:34:45 UTC (rev 16285) +++ trunk/busybox/include/dump.h 2006-10-01 21:05:12 UTC (rev 16286) @@ -40,7 +40,7 @@ } FS; extern void bb_dump_add(const char *fmt); -extern int bb_dump_dump (char **argv); +extern int bb_dump_dump(char **argv); extern int bb_dump_size(FS * fs); extern FS *bb_dump_fshead; /* head of format strings */ Modified: trunk/busybox/libbb/get_line_from_file.c =================================================================== --- trunk/busybox/libbb/get_line_from_file.c 2006-10-01 18:34:45 UTC (rev 16285) +++ trunk/busybox/libbb/get_line_from_file.c 2006-10-01 21:05:12 UTC (rev 16286) @@ -16,7 +16,7 @@ /* get_line_from_file() - This function reads an entire line from a text file, * up to a newline or NUL byte. It returns a malloc'ed char * which must be * stored and free'ed by the caller. If end is null '\n' isn't considered - * and of line. If end isn't null, length of the chunk read is stored in it. */ + * end of line. If end isn't null, length of the chunk read is stored in it. */ char *bb_get_chunk_from_file(FILE * file, int *end) { @@ -46,7 +46,7 @@ return linebuf; } -/* Get line, including trailing /n if any */ +/* Get line, including trailing \n if any */ char *bb_get_line_from_file(FILE * file) { int i; @@ -54,7 +54,7 @@ return bb_get_chunk_from_file(file, &i); } -/* Get line. Remove trailing /n */ +/* Get line. Remove trailing \n */ char *bb_get_chomped_line_from_file(FILE * file) { int i; From vda at busybox.net Sun Oct 1 14:37:40 2006 From: vda at busybox.net (vda at busybox.net) Date: Sun, 1 Oct 2006 14:37:40 -0700 (PDT) Subject: svn commit: trunk/busybox/editors Message-ID: <20061001213740.C34EB485F0@busybox.net> Author: vda Date: 2006-10-01 14:37:40 -0700 (Sun, 01 Oct 2006) New Revision: 16287 Log: sed: -e options were handled in reverse order. fix that. Modified: trunk/busybox/editors/sed.c Changeset: Modified: trunk/busybox/editors/sed.c =================================================================== --- trunk/busybox/editors/sed.c 2006-10-01 21:05:12 UTC (rev 16286) +++ trunk/busybox/editors/sed.c 2006-10-01 21:37:40 UTC (rev 16287) @@ -1084,6 +1084,29 @@ free(temp); } +static void add_cmds_link(llist_t *opt_e) +{ + if (!opt_e) return; + add_cmds_link(opt_e->link); + add_cmd_block(opt_e->data); + free(opt_e); +} + +static void add_files_link(llist_t *opt_f) +{ + char *line; + FILE *cmdfile; + if (!opt_f) return; + add_files_link(opt_f->link); + cmdfile = xfopen(opt_f->data, "r"); + while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { + add_cmd(line); + free(line); + } + xprint_and_close_file(cmdfile); + free(opt_f); +} + int sed_main(int argc, char **argv) { unsigned long opt; @@ -1112,27 +1135,12 @@ if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r if (opt & 0x4) bbg.be_quiet++; // -n if (opt & 0x8) { // -e - while (opt_e) { - llist_t *cur = opt_e; - add_cmd_block(cur->data); - opt_e = cur->link; - free(cur); - } + /* getopt_ulflags reverses order of arguments, handle it */ + add_cmds_link(opt_e); } if (opt & 0x10) { // -f - while (opt_f) { - llist_t *cur = opt_f; - FILE *cmdfile; - char *line; - cmdfile = xfopen(cur->data, "r"); - while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { - add_cmd(line); - free(line); - } - xprint_and_close_file(cmdfile); - opt_f = cur->link; - free(cur); - } + /* getopt_ulflags reverses order of arguments, handle it */ + add_files_link(opt_f); } /* if we didn't get a pattern from -e or -f, use argv[optind] */ if(!(opt & 0x18)) { From vda at busybox.net Mon Oct 2 11:52:49 2006 From: vda at busybox.net (vda at busybox.net) Date: Mon, 2 Oct 2006 11:52:49 -0700 (PDT) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20061002185249.CC7604856A@busybox.net> Author: vda Date: 2006-10-02 11:52:49 -0700 (Mon, 02 Oct 2006) New Revision: 16291 Log: mount: accept and ignore -s (sloppy) option. needed for compatibility with Linux automounter. Modified: trunk/busybox/util-linux/mount.c Changeset: Modified: trunk/busybox/util-linux/mount.c =================================================================== --- trunk/busybox/util-linux/mount.c 2006-10-02 18:52:14 UTC (rev 16290) +++ trunk/busybox/util-linux/mount.c 2006-10-02 18:52:49 UTC (rev 16291) @@ -92,8 +92,8 @@ {"remount", MS_REMOUNT}, // action flag }; +#define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0])) - /* Append mount options to string */ static void append_mount_options(char **oldopts, char *newopts) { @@ -139,7 +139,7 @@ if (comma) *comma = 0; // Find this option in mount_options - for (i = 0; i < (sizeof(mount_options) / sizeof(*mount_options)); i++) { + for (i = 0; i < VECTOR_SIZE(mount_options); i++) { if (!strcasecmp(mount_options[i].name, options)) { long fl = mount_options[i].flags; if (fl < 0) flags &= fl; @@ -148,9 +148,7 @@ } } // If unrecognized not NULL, append unrecognized mount options */ - if (unrecognized - && i == (sizeof(mount_options) / sizeof(*mount_options))) - { + if (unrecognized && i == VECTOR_SIZE(mount_options)) { // Add it to strflags, to pass on to kernel i = *unrecognized ? strlen(*unrecognized) : 0; *unrecognized = xrealloc(*unrecognized, i+strlen(options)+2); @@ -1446,7 +1444,7 @@ // Parse remaining options - opt = bb_getopt_ulflags(argc, argv, "o:t:rwanfv", &opt_o, &fstype); + opt = bb_getopt_ulflags(argc, argv, "o:t:rwanfvs", &opt_o, &fstype); if (opt & 0x1) append_mount_options(&cmdopts, opt_o); // -o //if (opt & 0x2) // -t if (opt & 0x4) append_mount_options(&cmdopts, "ro"); // -r @@ -1454,7 +1452,8 @@ //if (opt & 0x10) // -a if (opt & 0x20) USE_FEATURE_MTAB_SUPPORT(useMtab = 0); // -n if (opt & 0x40) USE_FEATURE_MTAB_SUPPORT(fakeIt = 1); // -f - //if (opt & 0x80) // -v: ignore + //if (opt & 0x80) // -v: verbose (ignore) + //if (opt & 0x100) // -s: sloppy (ignore) argv += optind; argc -= optind; @@ -1499,8 +1498,10 @@ goto clean_up; } + i = parse_mount_options(cmdopts, 0); + // If we have a shared subtree flag, don't worry about fstab or mtab. - i = parse_mount_options(cmdopts,0); + if (ENABLE_FEATURE_MOUNT_FLAGS && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE ))) { @@ -1511,17 +1512,16 @@ // Open either fstab or mtab - if (parse_mount_options(cmdopts,0) & MS_REMOUNT) + if (i & MS_REMOUNT) fstabname = bb_path_mtab_file; else fstabname = "/etc/fstab"; - fstab = setmntent(fstabname,"r"); if (!fstab) bb_perror_msg_and_die("cannot read %s", fstabname); // Loop through entries until we find what we're looking for. - memset(mtpair,0,sizeof(mtpair)); + memset(mtpair, 0, sizeof(mtpair)); for (;;) { struct mntent *mtnext = (mtcur==mtpair ? mtpair+1 : mtpair); From vda at busybox.net Mon Oct 2 13:49:26 2006 From: vda at busybox.net (vda at busybox.net) Date: Mon, 2 Oct 2006 13:49:26 -0700 (PDT) Subject: svn commit: trunk/busybox: include miscutils Message-ID: <20061002204926.E30C1485A4@busybox.net> Author: vda Date: 2006-10-02 13:49:25 -0700 (Mon, 02 Oct 2006) New Revision: 16293 Log: eject: -T (implements single button open/close) Modified: trunk/busybox/include/usage.h trunk/busybox/miscutils/eject.c Changeset: Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2006-10-02 19:40:44 UTC (rev 16292) +++ trunk/busybox/include/usage.h 2006-10-02 20:49:25 UTC (rev 16293) @@ -638,11 +638,12 @@ "Erik\\nis\\ncool\n") #define eject_trivial_usage \ - "[-t] [DEVICE]" + "[-t] [-T] [DEVICE]" #define eject_full_usage \ "Eject specified DEVICE (or default /dev/cdrom).\n\n" \ "Options:\n" \ - "\t-t\tclose tray" + "\t-t\tclose tray\n" \ + "\t-T\topen/close tray (toggle)" #define ed_trivial_usage "" #define ed_full_usage "" Modified: trunk/busybox/miscutils/eject.c =================================================================== --- trunk/busybox/miscutils/eject.c 2006-10-02 19:40:44 UTC (rev 16292) +++ trunk/busybox/miscutils/eject.c 2006-10-02 20:49:25 UTC (rev 16293) @@ -21,25 +21,40 @@ #define CDROMEJECT 0x5309 /* Ejects the cdrom media */ #define DEFAULT_CDROM "/dev/cdrom" +#define FLAG_CLOSE 1 +#define FLAG_SMART 2 + int eject_main(int argc, char **argv) { unsigned long flags; char *device; struct mntent *m; + int dev; - flags = bb_getopt_ulflags(argc, argv, "t"); + /*bb_opt_complementally = "t--T:T--t";*/ + flags = bb_getopt_ulflags(argc, argv, "tT"); device = argv[optind] ? : DEFAULT_CDROM; - if ((m = find_mount_point(device, bb_path_mtab_file))) { + m = find_mount_point(device, bb_path_mtab_file); + if (m) { if (umount(m->mnt_dir)) { - bb_error_msg_and_die("Can't umount"); + bb_error_msg_and_die("can't umount"); } else if (ENABLE_FEATURE_MTAB_SUPPORT) { erase_mtab(m->mnt_fsname); } } - if (ioctl(xopen(device, (O_RDONLY | O_NONBLOCK)), - (flags ? CDROMCLOSETRAY : CDROMEJECT))) { - bb_perror_msg_and_die("%s", device); + + dev = xopen(device, O_RDONLY|O_NONBLOCK); + + if (flags & FLAG_CLOSE) goto close_tray; + + if (ioctl(dev, CDROMEJECT)) { +close_tray: + if (ioctl(dev, CDROMCLOSETRAY)) + bb_perror_msg_and_die("%s", device); } - return (EXIT_SUCCESS); + + if (ENABLE_FEATURE_CLEAN_UP) close(dev); + + return EXIT_SUCCESS; } From vda at busybox.net Mon Oct 2 13:57:11 2006 From: vda at busybox.net (vda at busybox.net) Date: Mon, 2 Oct 2006 13:57:11 -0700 (PDT) Subject: svn commit: trunk/busybox/networking Message-ID: <20061002205711.2D008485C3@busybox.net> Author: vda Date: 2006-10-02 13:57:10 -0700 (Mon, 02 Oct 2006) New Revision: 16294 Log: ifupdown: Debian users contributed improvement to it Modified: trunk/busybox/networking/ifupdown.c Changeset: Modified: trunk/busybox/networking/ifupdown.c =================================================================== --- trunk/busybox/networking/ifupdown.c 2006-10-02 20:49:25 UTC (rev 16293) +++ trunk/busybox/networking/ifupdown.c 2006-10-02 20:57:10 UTC (rev 16294) @@ -452,45 +452,48 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) { - int i; + if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% " + "[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec)) + return 1; - for (i = 0; i < ifd->n_options; i++) { - if (strcmp(ifd->option[i].name, "dhcp-start-cmd") == 0) { - return execute(ifd->option[i].value, ifd, exec); - } - } + /* 2006-09-30: The following are deprecated, and should eventually be + * removed. For non-busybox (i.e., other than udhcpc) clients, use + * 'iface foo inet manual' in /etc/network/interfaces, and supply + * start/stop commands explicitly via up/down. */ - if (execute("udhcpc -n -p /var/run/udhcpc.%iface%.pid -i " - "%iface% [[-H %hostname%]] [[-c %clientid%]]", ifd, exec)) return 1; - if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]", ifd, exec)) return 1; - if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%", ifd, exec)) return 1; + if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]", + ifd, exec)) return 1; + if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%", + ifd, exec)) return 1; if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] " "[[-l %leasetime%]] %iface%", ifd, exec)) return 1; + return 0; } static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) { - int i; + if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", + ifd, exec)) return 1; - for (i = 0; i < ifd->n_options; i++) { - if (strcmp(ifd->option[i].name, "dhcp-stop-cmd") == 0) { - return execute(ifd->option[i].value, ifd, exec); - } - } + /* 2006-09-30: The following are deprecated, and should eventually be + * removed. For non-busybox (i.e., other than udhcpc) clients, use + * 'iface foo inet manual' in /etc/network/interfaces, and supply + * start/stop commands explicitly via up/down. */ - /* SIGUSR2 forces udhcpc to release the current lease and go inactive, - * and SIGTERM causes udhcpc to exit. Signals are queued and processed - * sequentially so we don't need to sleep */ - if (execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec) - || execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec)) - return 1; if (execute("pump -i %iface% -k", ifd, exec)) return 1; - if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null", ifd, exec)) return 1; + if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null", + ifd, exec)) return 1; if (execute("dhcpcd -k %iface%", ifd, exec)) return 1; + return static_down(ifd, exec); } +static int manual_up_down(struct interface_defn_t *ifd, execfn *exec) +{ + return 1; +} + static int bootp_up(struct interface_defn_t *ifd, execfn *exec) { return execute("bootpc [[--bootfile %bootfile%]] --dev %iface% " @@ -521,6 +524,7 @@ } static const struct method_t methods[] = { + { "manual", manual_up_down, manual_up_down, }, { "wvdial", wvdial_up, wvdial_down, }, { "ppp", ppp_up, ppp_down, }, { "static", static_up, static_down, }, From bugs at busybox.net Mon Oct 2 23:14:03 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Mon, 2 Oct 2006 23:14:03 -0700 Subject: [BusyBox 0001060]: mmap(2) doesn't work on Blackfin in insmod (probably in other pacles too) Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1060 ====================================================================== Reported By: landau Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1060 Category: Kernel Module Support Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 10-02-2006 23:14 PDT Last Modified: 10-02-2006 23:14 PDT ====================================================================== Summary: mmap(2) doesn't work on Blackfin in insmod (probably in other pacles too) Description: Blackfin as a no-mmu architecture has spased support for mmap(2). One place I encountered where it doesn't work is insmod (the one for 2.6.x kernels). The attached patch uses read(2) if mmap(2) fails. This solves the problem for Blackfin and shouldn't hurn anyone with an MMU. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 10-02-06 23:14 landau New Issue 10-02-06 23:14 landau Status new => assigned 10-02-06 23:14 landau Assigned To => BusyBox 10-02-06 23:14 landau File Added: insmod.patch ====================================================================== From bugs at busybox.net Mon Oct 2 23:29:37 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Mon, 2 Oct 2006 23:29:37 -0700 Subject: [BusyBox 0001061]: udhcpc searches file in a wrong (not FHS and the like) path Message-ID: <8224f2cab23b314b8f8d749597042121@busybox.net> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1061 ====================================================================== Reported By: landau Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1061 Category: Standards Compliance Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 10-02-2006 23:29 PDT Last Modified: 10-02-2006 23:29 PDT ====================================================================== Summary: udhcpc searches file in a wrong (not FHS and the like) path Description: When busybox is compiled with CONFIG_INSTALL_NO_USR=y, the default.script used by udhcpc is searched in /share/udhcpc/default.script instead of /usr/share/udhcpc/default.script. I know it may be by design, but I think busybox can use or not use the standard hierarchy, but not create its own one. The attached patch makes udhcpc search default.script in /usr even when busybox is compiled with CONFIG_INSTALL_NO_USR=y. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 10-02-06 23:29 landau New Issue 10-02-06 23:29 landau Status new => assigned 10-02-06 23:29 landau Assigned To => BusyBox 10-02-06 23:29 landau File Added: udhcp.patch ====================================================================== From vda at busybox.net Tue Oct 3 03:47:35 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 03:47:35 -0700 (PDT) Subject: svn commit: trunk/busybox/networking Message-ID: <20061003104735.F06164858C@busybox.net> Author: vda Date: 2006-10-03 03:47:35 -0700 (Tue, 03 Oct 2006) New Revision: 16295 Log: traceroute: do not look up icmp protocol# in /etc, it is well-known :) Modified: trunk/busybox/networking/traceroute.c Changeset: Modified: trunk/busybox/networking/traceroute.c =================================================================== --- trunk/busybox/networking/traceroute.c 2006-10-02 20:57:10 UTC (rev 16294) +++ trunk/busybox/networking/traceroute.c 2006-10-03 10:47:35 UTC (rev 16295) @@ -224,6 +224,7 @@ #include #include #include +#include #include #include #include @@ -921,14 +922,12 @@ traceroute_main(int argc, char *argv[]) { int code, n; - char *cp; unsigned char *outp; u_int32_t *ap; struct sockaddr_in *from = (struct sockaddr_in *)&wherefrom; struct sockaddr_in *to = (struct sockaddr_in *)&whereto; struct hostinfo *hi; int on = 1; - struct protoent *pe; int ttl, probe, i; int seq = 0; int tos = 0; @@ -1076,16 +1075,12 @@ bb_show_usage(); } - cp = "icmp"; - if ((pe = getprotobyname(cp)) == NULL) - bb_perror_msg_and_die("unknown protocol %s", cp); - /* Insure the socket fds won't be 0, 1 or 2 */ do n = xopen(bb_dev_null, O_RDONLY); while (n < 2); if (n > 2) close(n); - s = xsocket(AF_INET, SOCK_RAW, pe->p_proto); + s = xsocket(AF_INET, SOCK_RAW, IP_ICMP); #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG if (op & USAGE_OP_DEBUG) From bugs at busybox.net Tue Oct 3 04:24:16 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 3 Oct 2006 04:24:16 -0700 Subject: [BusyBox 0001062]: grep -C fails Message-ID: <24bed68584c3fd77cd15c238ac5e31d9@bugs.busybox.net> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1062 ====================================================================== Reported By: ykaliuta Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1062 Category: Other Reproducibility: always Severity: crash Priority: normal Status: assigned ====================================================================== Date Submitted: 10-03-2006 04:24 PDT Last Modified: 10-03-2006 04:24 PDT ====================================================================== Summary: grep -C fails Description: -C require an argument but there is no ':' in the declaration. Different effects on parsing ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 10-03-06 04:24 ykaliuta New Issue 10-03-06 04:24 ykaliuta Status new => assigned 10-03-06 04:24 ykaliuta Assigned To => BusyBox 10-03-06 04:24 ykaliuta File Added: context-fix.diff ====================================================================== From bugs at busybox.net Tue Oct 3 04:34:29 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 3 Oct 2006 04:34:29 -0700 Subject: [BusyBox 0001062]: grep -C fails Message-ID: <850d7a4c88bc80a238c56dc17b201169@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1062 ====================================================================== Reported By: ykaliuta Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1062 Category: Other Reproducibility: always Severity: crash Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 10-03-2006 04:24 PDT Last Modified: 10-03-2006 04:34 PDT ====================================================================== Summary: grep -C fails Description: -C require an argument but there is no ':' in the declaration. Different effects on parsing ====================================================================== ---------------------------------------------------------------------- bernhardf - 10-03-06 04:34 ---------------------------------------------------------------------- This was fixed back in r16220 Issue History Date Modified Username Field Change ====================================================================== 10-03-06 04:24 ykaliuta New Issue 10-03-06 04:24 ykaliuta Status new => assigned 10-03-06 04:24 ykaliuta Assigned To => BusyBox 10-03-06 04:24 ykaliuta File Added: context-fix.diff 10-03-06 04:34 bernhardf Status assigned => closed 10-03-06 04:34 bernhardf Note Added: 0001684 ====================================================================== From vda at busybox.net Tue Oct 3 08:57:41 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 08:57:41 -0700 (PDT) Subject: svn commit: trunk/busybox: coreutils include libbb Message-ID: <20061003155741.0D14C48582@busybox.net> Author: vda Date: 2006-10-03 08:57:40 -0700 (Tue, 03 Oct 2006) New Revision: 16298 Log: runit/chpst: "change process state" utility It's "nice" on steroids - can set uid/gid, mem/cpu limits etc. +3.5k Modified: trunk/busybox/Config.in trunk/busybox/Makefile trunk/busybox/coreutils/env.c trunk/busybox/include/applets.h trunk/busybox/include/libbb.h trunk/busybox/include/usage.h trunk/busybox/libbb/setup_environment.c trunk/busybox/libbb/xfuncs.c Changeset: Modified: trunk/busybox/Config.in =================================================================== --- trunk/busybox/Config.in 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/Config.in 2006-10-03 15:57:40 UTC (rev 16298) @@ -470,3 +470,4 @@ source procps/Config.in source shell/Config.in source sysklogd/Config.in +source runit/Config.in Modified: trunk/busybox/Makefile =================================================================== --- trunk/busybox/Makefile 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/Makefile 2006-10-03 15:57:40 UTC (rev 16298) @@ -34,7 +34,8 @@ DIRS:=applets archival archival/libunarchive coreutils console-tools \ debianutils editors findutils init miscutils modutils networking \ networking/libiproute networking/udhcp procps loginutils shell \ - sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb + sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils \ + runit libbb SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) Modified: trunk/busybox/coreutils/env.c =================================================================== --- trunk/busybox/coreutils/env.c 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/coreutils/env.c 2006-10-03 15:57:40 UTC (rev 16298) @@ -63,10 +63,10 @@ ++argv; } - if(opt & 1) + if (opt & 1) environ = cleanenv; - else if(opt & 2) { - while(unset_env) { + else if (opt & 2) { + while (unset_env) { unsetenv(unset_env->data); unset_env = unset_env->link; } Modified: trunk/busybox/include/applets.h =================================================================== --- trunk/busybox/include/applets.h 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/include/applets.h 2006-10-03 15:57:40 UTC (rev 16298) @@ -70,6 +70,7 @@ USE_CHGRP(APPLET(chgrp, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_CHMOD(APPLET(chmod, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_CHOWN(APPLET(chown, _BB_DIR_BIN, _BB_SUID_NEVER)) +USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_CHROOT(APPLET(chroot, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_CHVT(APPLET(chvt, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_CKSUM(APPLET(cksum, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) @@ -106,6 +107,8 @@ USE_FEATURE_GREP_EGREP_ALIAS(APPLET_NOUSAGE(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir)) +USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid)) USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake)) USE_EXPR(APPLET(expr, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) @@ -244,12 +247,14 @@ USE_SETKEYCODES(APPLET(setkeycodes, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_SETLOGCONS(APPLET(setlogcons, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_SETSID(APPLET(setsid, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, setuidgid)) USE_FEATURE_SH_IS_ASH(APPLET_NOUSAGE(sh, ash, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FEATURE_SH_IS_HUSH(APPLET_NOUSAGE(sh, hush, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum)) USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER)) +USE_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, softlimit)) USE_SORT(APPLET(sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_NEVER, start_stop_daemon)) USE_STAT(APPLET(stat, _BB_DIR_BIN, _BB_SUID_NEVER)) Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/include/libbb.h 2006-10-03 15:57:40 UTC (rev 16298) @@ -488,12 +488,13 @@ extern void set_current_security_context(security_context_t sid); #endif extern int run_parts(char **args, const unsigned char test_mode, char **env); -extern int restricted_shell ( const char *shell ); -extern void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ); -extern int correct_password ( const struct passwd *pw ); +extern int restricted_shell(const char *shell); +extern void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw); +extern int correct_password(const struct passwd *pw); extern char *pw_encrypt(const char *clear, const char *salt); extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); +extern void xsetenv(const char *key, const char *value); extern int xopen(const char *pathname, int flags); extern int xopen3(const char *pathname, int flags, int mode); extern void xread(int fd, void *buf, size_t count); Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/include/usage.h 2006-10-03 15:57:40 UTC (rev 16298) @@ -215,6 +215,70 @@ "ls -l /tmp/foo\n" \ "-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n" +#define chpst_trivial_usage \ + "[-vP012] [-u user[:group]] [-U user[:group]] [-e dir] " \ + "[-/ dir] [-n nice] [-m bytes] [-d bytes] [-o files] " \ + "[-p processes] [-f bytes] [-c bytes] prog args" +#define chpst_full_usage \ + "Change the process state and run specified program.\n\n" \ + "-u user[:grp] set uid and gid\n" \ + "-U user[:grp] set environment variables UID and GID\n" \ + "-e dir set environment variables as specified by files\n" \ + " in the directory: file=1st_line_of_file\n" \ + "-/ dir chroot to dir\n" \ + "-n inc add inc to nice value\n" \ + "-m bytes limit data segment, stack segment, locked physical pages,\n" \ + " and total of all segment per process to bytes bytes each\n" \ + "-d bytes limit data segment\n" \ + "-o n limit the number of open file descriptors per process to n\n" \ + "-p n limit number of processes per uid to n\n" \ + "-f bytes limit output file size to bytes bytes\n" \ + "-c bytes limit core file size to bytes bytes\n" \ + "-v verbose\n" \ + "-P run prog in a new process group\n" \ + "-0 close standard input\n" \ + "-1 close standard output\n" \ + "-2 close standard error" +#define setuidgid_trivial_usage \ + "account prog args" +#define setuidgid_full_usage \ + "Sets uid and gid to account's uid and gid, removing all supplementary\n" \ + "groups, then runs prog" +#define envuidgid_trivial_usage \ + "account prog args" +#define envuidgid_full_usage \ + "Sets $UID to account's uid and $GID to account's gid, then runs prog" +#define envdir_trivial_usage \ + "dir prog args" +#define envdir_full_usage \ + "Sets various environment variables as specified by files\n" \ + "in the directory dir, then runs prog" +#define softlimit_trivial_usage \ + "[-a allbytes] [-c corebytes] [-d databytes] [-f filebytes] " \ + "[-l lockbytes] [-m membytes] [-o openfiles] [-p processes] " \ + "[-r residentbytes] [-s stackbytes] [-t cpusecs] prog args" +#define softlimit_full_usage \ + "Sets soft resource limits as specified by options, then runs prog\n" \ + "\n" \ + "-m n Same as -d n -s n -l n -a n\n" \ + "-d n Limit the data segment per process to n bytes\n" \ + "-s n Limit the stack segment per process to n bytes\n" \ + "-l n Limit the locked physical pages per process to n bytes\n" \ + "-a n Limit the total of all segments per process to n bytes\n" \ + "-o n Limit the number of open file descriptors per process to n\n" \ + "-p n Limit the number of processes per uid to n\n" \ + "Options controlling file sizes:\n" \ + "-f n Limit output file sizes to n bytes\n" \ + "-c n Limit core file sizes to n bytes\n" \ + "Efficiency opts:\n" \ + "-r n Limit the resident set size to n bytes. This limit is not\n" \ + " enforced unless physical memory is full\n" \ + "-t n Limit the CPU time to n seconds. This limit is not enforced\n" \ + " except that the process receives a SIGXCPU signal after n seconds\n" \ + "\n" \ + "Some options may have no effect on some operating systems\n" \ + "n may be =, indicating that soft limit should be set equal to hard limit" + #define chroot_trivial_usage \ "NEWROOT [COMMAND...]" #define chroot_full_usage \ Modified: trunk/busybox/libbb/setup_environment.c =================================================================== --- trunk/busybox/libbb/setup_environment.c 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/libbb/setup_environment.c 2006-10-03 15:57:40 UTC (rev 16298) @@ -42,15 +42,9 @@ #define DEFAULT_LOGIN_PATH "/bin:/usr/bin" #define DEFAULT_ROOT_LOGIN_PATH "/usr/sbin:/bin:/usr/bin:/sbin" -static void xsetenv ( const char *key, const char *value ) +void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw) { - if ( setenv ( key, value, 1 )) - bb_error_msg_and_die (bb_msg_memory_exhausted); -} - -void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ) -{ - if ( loginshell ) { + if (loginshell) { const char *term; /* Change the current working directory to be the home directory @@ -59,32 +53,31 @@ * directory. * Some systems default to HOME=/ */ - if ( chdir ( pw-> pw_dir )) { - xchdir ( "/" ); - fputs ( "warning: cannot change to home directory\n", stderr ); + if (chdir(pw->pw_dir)) { + xchdir("/"); + fputs("warning: cannot change to home directory\n", stderr); } /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. Unset all other environment variables. */ - term = getenv ("TERM"); - clearenv ( ); - if ( term ) - xsetenv ( "TERM", term ); - xsetenv ( "HOME", pw-> pw_dir ); - xsetenv ( "SHELL", shell ); - xsetenv ( "USER", pw-> pw_name ); - xsetenv ( "LOGNAME", pw-> pw_name ); - xsetenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH )); + term = getenv("TERM"); + clearenv(); + if (term) + xsetenv("TERM", term); + xsetenv("HOME", pw->pw_dir); + xsetenv("SHELL", shell); + xsetenv("USER", pw->pw_name); + xsetenv("LOGNAME", pw->pw_name); + xsetenv("PATH", (pw->pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH)); } - else if ( changeenv ) { + else if (changeenv) { /* Set HOME, SHELL, and if not becoming a super-user, USER and LOGNAME. */ - xsetenv ( "HOME", pw-> pw_dir ); - xsetenv ( "SHELL", shell ); - if ( pw-> pw_uid ) { - xsetenv ( "USER", pw-> pw_name ); - xsetenv ( "LOGNAME", pw-> pw_name ); + xsetenv("HOME", pw->pw_dir); + xsetenv("SHELL", shell); + if (pw->pw_uid) { + xsetenv("USER", pw->pw_name); + xsetenv("LOGNAME", pw->pw_name); } } } - Modified: trunk/busybox/libbb/xfuncs.c =================================================================== --- trunk/busybox/libbb/xfuncs.c 2006-10-03 14:11:12 UTC (rev 16297) +++ trunk/busybox/libbb/xfuncs.c 2006-10-03 15:57:40 UTC (rev 16298) @@ -255,6 +255,14 @@ } #endif +#ifdef L_xsetenv +void xsetenv(const char *key, const char *value) +{ + if(setenv(key, value, 1)) + bb_error_msg_and_die(bb_msg_memory_exhausted); +} +#endif + #ifdef L_itoa // Convert unsigned integer to ascii, writing into supplied buffer. A // truncated result is always null terminated (unless buflen is 0), and From vda at busybox.net Tue Oct 3 10:52:25 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 10:52:25 -0700 (PDT) Subject: svn commit: trunk/busybox: runit Message-ID: <20061003175225.5959F4858F@busybox.net> Author: vda Date: 2006-10-03 10:52:24 -0700 (Tue, 03 Oct 2006) New Revision: 16299 Log: Yeah, yeah... I forgot about 'svn add'... fixing that Added: trunk/busybox/runit/ trunk/busybox/runit/Config.in trunk/busybox/runit/Makefile trunk/busybox/runit/Makefile.in trunk/busybox/runit/chpst.c trunk/busybox/runit/uidgid.c trunk/busybox/runit/uidgid.h Changeset: Added: trunk/busybox/runit/Config.in =================================================================== --- trunk/busybox/runit/Config.in 2006-10-03 15:57:40 UTC (rev 16298) +++ trunk/busybox/runit/Config.in 2006-10-03 17:52:24 UTC (rev 16299) @@ -0,0 +1,36 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + +menu "Runit Utilities" + +config CONFIG_CHPST + bool "chpst" + default n + help + chpst changes the process state according to the given options, and + execs specified program. + +config CONFIG_SETUIDGID + bool "setuidgid" + help + Sets soft resource limits as specified by options + +config CONFIG_ENVUIDGID + bool "envuidgid" + help + Sets $UID to account's uid and $GID to account's gid + +config CONFIG_ENVDIR + bool "envdir" + help + Sets various environment variables as specified by files + in the given directory + +config CONFIG_SOFTLIMIT + bool "softlimit" + help + Sets soft resource limits as specified by options + +endmenu Added: trunk/busybox/runit/Makefile =================================================================== --- trunk/busybox/runit/Makefile 2006-10-03 15:57:40 UTC (rev 16298) +++ trunk/busybox/runit/Makefile 2006-10-03 17:52:24 UTC (rev 16299) @@ -0,0 +1,23 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +ifndef top_srcdir +top_srcdir=.. +endif +ifndef top_builddir +top_builddir=.. +endif +srcdir=$(top_srcdir)/runit +RUNIT_DIR:=./ +include $(top_srcdir)/Rules.mak +include $(top_builddir)/.config +include Makefile.in +all: $(libraries-y) +-include $(top_builddir)/.depend + +clean: + rm -f *.o *.a $(AR_TARGET) + Added: trunk/busybox/runit/Makefile.in =================================================================== --- trunk/busybox/runit/Makefile.in 2006-10-03 15:57:40 UTC (rev 16298) +++ trunk/busybox/runit/Makefile.in 2006-10-03 17:52:24 UTC (rev 16299) @@ -0,0 +1,42 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +RUNIT_AR:=runit.a +ifndef RUNIT_DIR +RUNIT_DIR:=$(top_builddir)/runit/ +endif +srcdir=$(top_srcdir)/runit + +#unix_a:=buffer.o \ +#buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o \ +#fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \ +#ndelay_off.o ndelay_on.o open_append.o open_read.o \ +#open_trunc.o open_write.o openreadclose.o pathexec_env.o \ +#pathexec_run.o prot.o readclose.o seek_set.o sig.o \ +#sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ +#stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ +#stralloc_pend.o wait_nohang.o \ +#wait_pid.o + +RUNIT-y:= +RUNIT-$(CONFIG_CHPST) += chpst.o uidgid.o + +RUNIT-y:=$(sort $(RUNIT-y)) + +ifneq ($(strip $(RUNIT-y)),) +libraries-y+=$(RUNIT_DIR)$(RUNIT_AR) +endif + +RUNIT_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(RUNIT-y)) +RUNIT_SRC-a:=$(wildcard $(srcdir)/*.c) +APPLET_SRC-y+=$(RUNIT_SRC-y) +APPLET_SRC-a+=$(RUNIT_SRC-a) + +$(RUNIT_DIR)$(RUNIT_AR): $(patsubst %,$(RUNIT_DIR)%, $(RUNIT-y)) + $(do_ar) + +$(RUNIT_DIR)%.o: $(srcdir)/%.c + $(compile.c) Added: trunk/busybox/runit/chpst.c =================================================================== --- trunk/busybox/runit/chpst.c 2006-10-03 15:57:40 UTC (rev 16298) +++ trunk/busybox/runit/chpst.c 2006-10-03 17:52:24 UTC (rev 16299) @@ -0,0 +1,345 @@ +#include "busybox.h" + +#include +#include +#include + +#include "uidgid.h" + +#include +#include + +static unsigned option_mask; +// Must meatch constants in chpst_main! +#define OPT_verbose (option_mask & 0x2000) +#define OPT_pgrp (option_mask & 0x4000) +#define OPT_nostdin (option_mask & 0x8000) +#define OPT_nostdout (option_mask & 0x10000) +#define OPT_nostderr (option_mask & 0x20000) + +static char *set_user; +static char *env_user; +static const char *env_dir; +static long limitd = -2; +static long limits = -2; +static long limitl = -2; +static long limita = -2; +static long limito = -2; +static long limitp = -2; +static long limitf = -2; +static long limitc = -2; +static long limitr = -2; +static long limitt = -2; +static long nicelvl; +static const char *root; + +static void suidgid(char *user, unsigned dogrp) +{ + struct uidgid ugid; + + if (!uidgid_get(&ugid, user, dogrp)) { + if (dogrp) + bb_error_msg_and_die("unknown user/group: %s", user); + else + bb_error_msg_and_die("unknown account: %s", user); + } + if (setgroups(ugid.gids, ugid.gid) == -1) + bb_perror_msg_and_die("setgroups"); + xsetgid(*ugid.gid); + xsetuid(ugid.uid); +} + +static void euidgid(char *user, unsigned dogrp) +{ + struct uidgid ugid; + + if (!uidgid_get(&ugid, user, dogrp)) { + if (dogrp) + bb_error_msg_and_die("unknown user/group: %s", user); + else + bb_error_msg_and_die("unknown account: %s", user); + } + //FIXME: ultoa needed here! + xsetenv("GID", utoa(*ugid.gid)); + xsetenv("UID", utoa(ugid.uid)); +} + +static void edir(const char *directory_name) +{ + int wdir; + DIR *dir; + struct dirent *d; + int fd; + + wdir = xopen(".", O_RDONLY | O_NDELAY); + xchdir(directory_name); + dir = opendir("."); + if (!dir) + bb_perror_msg_and_die("opendir %s", directory_name); + for (;;) { + errno = 0; + d = readdir(dir); + if (!d) { + if (errno) bb_perror_msg_and_die("readdir %s", directory_name); + break; + } + if (d->d_name[0] == '.') continue; + fd = open(d->d_name, O_RDONLY | O_NDELAY); + if (fd < 0) { + if ((errno == EISDIR) && env_dir) { + if (OPT_verbose) + bb_perror_msg("warning: %s/%s is a directory", directory_name, + d->d_name); + continue; + } else + bb_perror_msg_and_die("open %s/%s", directory_name, /* was exiting 111 */ + d->d_name); + } + if (fd >= 0) { + char buf[256]; + char *tail; + int size; + + size = safe_read(fd, buf, sizeof(buf)-1); + if (size < 0) + bb_perror_msg_and_die("read %s/%s", directory_name, /* was exiting 111 */ + d->d_name); + if (size == 0) { + xsetenv(d->d_name, ""); + continue; + } + buf[size] = '\n'; + tail = memchr(buf, '\n', sizeof(buf)); + /* skip trailing whitespace */; + while (1) { + if (tail[0]==' ') tail[0] = '\0'; + if (tail[0]=='\t') tail[0] = '\0'; + if (tail[0]=='\n') tail[0] = '\0'; + if (tail == buf) break; + tail--; + } + xsetenv(d->d_name, buf); + } + } + closedir(dir); + if (fchdir(wdir) == -1) bb_perror_msg_and_die("fchdir"); + close(wdir); +} + +static void limit(int what, long l) +{ + struct rlimit r; + + if (getrlimit(what, &r) == -1) bb_perror_msg_and_die("getrlimit"); + if ((l < 0) || (l > r.rlim_max)) + r.rlim_cur = r.rlim_max; + else + r.rlim_cur = l; + if (setrlimit(what, &r) == -1) bb_perror_msg_and_die("setrlimit"); +} + +static void slimit(void) +{ + if (limitd >= -1) { +#ifdef RLIMIT_DATA + limit(RLIMIT_DATA, limitd); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_DATA"); +#endif + } + if (limits >= -1) { +#ifdef RLIMIT_STACK + limit(RLIMIT_STACK, limits); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_STACK"); +#endif + } + if (limitl >= -1) { +#ifdef RLIMIT_MEMLOCK + limit(RLIMIT_MEMLOCK, limitl); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_MEMLOCK"); +#endif + } + if (limita >= -1) { +#ifdef RLIMIT_VMEM + limit(RLIMIT_VMEM, limita); +#else +#ifdef RLIMIT_AS + limit(RLIMIT_AS, limita); +#else + if (OPT_verbose) + bb_error_msg("system does not support %s", "RLIMIT_VMEM"); +#endif +#endif + } + if (limito >= -1) { +#ifdef RLIMIT_NOFILE + limit(RLIMIT_NOFILE, limito); +#else +#ifdef RLIMIT_OFILE + limit(RLIMIT_OFILE, limito); +#else + if (OPT_verbose) + bb_error_msg("system does not support %s", "RLIMIT_NOFILE"); +#endif +#endif + } + if (limitp >= -1) { +#ifdef RLIMIT_NPROC + limit(RLIMIT_NPROC, limitp); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_NPROC"); +#endif + } + if (limitf >= -1) { +#ifdef RLIMIT_FSIZE + limit(RLIMIT_FSIZE, limitf); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_FSIZE"); +#endif + } + if (limitc >= -1) { +#ifdef RLIMIT_CORE + limit(RLIMIT_CORE, limitc); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_CORE"); +#endif + } + if (limitr >= -1) { +#ifdef RLIMIT_RSS + limit(RLIMIT_RSS, limitr); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_RSS"); +#endif + } + if (limitt >= -1) { +#ifdef RLIMIT_CPU + limit(RLIMIT_CPU, limitt); +#else + if (OPT_verbose) bb_error_msg("system does not support %s", "RLIMIT_CPU"); +#endif + } +} + +/* argv[0] */ +static void setuidgid(int, char **); +static void envuidgid(int, char **); +static void envdir(int, char **); +static void softlimit(int, char **); + +int chpst_main(int argc, char **argv) +{ + if (bb_applet_name[3] == 'd') envdir(argc, argv); + if (bb_applet_name[1] == 'o') softlimit(argc, argv); + if (bb_applet_name[0] == 's') setuidgid(argc, argv); + if (bb_applet_name[0] == 'e') envuidgid(argc, argv); + // otherwise we are.......... chpst + + { + char *m,*d,*o,*p,*f,*c,*r,*t,*n; + option_mask = bb_getopt_ulflags(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012", + &set_user,&env_user,&env_dir, + &m,&d,&o,&p,&f,&c,&r,&t,&root,&n); + // if (option_mask & 0x1) // -u + // if (option_mask & 0x2) // -U + // if (option_mask & 0x4) // -e + if (option_mask & 0x8) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m + if (option_mask & 0x10) limitd = bb_xgetularg10(d); // -d + if (option_mask & 0x20) limito = bb_xgetularg10(o); // -o + if (option_mask & 0x40) limitp = bb_xgetularg10(p); // -p + if (option_mask & 0x80) limitf = bb_xgetularg10(f); // -f + if (option_mask & 0x100) limitc = bb_xgetularg10(c); // -c + if (option_mask & 0x200) limitr = bb_xgetularg10(r); // -r + if (option_mask & 0x400) limitt = bb_xgetularg10(t); // -t + // if (option_mask & 0x800) // -/ + if (option_mask & 0x1000) nicelvl = bb_xgetlarg_bnd_sfx(n, 10, -20, 20, NULL); // -n + // The below consts should match #defines at top! + //if (option_mask & 0x2000) OPT_verbose = 1; // -v + //if (option_mask & 0x4000) OPT_pgrp = 1; // -P + //if (option_mask & 0x8000) OPT_nostdin = 1; // -0 + //if (option_mask & 0x10000) OPT_nostdout = 1; // -1 + //if (option_mask & 0x20000) OPT_nostderr = 1; // -2 + } + if (!argv || !*argv) bb_show_usage(); + + if (OPT_pgrp) setsid(); + if (env_dir) edir(env_dir); + if (root) { + xchdir(root); + if (chroot(".") == -1) + bb_perror_msg_and_die("chroot"); + } + slimit(); + if (nicelvl) { + errno = 0; + if (nice(nicelvl) == -1) + bb_perror_msg_and_die("nice"); + } + if (env_user) euidgid(env_user, 1); + if (set_user) suidgid(set_user, 1); + if (OPT_nostdin) close(0); + if (OPT_nostdout) close(1); + if (OPT_nostderr) close(2); + execvp(argv[0], argv); + bb_perror_msg_and_die("exec %s", argv[0]); +} + +static void setuidgid(int argc, char **argv) +{ + const char *account; + + account = *++argv; + if (!account) bb_show_usage(); + if (!*++argv) bb_show_usage(); + suidgid((char*)account, 0); + execvp(argv[0], argv); + bb_perror_msg_and_die("exec %s", argv[0]); +} + +static void envuidgid(int argc, char **argv) +{ + const char *account; + + account = *++argv; + if (!account) bb_show_usage(); + if (!*++argv) bb_show_usage(); + euidgid((char*)account, 0); + execvp(argv[0], argv); + bb_perror_msg_and_die("exec %s", argv[0]); +} + +static void envdir(int argc, char **argv) +{ + const char *dir; + + dir = *++argv; + if (!dir) bb_show_usage(); + if (!*++argv) bb_show_usage(); + edir(dir); + execvp(argv[0], argv); + bb_perror_msg_and_die("exec %s", argv[0]); +} + +static void softlimit(int argc, char **argv) +{ + char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t; + option_mask = bb_getopt_ulflags(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", + &a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t); + if (option_mask & 0x001) limita = bb_xgetularg10(a); // -a + if (option_mask & 0x002) limitc = bb_xgetularg10(c); // -c + if (option_mask & 0x004) limitd = bb_xgetularg10(d); // -d + if (option_mask & 0x008) limitf = bb_xgetularg10(f); // -f + if (option_mask & 0x010) limitl = bb_xgetularg10(l); // -l + if (option_mask & 0x020) limits = limitl = limita = limitd = bb_xgetularg10(m); // -m + if (option_mask & 0x040) limito = bb_xgetularg10(o); // -o + if (option_mask & 0x080) limitp = bb_xgetularg10(p); // -p + if (option_mask & 0x100) limitr = bb_xgetularg10(r); // -r + if (option_mask & 0x200) limits = bb_xgetularg10(s); // -s + if (option_mask & 0x400) limitt = bb_xgetularg10(t); // -t + argv += optind; + if (!argv[0]) bb_show_usage(); + slimit(); + execvp(argv[0], argv); + bb_perror_msg_and_die("exec %s", argv[0]); +} Added: trunk/busybox/runit/uidgid.c =================================================================== --- trunk/busybox/runit/uidgid.c 2006-10-03 15:57:40 UTC (rev 16298) +++ trunk/busybox/runit/uidgid.c 2006-10-03 17:52:24 UTC (rev 16299) @@ -0,0 +1,63 @@ +#include +#include +#include +#include "uidgid.h" + +static unsigned str_chr(const char *s, int c) +{ + const char *t = s; + while (t[0] && t[0] != (char)c) + t++; + return t - s; +} + + +unsigned uidgid_get(struct uidgid *u, char *ug, unsigned dogrp) { + char *g = 0; + struct passwd *pwd = 0; + struct group *gr = 0; + int i, d = 0; + + if (dogrp) + d = str_chr(ug, ':'); + if (ug[d] == ':') { + ug[d] = 0; + g = ug + d + 1; + } + pwd = getpwnam(ug); + if (!pwd) { + if (g) ug[d] = ':'; + return 0; + } + if (g) { + ug[d] = ':'; + for (i = 0; i < 60; ++i) { + d = str_chr(g, ':'); + if (g[d] == ':') { + g[d] = 0; + gr = getgrnam(g); + if (!gr) { + g[d] = ':'; + return 0; + } + g[d] = ':'; + u->gid[i] = gr->gr_gid; + g += d+1; + } + else { + gr = getgrnam(g); + if (!gr) return 0; + u->gid[i++] = gr->gr_gid; + break; + } + } + u->gid[i] = 0; + u->gids = i; + } + if (!g) { + u->gid[0] = pwd->pw_gid; + u->gids = 1; + } + u->uid = pwd->pw_uid; + return 1; +} Added: trunk/busybox/runit/uidgid.h =================================================================== --- trunk/busybox/runit/uidgid.h 2006-10-03 15:57:40 UTC (rev 16298) +++ trunk/busybox/runit/uidgid.h 2006-10-03 17:52:24 UTC (rev 16299) @@ -0,0 +1,14 @@ +#ifndef UIDGID_H +#define UIDGID_H + +#include + +struct uidgid { + uid_t uid; + gid_t gid[61]; + int gids; +}; + +extern unsigned uidgid_get(struct uidgid *, char *, unsigned); + +#endif From vda at busybox.net Tue Oct 3 11:19:03 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 11:19:03 -0700 (PDT) Subject: svn commit: trunk/busybox/networking Message-ID: <20061003181903.91F1D48587@busybox.net> Author: vda Date: 2006-10-03 11:19:02 -0700 (Tue, 03 Oct 2006) New Revision: 16300 Log: traceroute: fix compilation if netinet/protocols.h is missing Modified: trunk/busybox/networking/traceroute.c Changeset: Modified: trunk/busybox/networking/traceroute.c =================================================================== --- trunk/busybox/networking/traceroute.c 2006-10-03 17:52:24 UTC (rev 16299) +++ trunk/busybox/networking/traceroute.c 2006-10-03 18:19:02 UTC (rev 16300) @@ -204,27 +204,11 @@ #undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP //#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include #include "inet_common.h" #include -#include #include -#include +#include #include #include #include @@ -236,8 +220,16 @@ * Definitions for internet protocol version 4. * Per RFC 791, September 1981. */ -#define IPVERSION 4 +#define IPVERSION 4 +#ifndef IPPROTO_ICMP +/* Grrrr.... */ +#define IPPROTO_ICMP 1 +#endif +#ifndef IPPROTO_IP +#define IPPROTO_IP 0 +#endif + /* * Overlay for ip header used by other protocols (tcp, udp). */ @@ -1080,7 +1072,7 @@ if (n > 2) close(n); - s = xsocket(AF_INET, SOCK_RAW, IP_ICMP); + s = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP); #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG if (op & USAGE_OP_DEBUG) @@ -1098,10 +1090,6 @@ if (lsrr > 0) { unsigned char optlist[MAX_IPOPTLEN]; - cp = "ip"; - if ((pe = getprotobyname(cp)) == NULL) - bb_perror_msg_and_die("unknown protocol"); - /* final hop */ gwlist[lsrr] = to->sin_addr.s_addr; ++lsrr; @@ -1116,10 +1104,10 @@ optlist[3] = IPOPT_MINOFF; memcpy(optlist + 4, gwlist, i); - if ((setsockopt(sndsock, pe->p_proto, IP_OPTIONS, + if ((setsockopt(sndsock, IPPROTO_IP, IP_OPTIONS, (char *)optlist, i + sizeof(gwlist[0]))) < 0) { bb_perror_msg_and_die("IP_OPTIONS"); - } + } } #endif /* IP_OPTIONS */ #endif /* CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE */ From vda at busybox.net Tue Oct 3 12:02:21 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 12:02:21 -0700 (PDT) Subject: svn commit: trunk/busybox: archival include libbb Message-ID: <20061003190221.97231485AD@busybox.net> Author: vda Date: 2006-10-03 12:02:20 -0700 (Tue, 03 Oct 2006) New Revision: 16301 Log: random style fixes Modified: trunk/busybox/archival/rpm.c trunk/busybox/include/libbb.h trunk/busybox/libbb/bb_pwd.c trunk/busybox/libbb/parse_number.c Changeset: Modified: trunk/busybox/archival/rpm.c =================================================================== --- trunk/busybox/archival/rpm.c 2006-10-03 18:19:02 UTC (rev 16300) +++ trunk/busybox/archival/rpm.c 2006-10-03 19:02:20 UTC (rev 16301) @@ -303,7 +303,7 @@ int uid, gid; uid = bb_xgetpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref)); gid = bb_xgetgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref)); - chown (filename, uid, gid); + chown(filename, uid, gid); } static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref)) Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2006-10-03 18:19:02 UTC (rev 16300) +++ trunk/busybox/include/libbb.h 2006-10-03 19:02:20 UTC (rev 16301) @@ -163,7 +163,6 @@ void* userData); extern int bb_parse_mode( const char* s, mode_t* theMode); -extern long bb_xgetlarg(const char *arg, int base, long lower, long upper); extern unsigned int tty_baud_to_value(speed_t speed); extern speed_t tty_value_to_baud(unsigned int value); @@ -258,21 +257,24 @@ }; extern unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base, - unsigned long lower, - unsigned long upper, - const struct suffix_mult *suffixes); + unsigned long lower, + unsigned long upper, + const struct suffix_mult *suffixes); extern unsigned long bb_xgetularg_bnd(const char *arg, int base, - unsigned long lower, - unsigned long upper); + unsigned long lower, + unsigned long upper); extern unsigned long bb_xgetularg10_bnd(const char *arg, - unsigned long lower, - unsigned long upper); + unsigned long lower, + unsigned long upper); extern unsigned long bb_xgetularg10(const char *arg); +extern long bb_xgetlarg(const char *arg, int base, + long lower, + long upper); extern long bb_xgetlarg_bnd_sfx(const char *arg, int base, - long lower, - long upper, - const struct suffix_mult *suffixes); + long lower, + long upper, + const struct suffix_mult *suffixes); extern long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes); @@ -285,9 +287,9 @@ * increases target size and is often not needed on embedded systems. */ extern long bb_xgetpwnam(const char *name); extern long bb_xgetgrnam(const char *name); -extern char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix); -extern char * bb_getpwuid(char *name, long uid, int bufsize); -extern char * bb_getgrgid(char *group, long gid, int bufsize); +extern char *bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix); +extern char *bb_getpwuid(char *name, long uid, int bufsize); +extern char *bb_getgrgid(char *group, long gid, int bufsize); extern char *bb_askpass(int timeout, const char * prompt); extern int device_open(const char *device, int mode); Modified: trunk/busybox/libbb/bb_pwd.c =================================================================== --- trunk/busybox/libbb/bb_pwd.c 2006-10-03 18:19:02 UTC (rev 16300) +++ trunk/busybox/libbb/bb_pwd.c 2006-10-03 19:02:20 UTC (rev 16301) @@ -34,7 +34,7 @@ { struct group *mygroup = getgrgid(gid); - return bb_getug(group, (mygroup) ? + return bb_getug(group, (mygroup) ? mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g'); } #endif /* L_bb_getgrgid */ Modified: trunk/busybox/libbb/parse_number.c =================================================================== --- trunk/busybox/libbb/parse_number.c 2006-10-03 18:19:02 UTC (rev 16300) +++ trunk/busybox/libbb/parse_number.c 2006-10-03 19:02:20 UTC (rev 16301) @@ -15,7 +15,7 @@ #include "libbb.h" unsigned long bb_xparse_number(const char *numstr, - const struct suffix_mult *suffixes) + const struct suffix_mult *suffixes) { unsigned long int r; char *e; @@ -46,5 +46,5 @@ } while (suffixes->suffix); } } - bb_error_msg_and_die("invalid number `%s'", numstr); + bb_error_msg_and_die("invalid number '%s'", numstr); } From bugs at busybox.net Tue Oct 3 12:12:55 2006 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 3 Oct 2006 12:12:55 -0700 Subject: [BusyBox 0001054]: (in v1.2.1) reboot no longer works Message-ID: <6202d5c76046c0f9631c8ee6569dbe4e@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1054 ====================================================================== Reported By: Alain137 Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1054 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 09-27-2006 14:19 PDT Last Modified: 10-03-2006 12:12 PDT ====================================================================== Summary: (in v1.2.1) reboot no longer works Description: the reboot command no longer works (does nothing) reboot -f (bypasses init) still works though ====================================================================== ---------------------------------------------------------------------- vda - 09-29-06 07:21 ---------------------------------------------------------------------- I am convinced that doing reboot thru init is sheer insanity. It is prfectly possible to reboot machine using just a shell script with umounts, kills, and sync. I do it for many years. It means that you need to analyze reboot problem in much more detail (to diff -u stage is best). Sorry. ---------------------------------------------------------------------- E-Razor - 10-03-06 12:12 ---------------------------------------------------------------------- Same problem here, looks like there is something wrong with the sig-handler? I tried different signals on init via `kill` without any reaction. Anyway `reboot -f` works as mentioned in an earlier post. I'm using a uclibc based system. I also played a bit with strace and kill, looks like signaling works. Issue History Date Modified Username Field Change ====================================================================== 09-27-06 14:19 Alain137 New Issue 09-27-06 14:19 Alain137 Status new => assigned 09-27-06 14:19 Alain137 Assigned To => BusyBox 09-29-06 07:21 vda Note Added: 0001648 10-03-06 12:12 E-Razor Note Added: 0001685 ====================================================================== From vda at busybox.net Tue Oct 3 12:56:35 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 12:56:35 -0700 (PDT) Subject: svn commit: trunk/busybox: editors findutils networking networking/ etc... Message-ID: <20061003195635.C99C8485A9@busybox.net> Author: vda Date: 2006-10-03 12:56:34 -0700 (Tue, 03 Oct 2006) New Revision: 16302 Log: lots of silly indent fixes Modified: trunk/busybox/editors/awk.c trunk/busybox/editors/sed.c trunk/busybox/editors/vi.c trunk/busybox/findutils/grep.c trunk/busybox/networking/httpd.c trunk/busybox/networking/libiproute/ip_parse_common_args.c trunk/busybox/networking/telnet.c trunk/busybox/networking/traceroute.c trunk/busybox/shell/cmdedit.c trunk/busybox/util-linux/fdformat.c trunk/busybox/util-linux/fdisk.c trunk/busybox/util-linux/mdev.c Changeset: Modified: trunk/busybox/editors/awk.c =================================================================== --- trunk/busybox/editors/awk.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/editors/awk.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -1764,7 +1764,7 @@ is_numeric(arg) ? (char)getvar_i(arg) : *getvar_s(arg)); } else if (c == 's') { - s1 = getvar_s(arg); + s1 = getvar_s(arg); qrealloc(&b, incr+i+strlen(s1), &bsize); i += sprintf(b+i, s, s1); @@ -2434,7 +2434,7 @@ R.d--; goto r_op_change; case '!': - L.d = istrue(X.v) ? 0 : 1; + L.d = istrue(X.v) ? 0 : 1; break; case '-': L.d = -R.d; Modified: trunk/busybox/editors/sed.c =================================================================== --- trunk/busybox/editors/sed.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/editors/sed.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -153,7 +153,7 @@ if(bbg.hold_space) free(bbg.hold_space); - while(bbg.current_input_file 0) printf("%s:", cur_file); - printf("%d\n", nmatches); + printf("%d\n", nmatches); } /* grep -l: print just the filename, but only if we grepped the line in the file */ Modified: trunk/busybox/networking/httpd.c =================================================================== --- trunk/busybox/networking/httpd.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/networking/httpd.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -325,20 +325,20 @@ i = 0; while (*p) { - if (*p < '0' || *p > '9') { - if (*p == '.') { - i = scan_ip(&ipm, mask, 0); - return i != 32; - } - return -1; + if (*p < '0' || *p > '9') { + if (*p == '.') { + i = scan_ip(&ipm, mask, 0); + return i != 32; } - i *= 10; - i += *p - '0'; - p++; + return -1; + } + i *= 10; + i += *p - '0'; + p++; } } if (i > 32 || i < 0) - return -1; + return -1; msk = 0x80000000; *mask = 0; while (i > 0) { @@ -553,7 +553,7 @@ } else if ((cf[1] == '.') && (cf[2] == '/' || cf[2] == 0)) { ++cf; if (p > p0) { - while (*--p != '/'); /* omit previous dir */ + while (*--p != '/') /* omit previous dir */; } continue; } @@ -1571,8 +1571,8 @@ /* protect out root */ goto BAD_REQUEST; } - while (*--purl != '/'); /* omit previous dir */ - continue; + while (*--purl != '/') /* omit previous dir */; + continue; } } } Modified: trunk/busybox/networking/libiproute/ip_parse_common_args.c =================================================================== --- trunk/busybox/networking/libiproute/ip_parse_common_args.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/networking/libiproute/ip_parse_common_args.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -48,8 +48,8 @@ if (matches(opt, "-family") == 0) { argc--; argv++; - if (! argv[1]) - bb_show_usage(); + if (!argv[1]) + bb_show_usage(); if (strcmp(argv[1], "inet") == 0) preferred_family = AF_INET; else if (strcmp(argv[1], "inet6") == 0) Modified: trunk/busybox/networking/telnet.c =================================================================== --- trunk/busybox/networking/telnet.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/networking/telnet.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -205,12 +205,12 @@ } outbuf[j++] = *p; if (*p == 0xff) - outbuf[j++] = 0xff; + outbuf[j++] = 0xff; else if (*p == 0x0d) - outbuf[j++] = 0x00; + outbuf[j++] = 0x00; } if (j > 0 ) - write(G.netfd, outbuf, j); + write(G.netfd, outbuf, j); } Modified: trunk/busybox/networking/traceroute.c =================================================================== --- trunk/busybox/networking/traceroute.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/networking/traceroute.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -641,7 +641,7 @@ outicmp->icmp_cksum = 0xffff; } else #endif - if (doipcksum) { + if (doipcksum) { /* Checksum (we must save and restore ip header) */ tip = *outip; ui = (struct udpiphdr *)outip; @@ -788,7 +788,7 @@ return (type == ICMP_TIMXCEED ? -1 : code + 1); } else #endif - { + { up = (struct udphdr *)((unsigned char *)hip + hlen); /* XXX 8 is a magic number */ if (hlen + 12 <= cc && @@ -996,11 +996,11 @@ if(nprobes_str) nprobes = str2val(nprobes_str, "nprobes", 1, -1); if(source) { - /* - * set the ip source address of the outbound - * probe (e.g., on a multi-homed host). - */ - if (getuid()) bb_error_msg_and_die("-s %s: Permission denied", source); + /* + * set the ip source address of the outbound + * probe (e.g., on a multi-homed host). + */ + if (getuid()) bb_error_msg_and_die("-s %s: permission denied", source); } if(waittime_str) waittime = str2val(waittime_str, "wait time", 2, 24 * 60 * 60); @@ -1015,7 +1015,7 @@ for(l_sr = sourse_route_list; l_sr; ) { if (lsrr >= NGATEWAYS) - bb_error_msg_and_die("No more than %d gateways", NGATEWAYS); + bb_error_msg_and_die("no more than %d gateways", NGATEWAYS); getaddr(gwlist + lsrr, l_sr->data); ++lsrr; l_sr = l_sr->link; Modified: trunk/busybox/shell/cmdedit.c =================================================================== --- trunk/busybox/shell/cmdedit.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/shell/cmdedit.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -271,7 +271,6 @@ if (num < 4) while (num-- > 0) putchar('\b'); - else printf("\033[%dD", num); } else { @@ -370,7 +369,7 @@ pbuf = buf2; *pbuf = '~'; strcpy(pbuf+1, pwd_buf+l); - } + } break; #endif case 'W': @@ -712,7 +711,7 @@ s[l++] = *found++; } if(add) - s[l++] = (char)add; + s[l++] = (char)add; s[l] = 0; return s; } @@ -995,7 +994,7 @@ for (row = 0; row < nrows; row++) { l = strlen(matches[row]); if(add_char_to_match[row]) - l++; + l++; if (column_width < l) column_width = l; } @@ -1021,8 +1020,8 @@ printf("%s%s", matches[n], str_add_chr); l = strlen(matches[n]); while(l < acol) { - putchar(' '); - l++; + putchar(' '); + l++; } } str_add_chr[0] = add_char_to_match[n]; @@ -1081,30 +1080,32 @@ int i, j, n, srt; /* bubble */ n = num_matches; - for(i=0; i<(n-1); i++) - for(j=i+1; j 0) { - tmp1 = matches[i]; - matches[i] = matches[j]; - matches[j] = tmp1; - srt = add_char_to_match[i]; - add_char_to_match[i] = add_char_to_match[j]; - add_char_to_match[j] = srt; - } + for(i=0; i<(n-1); i++) { + for(j=i+1; j 0) { + tmp1 = matches[i]; + matches[i] = matches[j]; + matches[j] = tmp1; + srt = add_char_to_match[i]; + add_char_to_match[i] = add_char_to_match[j]; + add_char_to_match[j] = srt; + } + } } + } j = n; n = 0; for(i=0; i cursor) + input_delete(1); + break; + case 'b': /* "db", "cb" */ + case 'B': /* implemented as B */ + if (c == 'b') + vi_back_motion(command); + else + vi_Back_motion(command); + while (sc-- > cursor) + input_delete(1); + break; + case ' ': /* "d ", "c " */ + input_delete(1); + break; + case '$': /* "d$", "c$" */ + clear_to_eol: + while (cursor < len) + input_delete(1); + break; + } } - switch(c) { - case 'w': - case 'W': - case 'e': - case 'E': - switch (c) { - case 'w': /* "dw", "cw" */ - vi_word_motion(command, vi_cmdmode); - break; - case 'W': /* 'dW', 'cW' */ - vi_Word_motion(command, vi_cmdmode); - break; - case 'e': /* 'de', 'ce' */ - vi_end_motion(command); - input_forward(); - break; - case 'E': /* 'dE', 'cE' */ - vi_End_motion(command); - input_forward(); - break; - } - nc = cursor; - input_backward(cursor - sc); - while (nc-- > cursor) - input_delete(1); - break; - case 'b': /* "db", "cb" */ - case 'B': /* implemented as B */ - if (c == 'b') - vi_back_motion(command); - else - vi_Back_motion(command); - while (sc-- > cursor) - input_delete(1); - break; - case ' ': /* "d ", "c " */ - input_delete(1); - break; - case '$': /* "d$", "c$" */ - clear_to_eol: - while (cursor < len) - input_delete(1); - break; - } - } break; case 'p'|vbit: input_forward(); Modified: trunk/busybox/util-linux/fdformat.c =================================================================== --- trunk/busybox/util-linux/fdformat.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/util-linux/fdformat.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -47,7 +47,7 @@ static void xioctl(int fd, int request, void *argp, const char *string) { - if (ioctl (fd, request, argp) < 0) { + if (ioctl(fd, request, argp) < 0) { bb_perror_msg_and_die(string); } } @@ -67,17 +67,16 @@ argv += optind; /* R_OK is needed for verifying */ - if (stat(*argv,&st) < 0 || access(*argv,W_OK | R_OK ) < 0) { - bb_perror_msg_and_die("%s",*argv); + if (stat(*argv, &st) < 0 || access(*argv, W_OK | R_OK ) < 0) { + bb_perror_msg_and_die("%s", *argv); } if (!S_ISBLK(st.st_mode)) { - bb_error_msg_and_die("%s: not a block device",*argv); + bb_error_msg_and_die("%s: not a block device", *argv); /* do not test major - perhaps this was an USB floppy */ } - /* O_RDWR for formatting and verifying */ - fd = xopen(*argv,O_RDWR ); + fd = xopen(*argv, O_RDWR); xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */ @@ -86,44 +85,45 @@ param.track, param.sect, param.size >> 1); /* FORMAT */ - printf("Formatting ... "); - xioctl(fd, FDFMTBEG,NULL,"FDFMTBEG"); + printf("Formatting... "); + xioctl(fd, FDFMTBEG, NULL, "FDFMTBEG"); /* n == track */ - for (n = 0; n < param.track; n++) - { - descr.head = 0; - descr.track = n; - xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); - printf("%3d\b\b\b", n); - if (param.head == 2) { - descr.head = 1; - xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); - } + for (n = 0; n < param.track; n++) { + descr.head = 0; + descr.track = n; + xioctl(fd, FDFMTTRK, &descr, "FDFMTTRK"); + printf("%3d\b\b\b", n); + if (param.head == 2) { + descr.head = 1; + xioctl(fd, FDFMTTRK, &descr, "FDFMTTRK"); + } } - xioctl(fd,FDFMTEND,NULL,"FDFMTEND"); + xioctl(fd, FDFMTEND, NULL, "FDFMTEND"); printf("done\n"); /* VERIFY */ - if(verify) { + if (verify) { /* n == cyl_size */ n = param.sect*param.head*512; data = xmalloc(n); - printf("Verifying ... "); + printf("Verifying... "); for (cyl = 0; cyl < param.track; cyl++) { printf("%3d\b\b\b", cyl); - if((read_bytes = safe_read(fd,data,n))!= n ) { - if(read_bytes < 0) { + read_bytes = safe_read(fd, data, n); + if (read_bytes != n) { + if (read_bytes < 0) { bb_perror_msg(bb_msg_read_error); } - bb_error_msg_and_die("Problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes); + bb_error_msg_and_die("problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes); + // FIXME: maybe better seek & continue?? } /* Check backwards so we don't need a counter */ - while(--read_bytes>=0) { - if( data[read_bytes] != FD_FILL_BYTE) { - printf("bad data in cyl %d\nContinuing ... ",cyl); + while (--read_bytes >= 0) { + if (data[read_bytes] != FD_FILL_BYTE) { + printf("bad data in cyl %d\nContinuing... ",cyl); } } } Modified: trunk/busybox/util-linux/fdisk.c =================================================================== --- trunk/busybox/util-linux/fdisk.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/util-linux/fdisk.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -4506,8 +4506,7 @@ label_sun != current_label_type && !get_nr_sects(p)) { printf(_("Partition %d does not exist yet!\n"), i + 1); - }else{ - while (1) { + } else while (1) { sys = read_hex (get_sys_types()); if (!sys && label_sgi != current_label_type && @@ -4573,7 +4572,6 @@ dos_changed = 1; break; } - } } } #endif /* CONFIG_FEATURE_FDISK_WRITABLE */ Modified: trunk/busybox/util-linux/mdev.c =================================================================== --- trunk/busybox/util-linux/mdev.c 2006-10-03 19:02:20 UTC (rev 16301) +++ trunk/busybox/util-linux/mdev.c 2006-10-03 19:56:34 UTC (rev 16302) @@ -250,7 +250,7 @@ } else { action = getenv("ACTION"); env_path = getenv("DEVPATH"); - if (!action || !env_path) + if (!action || !env_path) bb_show_usage(); sprintf(temp, "/sys%s", env_path); From vda at busybox.net Tue Oct 3 12:57:51 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 12:57:51 -0700 (PDT) Subject: svn commit: trunk/busybox: libbb util-linux Message-ID: <20061003195751.2C9F1485DE@busybox.net> Author: vda Date: 2006-10-03 12:57:50 -0700 (Tue, 03 Oct 2006) New Revision: 16303 Log: fdformat: remove redundant check Modified: trunk/busybox/libbb/xfuncs.c trunk/busybox/util-linux/fdformat.c Changeset: Modified: trunk/busybox/libbb/xfuncs.c =================================================================== --- trunk/busybox/libbb/xfuncs.c 2006-10-03 19:56:34 UTC (rev 16302) +++ trunk/busybox/libbb/xfuncs.c 2006-10-03 19:57:50 UTC (rev 16303) @@ -498,7 +498,7 @@ void xstat(char *name, struct stat *stat_buf) { if (stat(name, stat_buf)) - bb_perror_msg_and_die("Can't stat '%s'", name); + bb_perror_msg_and_die("can't stat '%s'", name); } #endif Modified: trunk/busybox/util-linux/fdformat.c =================================================================== --- trunk/busybox/util-linux/fdformat.c 2006-10-03 19:56:34 UTC (rev 16302) +++ trunk/busybox/util-linux/fdformat.c 2006-10-03 19:57:50 UTC (rev 16303) @@ -66,10 +66,7 @@ verify = !bb_getopt_ulflags(argc, argv, "n"); argv += optind; - /* R_OK is needed for verifying */ - if (stat(*argv, &st) < 0 || access(*argv, W_OK | R_OK ) < 0) { - bb_perror_msg_and_die("%s", *argv); - } + xstat(*argv, &st); if (!S_ISBLK(st.st_mode)) { bb_error_msg_and_die("%s: not a block device", *argv); /* do not test major - perhaps this was an USB floppy */ @@ -78,9 +75,10 @@ /* O_RDWR for formatting and verifying */ fd = xopen(*argv, O_RDWR); - xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */ + /* original message was: "Could not determine current format type" */ + xioctl(fd, FDGETPRM, ¶m, "FDGETPRM"); - printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", + printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB\n", (param.head == 2) ? "Double" : "Single", param.track, param.sect, param.size >> 1); @@ -117,7 +115,8 @@ if (read_bytes < 0) { bb_perror_msg(bb_msg_read_error); } - bb_error_msg_and_die("problem reading cylinder %d, expected %d, read %d", cyl, n, read_bytes); + bb_error_msg_and_die("problem reading cylinder %d, " + "expected %d, read %d", cyl, n, read_bytes); // FIXME: maybe better seek & continue?? } /* Check backwards so we don't need a counter */ From vda at busybox.net Tue Oct 3 13:28:07 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 13:28:07 -0700 (PDT) Subject: svn commit: trunk/busybox: applets coreutils editors include libbb etc... Message-ID: <20061003202807.496B7485D3@busybox.net> Author: vda Date: 2006-10-03 13:28:06 -0700 (Tue, 03 Oct 2006) New Revision: 16304 Log: rename bb_default_error_retval -> xfunc_error_retval Modified: trunk/busybox/applets/applets.c trunk/busybox/coreutils/cmp.c trunk/busybox/coreutils/env.c trunk/busybox/coreutils/nice.c trunk/busybox/coreutils/nohup.c trunk/busybox/coreutils/sort.c trunk/busybox/coreutils/tty.c trunk/busybox/editors/sed.c trunk/busybox/include/libbb.h trunk/busybox/libbb/default_error_retval.c trunk/busybox/libbb/error_msg_and_die.c trunk/busybox/libbb/fflush_stdout_and_exit.c trunk/busybox/libbb/herror_msg_and_die.c trunk/busybox/libbb/perror_msg_and_die.c trunk/busybox/libbb/xfuncs.c trunk/busybox/miscutils/crontab.c trunk/busybox/networking/arping.c Changeset: Modified: trunk/busybox/applets/applets.c =================================================================== --- trunk/busybox/applets/applets.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/applets/applets.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -443,7 +443,7 @@ applet_using->name, usage_string); } - exit (bb_default_error_retval); + exit(xfunc_error_retval); } static int applet_name_compare(const void *name, const void *vapplet) Modified: trunk/busybox/coreutils/cmp.c =================================================================== --- trunk/busybox/coreutils/cmp.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/coreutils/cmp.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -31,7 +31,7 @@ return fp; } - exit(bb_default_error_retval); /* We already output an error message. */ + exit(xfunc_error_retval); /* We already output an error message. */ } static const char fmt_eof[] = "cmp: EOF on %s\n"; @@ -52,7 +52,7 @@ unsigned opt; int retval = 0; - bb_default_error_retval = 2; /* 1 is returned if files are different. */ + xfunc_error_retval = 2; /* 1 is returned if files are different. */ opt = bb_getopt_ulflags(argc, argv, opt_chars); Modified: trunk/busybox/coreutils/env.c =================================================================== --- trunk/busybox/coreutils/env.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/coreutils/env.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -26,7 +26,7 @@ * - correct "-" option usage * - multiple "-u unsetenv" support * - GNU long option support - * - use bb_default_error_retval + * - use xfunc_error_retval */ #include "busybox.h" @@ -82,7 +82,7 @@ if (*argv) { execvp(*argv, argv); /* SUSv3-mandated exit codes. */ - bb_default_error_retval = (errno == ENOENT) ? 127 : 126; + xfunc_error_retval = (errno == ENOENT) ? 127 : 126; bb_perror_msg_and_die("%s", *argv); } Modified: trunk/busybox/coreutils/nice.c =================================================================== --- trunk/busybox/coreutils/nice.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/coreutils/nice.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -67,6 +67,6 @@ execvp(*argv, argv); /* Now exec the desired program. */ /* The exec failed... */ - bb_default_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */ + xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */ bb_perror_msg_and_die("%s", *argv); } Modified: trunk/busybox/coreutils/nohup.c =================================================================== --- trunk/busybox/coreutils/nohup.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/coreutils/nohup.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -17,7 +17,7 @@ int temp, nullfd; char *nohupout, *home = NULL; - bb_default_error_retval = 127; + xfunc_error_retval = 127; if (argc<2) bb_show_usage(); Modified: trunk/busybox/coreutils/sort.c =================================================================== --- trunk/busybox/coreutils/sort.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/coreutils/sort.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -225,7 +225,7 @@ char *line,**lines=NULL,*optlist="ngMucszbrdfimS:T:o:k:t:"; int c; - bb_default_error_retval = 2; + xfunc_error_retval = 2; /* Parse command line options */ while((c=getopt(argc,argv,optlist))>0) { line=strchr(optlist,c); Modified: trunk/busybox/coreutils/tty.c =================================================================== --- trunk/busybox/coreutils/tty.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/coreutils/tty.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -21,7 +21,7 @@ int silent; /* Note: No longer relevant in SUSv3. */ int retval; - bb_default_error_retval = 2; /* SUSv3 requires > 1 for error. */ + xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */ silent = bb_getopt_ulflags(argc, argv, "s"); Modified: trunk/busybox/editors/sed.c =================================================================== --- trunk/busybox/editors/sed.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/editors/sed.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -725,7 +725,7 @@ if(!no_newline) fputc('\n',file); if(ferror(file)) { - bb_default_error_retval = 4; /* It's what gnu sed exits with... */ + xfunc_error_retval = 4; /* It's what gnu sed exits with... */ bb_error_msg_and_die(bb_msg_write_error); } Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/include/libbb.h 2006-10-03 20:28:06 UTC (rev 16304) @@ -421,7 +421,7 @@ extern const char bb_path_mtab_file[]; -extern int bb_default_error_retval; +extern int xfunc_error_retval; #ifdef CONFIG_FEATURE_DEVFS # define CURRENT_VC "/dev/vc/0" Modified: trunk/busybox/libbb/default_error_retval.c =================================================================== --- trunk/busybox/libbb/default_error_retval.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/libbb/default_error_retval.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -16,4 +16,4 @@ #include #include "libbb.h" -int bb_default_error_retval = EXIT_FAILURE; +int xfunc_error_retval = EXIT_FAILURE; Modified: trunk/busybox/libbb/error_msg_and_die.c =================================================================== --- trunk/busybox/libbb/error_msg_and_die.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/libbb/error_msg_and_die.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -24,5 +24,5 @@ va_end(p); if (die_sleep) sleep(die_sleep); - exit(bb_default_error_retval); + exit(xfunc_error_retval); } Modified: trunk/busybox/libbb/fflush_stdout_and_exit.c =================================================================== --- trunk/busybox/libbb/fflush_stdout_and_exit.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/libbb/fflush_stdout_and_exit.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -18,7 +18,7 @@ void bb_fflush_stdout_and_exit(int retval) { if (fflush(stdout)) { - retval = bb_default_error_retval; + retval = xfunc_error_retval; } if (die_sleep) sleep(die_sleep); Modified: trunk/busybox/libbb/herror_msg_and_die.c =================================================================== --- trunk/busybox/libbb/herror_msg_and_die.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/libbb/herror_msg_and_die.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -21,5 +21,5 @@ va_end(p); if (die_sleep) sleep(die_sleep); - exit(bb_default_error_retval); + exit(xfunc_error_retval); } Modified: trunk/busybox/libbb/perror_msg_and_die.c =================================================================== --- trunk/busybox/libbb/perror_msg_and_die.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/libbb/perror_msg_and_die.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -22,5 +22,5 @@ va_end(p); if (die_sleep) sleep(die_sleep); - exit(bb_default_error_retval); + exit(xfunc_error_retval); } Modified: trunk/busybox/libbb/xfuncs.c =================================================================== --- trunk/busybox/libbb/xfuncs.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/libbb/xfuncs.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -414,7 +414,7 @@ { // copyfd outputs error messages for us. if (bb_copyfd_eof(fileno(file), 1) == -1) - exit(bb_default_error_retval); + exit(xfunc_error_retval); fclose(file); } Modified: trunk/busybox/miscutils/crontab.c =================================================================== --- trunk/busybox/miscutils/crontab.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/miscutils/crontab.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -269,7 +269,7 @@ if (ChangeUser(user, 0) < 0) exit(0); - bb_default_error_retval = 0; + xfunc_error_retval = 0; fd = xopen(file, O_RDONLY); buf[0] = 0; write(filedes[1], buf, 1); Modified: trunk/busybox/networking/arping.c =================================================================== --- trunk/busybox/networking/arping.c 2006-10-03 19:57:50 UTC (rev 16303) +++ trunk/busybox/networking/arping.c 2006-10-03 20:28:06 UTC (rev 16304) @@ -295,7 +295,7 @@ target = *argv; - bb_default_error_retval = 2; + xfunc_error_retval = 2; { struct ifreq ifr; From vda at busybox.net Tue Oct 3 14:00:11 2006 From: vda at busybox.net (vda at busybox.net) Date: Tue, 3 Oct 2006 14:00:11 -0700 (PDT) Subject: svn commit: trunk/busybox: archival console-tools coreutils coreuti etc... Message-ID: <20061003210011.E7467485CD@busybox.net> Author: vda Date: 2006-10-03 14:00:06 -0700 (Tue, 03 Oct 2006) New Revision: 16305 Log: getopt_ulflags -> getopt32. It is impossible to formulate sane ABI based on size of ulong because it can be 32-bit or 64-bit. Basically it means that you cannot portably use more that 32 option chars in one call anyway... Make it explicit. Added: trunk/busybox/libbb/getopt32.c Removed: trunk/busybox/libbb/getopt_ulflags.c Modified: trunk/busybox/archival/ar.c trunk/busybox/archival/bunzip2.c trunk/busybox/archival/cpio.c trunk/busybox/archival/dpkg_deb.c trunk/busybox/archival/gunzip.c trunk/busybox/archival/gzip.c trunk/busybox/archival/tar.c trunk/busybox/archival/uncompress.c trunk/busybox/archival/unlzma.c trunk/busybox/console-tools/setconsole.c trunk/busybox/coreutils/cal.c trunk/busybox/coreutils/cat.c trunk/busybox/coreutils/catv.c trunk/busybox/coreutils/chgrp.c trunk/busybox/coreutils/chown.c trunk/busybox/coreutils/cmp.c trunk/busybox/coreutils/comm.c trunk/b