fixes from Vladimir Dronnikov <dronnikov@gmail.ru>

This commit is contained in:
Denis Vlasenko 2006-10-10 21:00:47 +00:00
parent 1ac42bf66e
commit cba9ef5523
12 changed files with 103 additions and 66 deletions

View File

@ -563,9 +563,17 @@ busybox-all := $(core-y) $(libs-y)
# Rule to link busybox - also used during CONFIG_KALLSYMS # Rule to link busybox - also used during CONFIG_KALLSYMS
# May be overridden by arch/$(ARCH)/Makefile # May be overridden by arch/$(ARCH)/Makefile
quiet_cmd_busybox__ ?= LINK $@ 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 $@ \ cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) -o $@ \
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ -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 # Generate System.map
quiet_cmd_sysmap = SYSMAP quiet_cmd_sysmap = SYSMAP

View File

@ -14,15 +14,18 @@ void data_extract_all(archive_handle_t *archive_handle)
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) { if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
char *name = xstrdup(file_header->name); char *name = xstrdup(file_header->name);
bb_make_directory (dirname(name), -1, FILEUTILS_RECUR); bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
free(name); free(name);
} }
/* Check if the file already exists */ /* Check if the file already exists */
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) { if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the existing entry if it exists */ /* Remove the existing entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR) && (unlink(file_header->name) == -1) && (errno != ENOENT)) { if (((file_header->mode & S_IFMT) != S_IFDIR)
bb_perror_msg_and_die("Couldnt remove old file"); && (unlink(file_header->name) == -1)
&& (errno != ENOENT)
) {
bb_perror_msg_and_die("cannot remove old file");
} }
} }
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) { else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
@ -30,64 +33,77 @@ void data_extract_all(archive_handle_t *archive_handle)
struct stat statbuf; struct stat statbuf;
if (lstat(file_header->name, &statbuf) == -1) { if (lstat(file_header->name, &statbuf) == -1) {
if (errno != ENOENT) { 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) { else if (statbuf.st_mtime <= file_header->mtime) {
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { 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); data_skip(archive_handle);
return; return;
} }
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { 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 /* Handle hard links separately
* We identified hard links as regular files of size 0 with a symlink */ * 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 */ /* hard link */
res = link(file_header->link_name, file_header->name); res = link(file_header->link_name, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("Couldnt create hard link"); bb_perror_msg("cannot create hard link");
} }
} else { } else {
/* Create the filesystem entry */ /* Create the filesystem entry */
switch (file_header->mode & S_IFMT) { switch (file_header->mode & S_IFMT) {
case S_IFREG: { case S_IFREG: {
/* Regular file */ /* Regular file */
dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL, dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL,
file_header->mode); file_header->mode);
bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size); bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
close(dst_fd); close(dst_fd);
break; break;
} }
case S_IFDIR: case S_IFDIR:
res = mkdir(file_header->name, file_header->mode); res = mkdir(file_header->name, file_header->mode);
if ((errno != EISDIR) && (res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { if ((errno != EISDIR) && (res == -1)
bb_perror_msg("extract_archive: %s", file_header->name); && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
} ) {
break; bb_perror_msg("extract_archive: %s", file_header->name);
case S_IFLNK: }
/* Symlink */ break;
res = symlink(file_header->link_name, file_header->name); case S_IFLNK:
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { /* Symlink */
bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name); res = symlink(file_header->link_name, file_header->name);
} if ((res == -1)
break; && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
case S_IFSOCK: ) {
case S_IFBLK: bb_perror_msg("cannot create symlink "
case S_IFCHR: "from %s to '%s'",
case S_IFIFO: file_header->name,
res = mknod(file_header->name, file_header->mode, file_header->device); file_header->link_name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { }
bb_perror_msg("Cannot create node %s", file_header->name); break;
} case S_IFSOCK:
break; case S_IFBLK:
default: case S_IFCHR:
bb_error_msg_and_die("Unrecognised file type"); 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");
} }
} }

View File

@ -61,13 +61,13 @@ char get_header_cpio(archive_handle_t *archive_handle)
} }
{ {
unsigned long tmpsize; unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c", sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&file_header->mode, dummy, &inode, (unsigned int*)&file_header->mode,
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid, (unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
&nlink, &file_header->mtime, &tmpsize, &nlink, &file_header->mtime, &tmpsize,
dummy, &major, &minor, &namesize, dummy); dummy, &major, &minor, &namesize, dummy);
file_header->size = tmpsize; file_header->size = tmpsize;
} }
file_header->name = (char *) xzalloc(namesize + 1); file_header->name = (char *) xzalloc(namesize + 1);

View File

