fixes from Vladimir Dronnikov <dronnikov@gmail.ru>
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 10 Oct 2006 21:00:47 +0000 (21:00 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 10 Oct 2006 21:00:47 +0000 (21:00 -0000)
12 files changed:
Makefile
archival/libunarchive/data_extract_all.c
archival/libunarchive/get_header_cpio.c
archival/libunarchive/get_header_tar.c
archival/libunarchive/init_handle.c
e2fsprogs/e2p/Kbuild
include/libbb.h
libbb/xatol.c
modutils/Config.in
networking/wget.c
runit/chpst.c
shell/ash.c

index c1103cf955d0008b7acc267f86de13ab9399d0ef..5117c45504bb57300cb5ac97cf3f62fe641787fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -563,9 +563,17 @@ busybox-all  := $(core-y) $(libs-y)
 # Rule to link busybox - also used during CONFIG_KALLSYMS
 # May be overridden by arch/$(ARCH)/Makefile
 quiet_cmd_busybox__ ?= LINK    $@
+ifdef CONFIG_STATIC
+      cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) \
+      -static \
+      -o $@ \
+      -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
+      -Wl,--start-group $(busybox-all) -Wl,--end-group
+else
       cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) -o $@ \
       -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
-      -Wl,--start-group $(busybox-all) -Wl,--end-group \
+      -Wl,--start-group $(busybox-all) -Wl,--end-group
+endif
 
 # Generate System.map
 quiet_cmd_sysmap = SYSMAP 
index b1c66a4a22f2b71067d1e8b6c562bfb0099454b2..67f8f3534aa5f0f0749cfac38ff953d92d12ce7c 100644 (file)
@@ -14,15 +14,18 @@ void data_extract_all(archive_handle_t *archive_handle)
 
        if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
                char *name = xstrdup(file_header->name);
-               bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
+               bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
                free(name);
        }
 
        /* Check if the file already exists */
        if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
                /* Remove the existing entry if it exists */
-               if (((file_header->mode & S_IFMT) != S_IFDIR) && (unlink(file_header->name) == -1) && (errno != ENOENT)) {
-                       bb_perror_msg_and_die("Couldnt remove old file");
+               if (((file_header->mode & S_IFMT) != S_IFDIR)
+                && (unlink(file_header->name) == -1)
+                && (errno != ENOENT)
+               ) {
+                       bb_perror_msg_and_die("cannot remove old file");
                }
        }
        else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
@@ -30,64 +33,77 @@ void data_extract_all(archive_handle_t *archive_handle)
                struct stat statbuf;
                if (lstat(file_header->name, &statbuf) == -1) {
                        if (errno != ENOENT) {
-                               bb_perror_msg_and_die("Couldnt stat old file");
+                               bb_perror_msg_and_die("cannot stat old file");
                        }
                }
                else if (statbuf.st_mtime <= file_header->mtime) {
                        if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
-                               bb_error_msg("%s not created: newer or same age file exists", file_header->name);
+                               bb_error_msg("%s not created: newer or "
+                                       "same age file exists", file_header->name);
                        }
                        data_skip(archive_handle);
                        return;
                }
                else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
-                       bb_perror_msg_and_die("Couldnt remove old file %s", file_header->name);
+                       bb_perror_msg_and_die("cannot remove old file %s",
+                                       file_header->name);
                }
        }
 
        /* Handle hard links separately
         * We identified hard links as regular files of size 0 with a symlink */