@ -74,12 +74,12 @@ char get_header_tar(archive_handle_t *archive_handle)
*/ */
if (strncmp(tar.formatted.magic, "ustar", 5) != 0) { if (strncmp(tar.formatted.magic, "ustar", 5) != 0) {
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY #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 #endif
bb_error_msg_and_die("invalid tar magic"); bb_error_msg_and_die("invalid tar magic");
} }
/* Do checksum on headers */ /* Do checksum on headers */
for (i = 0; i < 148 ; i++) { for (i = 0; i < 148 ; i++) {
sum += tar.raw[i]; sum += tar.raw[i];
} }
sum += ' ' * 8; 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->uid = xstrtoul(tar.formatted.uid, 8);
file_header->gid = xstrtoul(tar.formatted.gid, 8); file_header->gid = xstrtoul(tar.formatted.gid, 8);
// TODO: LFS support file_header->size = XSTRTOUOFF(tar.formatted.size, 8);
file_header->size = xstrtoul(tar.formatted.size, 8);
file_header->mtime = xstrtoul(tar.formatted.mtime, 8); file_header->mtime = xstrtoul(tar.formatted.mtime, 8);
file_header->link_name = tar.formatted.linkname[0] ? file_header->link_name = tar.formatted.linkname[0] ?
xstrdup(tar.formatted.linkname) : NULL; xstrdup(tar.formatted.linkname) : NULL;
file_header->device = makedev(xstrtoul(tar.formatted.devmajor, 8), if (tar.formatted.devmajor[0]) {
xstrtoul(tar.formatted.devminor, 8)); file_header->device = makedev(xstrtoul(tar.formatted.devmajor, 8),
xstrtoul(tar.formatted.devminor, 8));
}
/* Set bits 0-11 of the files mode */ /* Set bits 0-11 of the files mode */
file_header->mode = 07777 & xstrtoul(tar.formatted.mode, 8); file_header->mode = 07777 & xstrtoul(tar.formatted.mode, 8);

View File

@ -3,8 +3,8 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/ */
#include <unistd.h> //#include <unistd.h>
#include <string.h> //#include <string.h>
#include "libbb.h" #include "libbb.h"
#include "unarchive.h" #include "unarchive.h"
@ -12,7 +12,7 @@ archive_handle_t *init_handle(void)
{ {
archive_handle_t *archive_handle; archive_handle_t *archive_handle;
/* Initialise default values */ /* Initialize default values */
archive_handle = xzalloc(sizeof(archive_handle_t)); archive_handle = xzalloc(sizeof(archive_handle_t));
archive_handle->file_header = xmalloc(sizeof(file_header_t)); archive_handle->file_header = xmalloc(sizeof(file_header_t));
archive_handle->action_header = header_skip; archive_handle->action_header = header_skip;
@ -20,5 +20,5 @@ archive_handle_t *init_handle(void)
archive_handle->filter = filter_accept_all; archive_handle->filter = filter_accept_all;
archive_handle->seek = seek_by_jump; archive_handle->seek = seek_by_jump;
return(archive_handle); return archive_handle;
} }

View File

@ -5,9 +5,9 @@
# Licensed under the GPL v2, see the file LICENSE in this tarball. # Licensed under the GPL v2, see the file LICENSE in this tarball.
NEEDED-$(CONFIG_CHATTR) = y NEEDED-$(CONFIG_CHATTR) = y
NEEDED-$(LSATTR) = y NEEDED-$(CONFIG_LSATTR) = y
NEEDED-$(MKE2FS) = y NEEDED-$(CONFIG_MKE2FS) = y
NEEDED-$(TUNE2FS) = y NEEDED-$(CONFIG_TUNE2FS) = y
lib-y:= lib-y:=
lib-$(NEEDED-y) += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \ lib-$(NEEDED-y) += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \

View File