-       if (S_ISREG(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
+       if (S_ISREG(file_header->mode) && (file_header->link_name)
+        && (file_header->size == 0)
+       ) {
                /* hard link */
                res = link(file_header->link_name, file_header->name);
                if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
-                       bb_perror_msg("Couldnt create hard link");
+                       bb_perror_msg("cannot create hard link");
                }
        } else {
                /* Create the filesystem entry */
                switch (file_header->mode & S_IFMT) {
-                       case S_IFREG: {
-                               /* Regular file */
-                               dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL,
-                                                               file_header->mode);
-                               bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
-                               close(dst_fd);
-                               break;
-                               }
-                       case S_IFDIR:
-                               res = mkdir(file_header->name, file_header->mode);
-                               if ((errno != EISDIR) && (res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
-                                       bb_perror_msg("extract_archive: %s", file_header->name);
-                               }
-                               break;
-                       case S_IFLNK:
-                               /* Symlink */
-                               res = symlink(file_header->link_name, file_header->name);
-                               if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
-                                       bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
-                               }
-                               break;
-                       case S_IFSOCK:
-                       case S_IFBLK:
-                       case S_IFCHR:
-                       case S_IFIFO:
-                               res = mknod(file_header->name, file_header->mode, file_header->device);
-                               if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
-                                       bb_perror_msg("Cannot create node %s", file_header->name);
-                               }
-                               break;
-                       default:
-                               bb_error_msg_and_die("Unrecognised file type");
+               case S_IFREG: {
+                       /* Regular file */
+                       dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL,
+                                                       file_header->mode);
+                       bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
+                       close(dst_fd);
+                       break;
+                       }
+               case S_IFDIR:
+                       res = mkdir(file_header->name, file_header->mode);
+                       if ((errno != EISDIR) && (res == -1)
+                        && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
+                       ) {
+                               bb_perror_msg("extract_archive: %s", file_header->name);
+                       }
+                       break;
+               case S_IFLNK:
+                       /* Symlink */
+                       res = symlink(file_header->link_name, file_header->name);
+                       if ((res == -1)
+                        && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
+                       ) {
+                               bb_perror_msg("cannot create symlink "
+                                       "from %s to '%s'",
+                                       file_header->name,
+                                       file_header->link_name);
+                       }
+                       break;
+               case S_IFSOCK:
+               case S_IFBLK:
+               case S_IFCHR:
+               case S_IFIFO:
+                       res = mknod(file_header->name, file_header->mode, file_header->device);
+                       if ((res == -1)
+                        && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
+                       ) {
+                               bb_perror_msg("cannot create node %s", file_header->name);
+                       }
+                       break;
+               default:
+                       bb_error_msg_and_die("unrecognized file type");
                }
        }
 
index bc766c6aafdf0bd8d0ed3c05259db51887e7b0b2..56862f137ea9f680126d238ec5b5482ff559d870 100644 (file)
@@ -61,13 +61,13 @@ char get_header_cpio(archive_handle_t *archive_handle)
        }
 
        {
-           unsigned long tmpsize;
-           sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
+               unsigned long tmpsize;
+               sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
                    dummy, &inode, (unsigned int*)&file_header->mode,
                    (unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
                    &nlink, &file_header->mtime, &tmpsize,
                    dummy, &major, &minor, &namesize, dummy);
-           file_header->size = tmpsize;
+               file_header->size = tmpsize;
        }
 
        file_header->name = (char *) xzalloc(namesize + 1);
index d3cd96d0cc0c96eb4d0f557d03712b8cd3e15dee..f78377e28a68485e9eed1029614440228e5e8f8d 100644 (file)
@@ -74,12 +74,12 @@ char get_header_tar(archive_handle_t *archive_handle)
         */
        if (strncmp(tar.formatted.magic, "ustar", 5) != 0) {
 #ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
-               if (strncmp(tar.formatted.magic, "\0\0\0\0\0", 5) != 0)
+               if (memcmp(tar.formatted.magic, "\0\0\0\0", 5) != 0)
 #endif
                        bb_error_msg_and_die("invalid tar magic");
        }
        /* Do checksum on headers */
-       for (i =  0; i < 148 ; i++) {
+       for (i = 0; i < 148 ; i++) {
                sum += tar.raw[i];
        }
        sum += ' ' * 8;
@@ -111,13 +111,14 @@ char get_header_tar(archive_handle_t *archive_handle)
 
        file_header->uid = xstrtoul(tar.formatted.uid, 8);
        file_header->gid = xstrtoul(tar.formatted.gid, 8);
-       // TODO: LFS support
-       file_header->size = xstrtoul(tar.formatted.size, 8);
+       file_header->size = XSTRTOUOFF(tar.formatted.size, 8);
        file_header->mtime = xstrtoul(tar.formatted.mtime, 8);
        file_header->link_name = tar.formatted.linkname[0] ?
                                 xstrdup(tar.formatted.linkname) : NULL;
-       file_header->device = makedev(xstrtoul(tar.formatted.devmajor, 8),
-                                     xstrtoul(tar.formatted.devminor, 8));
+       if (tar.formatted.devmajor[0]) {
+               file_header->device = makedev(xstrtoul(tar.formatted.devmajor, 8),
+                                             xstrtoul(tar.formatted.devminor, 8));
+       }
 
        /* Set bits 0-11 of the files mode */
        file_header->mode = 07777 & xstrtoul(tar.formatted.mode, 8);
index 96bb1dbc97ba3d504697ac22267cfe2589138362..beda1b462aa0399b586a4d37646ac42beee3428e 100644 (file)
@@ -3,8 +3,8 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
-#include <unistd.h>
-#include <string.h>
+//#include <unistd.h>
+//#include <string.h>
 #include "libbb.h"
 #include "unarchive.h"
 
@@ -12,7 +12,7 @@ archive_handle_t *init_handle(void)
 {
        archive_handle_t *archive_handle;
 
-       /* Initialise default values */
+       /* Initialize default values */
        archive_handle = xzalloc(sizeof(archive_handle_t));
        archive_handle->file_header = xmalloc(sizeof(file_header_t));
        archive_handle->action_header = header_skip;
@@ -20,5 +20,5 @@ archive_handle_t *init_handle(void)
        archive_handle->filter = filter_accept_all;
        archive_handle->seek = seek_by_jump;
 
-       return(archive_handle);
+       return archive_handle;
 }
index 64e4621709f57cc3d1c9baa75dd91127190df105..c0ff824e3c63fe62987d05b6d106dea183e3fa1a 100644 (file)
@@ -5,9 +5,9 @@
 # Licensed under the GPL v2, see the file LICENSE in this tarball.
 
 NEEDED-$(CONFIG_CHATTR) = y
-NEEDED-$(LSATTR) = y
-NEEDED-$(MKE2FS) = y
-NEEDED-$(TUNE2FS) = y
+NEEDED-$(CONFIG_LSATTR) = y
+NEEDED-$(CONFIG_MKE2FS) = y
+NEEDED-$(CONFIG_TUNE2FS) = y
 
 lib-y:=
 lib-$(NEEDED-y) += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \
index 7b9b839082f40131304810f33eb09934a517a063..e4e67aa5a99b1dcf8291ea13f89c3603a10ee41d 100644 (file)
 /* "long" is long enough on this system */
 #  define STRTOOFF strtol
 #  define SAFE_STRTOOFF safe_strtol
+#  define XSTRTOUOFF xstrtoul
 #  define OFF_FMT "%ld"
 # else
-/* "long" is too short, need "lomg long" */
+/* "long" is too short, need "long long" */
 #  define STRTOOFF strtoll
 #  define SAFE_STRTOOFF safe_strtoll
+#  define XSTRTOUOFF xstrtoull
 #  define OFF_FMT "%lld"
 # endif
 #else
-# if 0 /* UINT_MAX == 0xffffffff */
+# if 0 /* #if UINT_MAX == 0xffffffff */
 /* Doesn't work. off_t is a long. gcc will throw warnings on printf("%d", off_t)
  * even if long==int on this arch. Crap... */
 #  define STRTOOFF strtol
 #  define SAFE_STRTOOFF safe_strtoi
+#  define XSTRTOUOFF xstrtou
 #  define OFF_FMT "%d"
 # else
 #  define STRTOOFF strtol
 #  define SAFE_STRTOOFF safe_strtol
+#  define XSTRTOUOFF xstrtoul
 #  define OFF_FMT "%ld"
 # endif
 #endif
@@ -313,6 +317,8 @@ struct suffix_mult {
        unsigned int mult;
 };
 
+unsigned long long xstrtoull(const char *numstr, int base);
+unsigned long long xatoull(const char *numstr);
 unsigned long xstrtoul_range_sfx(const char *numstr, int base,
                unsigned long lower,
                unsigned long upper,
@@ -331,7 +337,6 @@ unsigned long xatoul_range(const char *numstr,
                unsigned long lower,
                unsigned long upper);
 unsigned long xatoul(const char *numstr);
-unsigned long long xatoull(const char *numstr);
 long xstrtol_range_sfx(const char *numstr, int base,
                long lower,
                long upper,
index 3316c3d069775072caeabd181ccfdda5e9d58aca..1b71e9ca8707f28523914b44ab3113544a8bcd70 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "libbb.h"
 
-unsigned long long xatoull(const char *numstr)
+unsigned long long xstrtoull(const char *numstr, int base)
 {
        unsigned long long r;
        int old_errno;
@@ -18,7 +18,7 @@ unsigned long long xatoull(const char *numstr)
                bb_error_msg_and_die("invalid number '%s'", numstr);
        old_errno = errno;
        errno = 0;
-       r = strtoull(numstr, &e, 10);
+       r = strtoull(numstr, &e, base);
        if (errno || (numstr == e) || *e)
                /* Error / no digits / illegal trailing chars */
                bb_error_msg_and_die("invalid number '%s'", numstr);
@@ -27,6 +27,11 @@ unsigned long long xatoull(const char *numstr)
        return r;
 }
 
+unsigned long long xatoull(const char *numstr)
+{
+       return xstrtoull(numstr, 10);
+}
+
 unsigned long xstrtoul_range_sfx(const char *numstr, int base,
                unsigned long lower,
                unsigned long upper,
index b28c66d2472f5708664cdfecd9872395a0ab9c52..c8bd619968629333542a27cfcad4b1c90dd382ee 100644 (file)
@@ -43,7 +43,7 @@ config FEATURE_INSMOD_LOADINKMEM
 config FEATURE_INSMOD_LOAD_MAP
        bool "Enable load map (-m) option"
        default n
-       depends on INSMOD && FEATURE_2_4_MODULES
+       depends on INSMOD && ( FEATURE_2_4_MODULES || FEATURE_2_6_MODULES )
        help
          Enabling this, one would be able to get a load map
          output on stdout. This makes kernel module debugging
index 74feccc365558ab850ffd029b3dbe5ff6db8f002..264ae4483331a433f84cee4b2fc7f4a02cf5be94 100644 (file)
@@ -31,7 +31,9 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf);
 /* Globals (can be accessed from signal handlers */
 static off_t content_len;        /* Content-length of the file */
 static off_t beg_range;          /* Range at which continue begins */
+#ifdef CONFIG_FEATURE_WGET_STATUSBAR
 static off_t transferred;        /* Number of bytes transferred so far */
+#endif
 static int chunked;                     /* chunked transfer encoding */
 #ifdef CONFIG_FEATURE_WGET_STATUSBAR
 static void progressmeter(int flag);
index 5f30b88154b67c10b99b2c6165d16998d219f86a..1b6f37849fcdf70d23a052dd877ab5ff19a54b3e 100644 (file)
@@ -223,7 +223,7 @@ int chpst_main(int argc, char **argv)
 
        {
                char *m,*d,*o,*p,*f,*c,*r,*t,*n;
-               getopt32(argc, argv, "u:U:e:m:d:o:p:f:c:r:t:/:n:vP012",
+               getopt32(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_mask32 & 0x1) // -u
@@ -310,7 +310,7 @@ static void envdir(int argc, char **argv)
 static void softlimit(int argc, char **argv)
 {
        char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t;
-       getopt32(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:",
+       getopt32(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_mask32 & 0x001) limita = xatoul(a); // -a
        if (option_mask32 & 0x002) limitc = xatoul(c); // -c
index 3564044b2cb39051c54205e847f61dc1116fa8d3..1260d5e9a0900d986c725cd9bf27f6e270c9509c 100644 (file)
@@ -12542,7 +12542,7 @@ static int
 letcmd(int argc, char **argv)
 {
        char **ap;
-       arith_t i;
+       arith_t i = 0;
 
        ap = argv + 1;
        if(!*ap)