@ -89,23 +89,27 @@
/* "long" is long enough on this system */ /* "long" is long enough on this system */
# define STRTOOFF strtol # define STRTOOFF strtol
# define SAFE_STRTOOFF safe_strtol # define SAFE_STRTOOFF safe_strtol
# define XSTRTOUOFF xstrtoul
# define OFF_FMT "%ld" # define OFF_FMT "%ld"
# else # else
/* "long" is too short, need "lomg long" */ /* "long" is too short, need "long long" */
# define STRTOOFF strtoll # define STRTOOFF strtoll
# define SAFE_STRTOOFF safe_strtoll # define SAFE_STRTOOFF safe_strtoll
# define XSTRTOUOFF xstrtoull
# define OFF_FMT "%lld" # define OFF_FMT "%lld"
# endif # endif
#else #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) /* 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... */ * even if long==int on this arch. Crap... */
# define STRTOOFF strtol # define STRTOOFF strtol
# define SAFE_STRTOOFF safe_strtoi # define SAFE_STRTOOFF safe_strtoi
# define XSTRTOUOFF xstrtou
# define OFF_FMT "%d" # define OFF_FMT "%d"
# else # else
# define STRTOOFF strtol # define STRTOOFF strtol
# define SAFE_STRTOOFF safe_strtol # define SAFE_STRTOOFF safe_strtol
# define XSTRTOUOFF xstrtoul
# define OFF_FMT "%ld" # define OFF_FMT "%ld"
# endif # endif
#endif #endif
@ -313,6 +317,8 @@ struct suffix_mult {
unsigned int 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 xstrtoul_range_sfx(const char *numstr, int base,
unsigned long lower, unsigned long lower,
unsigned long upper, unsigned long upper,
@ -331,7 +337,6 @@ unsigned long xatoul_range(const char *numstr,
unsigned long lower, unsigned long lower,
unsigned long upper); unsigned long upper);
unsigned long xatoul(const char *numstr); unsigned long xatoul(const char *numstr);
unsigned long long xatoull(const char *numstr);
long xstrtol_range_sfx(const char *numstr, int base, long xstrtol_range_sfx(const char *numstr, int base,
long lower, long lower,
long upper, long upper,

View File

@ -9,7 +9,7 @@
#include "libbb.h" #include "libbb.h"
unsigned long long xatoull(const char *numstr) unsigned long long xstrtoull(const char *numstr, int base)
{ {
unsigned long long r; unsigned long long r;
int old_errno; int old_errno;
@ -18,7 +18,7 @@ unsigned long long xatoull(const char *numstr)
bb_error_msg_and_die("invalid number '%s'", numstr); bb_error_msg_and_die("invalid number '%s'", numstr);
old_errno = errno; old_errno = errno;
errno = 0; errno = 0;
r = strtoull(numstr, &e, 10); r = strtoull(numstr, &e, base);
if (errno || (numstr == e) || *e) if (errno || (numstr == e) || *e)
/* Error / no digits / illegal trailing chars */ /* Error / no digits / illegal trailing chars */
bb_error_msg_and_die("invalid number '%s'", numstr); bb_error_msg_and_die("invalid number '%s'", numstr);
@ -27,6 +27,11 @@ unsigned long long xatoull(const char *numstr)
return r; 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 xstrtoul_range_sfx(const char *numstr, int base,
unsigned long lower, unsigned long lower,
unsigned long upper, unsigned long upper,

View File

@ -43,7 +43,7 @@ config FEATURE_INSMOD_LOADINKMEM
config FEATURE_INSMOD_LOAD_MAP config FEATURE_INSMOD_LOAD_MAP
bool "Enable load map (-m) option" bool "Enable load map (-m) option"
default n default n
depends on INSMOD && FEATURE_2_4_MODULES depends on INSMOD && ( FEATURE_2_4_MODULES || FEATURE_2_6_MODULES )
help help
Enabling this, one would be able to get a load map Enabling this, one would be able to get a load map
output on stdout. This makes kernel module debugging output on stdout. This makes kernel module debugging

View File

@ -31,7 +31,9 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf);
/* Globals (can be accessed from signal handlers */ /* Globals (can be accessed from signal handlers */
static off_t content_len; /* Content-length of the file */ static off_t content_len; /* Content-length of the file */
static off_t beg_range; /* Range at which continue begins */ 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 */ static off_t transferred; /* Number of bytes transferred so far */
#endif
static int chunked; /* chunked transfer encoding */ static int chunked; /* chunked transfer encoding */
#ifdef CONFIG_FEATURE_WGET_STATUSBAR #ifdef CONFIG_FEATURE_WGET_STATUSBAR
static void progressmeter(int flag); static void progressmeter(int flag);

View File

@ -223,7 +223,7 @@ int chpst_main(int argc, char **argv)
{ {
char *m,*d,*o,*p,*f,*c,*r,*t,*n; 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, &set_user,&env_user,&env_dir,
&m,&d,&o,&p,&f,&c,&r,&t,&root,&n); &m,&d,&o,&p,&f,&c,&r,&t,&root,&n);
// if (option_mask32 & 0x1) // -u // if (option_mask32 & 0x1) // -u
@ -310,7 +310,7 @@ static void envdir(int argc, char **argv)
static void softlimit(int argc, char **argv) static void softlimit(int argc, char **argv)
{ {
char *a,*c,*d,*f,*l,*m,*o,*p,*r,*s,*t; 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); &a,&c,&d,&f,&l,&m,&o,&p,&r,&s,&t);
if (option_mask32 & 0x001) limita = xatoul(a); // -a if (option_mask32 & 0x001) limita = xatoul(a); // -a
if (option_mask32 & 0x002) limitc = xatoul(c); // -c if (option_mask32 & 0x002) limitc = xatoul(c); // -c

View File

@ -12542,7 +12542,7 @@ static int
letcmd(int argc, char **argv) letcmd(int argc, char **argv)
{ {
char **ap; char **ap;
arith_t i; arith_t i = 0;
ap = argv + 1; ap = argv + 1;
if(!*ap) if(!*ap)