mirror of
https://github.com/sheumann/hush.git
synced 2024-08-22 02:29:00 +00:00
Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox
This commit is contained in:
commit
40c221334f
147
archival/unzip.c
147
archival/unzip.c
@ -253,14 +253,16 @@ int unzip_main(int argc, char **argv)
|
|||||||
enum { O_PROMPT, O_NEVER, O_ALWAYS };
|
enum { O_PROMPT, O_NEVER, O_ALWAYS };
|
||||||
|
|
||||||
zip_header_t zip_header;
|
zip_header_t zip_header;
|
||||||
smallint verbose = 1;
|
smallint quiet = 0;
|
||||||
|
IF_NOT_DESKTOP(const) smallint verbose = 0;
|
||||||
smallint listing = 0;
|
smallint listing = 0;
|
||||||
smallint overwrite = O_PROMPT;
|
smallint overwrite = O_PROMPT;
|
||||||
#if ENABLE_DESKTOP
|
#if ENABLE_DESKTOP
|
||||||
uint32_t cds_offset;
|
uint32_t cds_offset;
|
||||||
unsigned cds_entries;
|
unsigned cds_entries;
|
||||||
#endif
|
#endif
|
||||||
unsigned total_size;
|
unsigned long total_usize;
|
||||||
|
unsigned long total_size;
|
||||||
unsigned total_entries;
|
unsigned total_entries;
|
||||||
int dst_fd = -1;
|
int dst_fd = -1;
|
||||||
char *src_fn = NULL;
|
char *src_fn = NULL;
|
||||||
@ -273,8 +275,49 @@ int unzip_main(int argc, char **argv)
|
|||||||
char key_buf[80];
|
char key_buf[80];
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
|
||||||
|
/* -q, -l and -v: UnZip 5.52 of 28 February 2005, by Info-ZIP:
|
||||||
|
*
|
||||||
|
* # /usr/bin/unzip -qq -v decompress_unlzma.i.zip
|
||||||
|
* 204372 Defl:N 35278 83% 09-06-09 14:23 0d056252 decompress_unlzma.i
|
||||||
|
* # /usr/bin/unzip -q -v decompress_unlzma.i.zip
|
||||||
|
* Length Method Size Ratio Date Time CRC-32 Name
|
||||||
|
* -------- ------ ------- ----- ---- ---- ------ ----
|
||||||
|
* 204372 Defl:N 35278 83% 09-06-09 14:23 0d056252 decompress_unlzma.i
|
||||||
|
* -------- ------- --- -------
|
||||||
|
* 204372 35278 83% 1 file
|
||||||
|
* # /usr/bin/unzip -v decompress_unlzma.i.zip
|
||||||
|
* Archive: decompress_unlzma.i.zip
|
||||||
|
* Length Method Size Ratio Date Time CRC-32 Name
|
||||||
|
* -------- ------ ------- ----- ---- ---- ------ ----
|
||||||
|
* 204372 Defl:N 35278 83% 09-06-09 14:23 0d056252 decompress_unlzma.i
|
||||||
|
* -------- ------- --- -------
|
||||||
|
* 204372 35278 83% 1 file
|
||||||
|
* # unzip -v decompress_unlzma.i.zip
|
||||||
|
* Archive: decompress_unlzma.i.zip
|
||||||
|
* Length Date Time Name
|
||||||
|
* -------- ---- ---- ----
|
||||||
|
* 204372 09-06-09 14:23 decompress_unlzma.i
|
||||||
|
* -------- -------
|
||||||
|
* 204372 1 files
|
||||||
|
* # /usr/bin/unzip -l -qq decompress_unlzma.i.zip
|
||||||
|
* 204372 09-06-09 14:23 decompress_unlzma.i
|
||||||
|
* # /usr/bin/unzip -l -q decompress_unlzma.i.zip
|
||||||
|
* Length Date Time Name
|
||||||
|
* -------- ---- ---- ----
|
||||||
|
* 204372 09-06-09 14:23 decompress_unlzma.i
|
||||||
|
* -------- -------
|
||||||
|
* 204372 1 file
|
||||||
|
* # /usr/bin/unzip -l decompress_unlzma.i.zip
|
||||||
|
* Archive: decompress_unlzma.i.zip
|
||||||
|
* Length Date Time Name
|
||||||
|
* -------- ---- ---- ----
|
||||||
|
* 204372 09-06-09 14:23 decompress_unlzma.i
|
||||||
|
* -------- -------
|
||||||
|
* 204372 1 file
|
||||||
|
*/
|
||||||
|
|
||||||
/* '-' makes getopt return 1 for non-options */
|
/* '-' makes getopt return 1 for non-options */
|
||||||
while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
|
while ((opt = getopt(argc, argv, "-d:lnopqxv")) != -1) {
|
||||||
switch (opt_range) {
|
switch (opt_range) {
|
||||||
case 0: /* Options */
|
case 0: /* Options */
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
@ -294,7 +337,12 @@ int unzip_main(int argc, char **argv)
|
|||||||
dst_fd = STDOUT_FILENO;
|
dst_fd = STDOUT_FILENO;
|
||||||
|
|
||||||
case 'q': /* Be quiet */
|
case 'q': /* Be quiet */
|
||||||
verbose = 0;
|
quiet++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'v': /* Verbose list */
|
||||||
|
IF_DESKTOP(verbose++;)
|
||||||
|
listing = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* The zip file */
|
case 1: /* The zip file */
|
||||||
@ -373,14 +421,21 @@ int unzip_main(int argc, char **argv)
|
|||||||
if (base_dir)
|
if (base_dir)
|
||||||
xchdir(base_dir);
|
xchdir(base_dir);
|
||||||
|
|
||||||
if (verbose) {
|
if (quiet <= 1) { /* not -qq */
|
||||||
printf("Archive: %s\n", src_fn);
|
if (quiet == 0)
|
||||||
if (listing){
|
printf("Archive: %s\n", src_fn);
|
||||||
puts(" Length Date Time Name\n"
|
if (listing) {
|
||||||
" -------- ---- ---- ----");
|
puts(verbose ?
|
||||||
|
" Length Method Size Ratio Date Time CRC-32 Name\n"
|
||||||
|
"-------- ------ ------- ----- ---- ---- ------ ----"
|
||||||
|
:
|
||||||
|
" Length Date Time Name\n"
|
||||||
|
" -------- ---- ---- ----"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
total_usize = 0;
|
||||||
total_size = 0;
|
total_size = 0;
|
||||||
total_entries = 0;
|
total_entries = 0;
|
||||||
#if ENABLE_DESKTOP
|
#if ENABLE_DESKTOP
|
||||||
@ -449,20 +504,39 @@ int unzip_main(int argc, char **argv)
|
|||||||
|
|
||||||
} else { /* Extract entry */
|
} else { /* Extract entry */
|
||||||
if (listing) { /* List entry */
|
if (listing) { /* List entry */
|
||||||
if (verbose) {
|
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
||||||
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
if (!verbose) {
|
||||||
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
|
// " Length Date Time Name\n"
|
||||||
zip_header.formatted.ucmpsize,
|
// " -------- ---- ---- ----"
|
||||||
(dostime & 0x01e00000) >> 21,
|
printf( "%9u %02u-%02u-%02u %02u:%02u %s\n",
|
||||||
(dostime & 0x001f0000) >> 16,
|
(unsigned)zip_header.formatted.ucmpsize,
|
||||||
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
|
(dostime & 0x01e00000) >> 21,
|
||||||
(dostime & 0x0000f800) >> 11,
|
(dostime & 0x001f0000) >> 16,
|
||||||
(dostime & 0x000007e0) >> 5,
|
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
|
||||||
dst_fn);
|
(dostime & 0x0000f800) >> 11,
|
||||||
total_size += zip_header.formatted.ucmpsize;
|
(dostime & 0x000007e0) >> 5,
|
||||||
|
dst_fn);
|
||||||
|
total_usize += zip_header.formatted.ucmpsize;
|
||||||
} else {
|
} else {
|
||||||
/* short listing -- filenames only */
|
unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize;
|
||||||
puts(dst_fn);
|
percents = percents * 100;
|
||||||
|
if (zip_header.formatted.ucmpsize)
|
||||||
|
percents /= zip_header.formatted.ucmpsize;
|
||||||
|
// " Length Method Size Ratio Date Time CRC-32 Name\n"
|
||||||
|
// "-------- ------ ------- ----- ---- ---- ------ ----"
|
||||||
|
printf( "%8u Defl:N" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n",
|
||||||
|
(unsigned)zip_header.formatted.ucmpsize,
|
||||||
|
(unsigned)zip_header.formatted.cmpsize,
|
||||||
|
(unsigned)percents,
|
||||||
|
(dostime & 0x01e00000) >> 21,
|
||||||
|
(dostime & 0x001f0000) >> 16,
|
||||||
|
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
|
||||||
|
(dostime & 0x0000f800) >> 11,
|
||||||
|
(dostime & 0x000007e0) >> 5,
|
||||||
|
zip_header.formatted.crc32,
|
||||||
|
dst_fn);
|
||||||
|
total_usize += zip_header.formatted.ucmpsize;
|
||||||
|
total_size += zip_header.formatted.cmpsize;
|
||||||
}
|
}
|
||||||
i = 'n';
|
i = 'n';
|
||||||
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
|
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
|
||||||
@ -472,7 +546,7 @@ int unzip_main(int argc, char **argv)
|
|||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
bb_perror_msg_and_die("can't stat '%s'", dst_fn);
|
bb_perror_msg_and_die("can't stat '%s'", dst_fn);
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (!quiet) {
|
||||||
printf(" creating: %s\n", dst_fn);
|
printf(" creating: %s\n", dst_fn);
|
||||||
}
|
}
|
||||||
unzip_create_leading_dirs(dst_fn);
|
unzip_create_leading_dirs(dst_fn);
|
||||||
@ -520,7 +594,7 @@ int unzip_main(int argc, char **argv)
|
|||||||
unzip_create_leading_dirs(dst_fn);
|
unzip_create_leading_dirs(dst_fn);
|
||||||
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
|
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
|
||||||
case -1: /* Unzip */
|
case -1: /* Unzip */
|
||||||
if (verbose) {
|
if (!quiet) {
|
||||||
printf(" inflating: %s\n", dst_fn);
|
printf(" inflating: %s\n", dst_fn);
|
||||||
}
|
}
|
||||||
unzip_extract(&zip_header, dst_fd);
|
unzip_extract(&zip_header, dst_fd);
|
||||||
@ -549,17 +623,32 @@ int unzip_main(int argc, char **argv)
|
|||||||
goto check_file;
|
goto check_file;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("error: invalid response [%c]\n",(char)i);
|
printf("error: invalid response [%c]\n", (char)i);
|
||||||
goto check_file;
|
goto check_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_entries++;
|
total_entries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listing && verbose) {
|
if (listing && quiet <= 1) {
|
||||||
printf(" -------- -------\n"
|
if (!verbose) {
|
||||||
"%9d %d files\n",
|
// " Length Date Time Name\n"
|
||||||
total_size, total_entries);
|
// " -------- ---- ---- ----"
|
||||||
|
printf( " -------- -------\n"
|
||||||
|
"%9lu" " %u files\n",
|
||||||
|
total_usize, total_entries);
|
||||||
|
} else {
|
||||||
|
unsigned long percents = total_usize - total_size;
|
||||||
|
percents = percents * 100;
|
||||||
|
if (total_usize)
|
||||||
|
percents /= total_usize;
|
||||||
|
// " Length Method Size Ratio Date Time CRC-32 Name\n"
|
||||||
|
// "-------- ------ ------- ----- ---- ---- ------ ----"
|
||||||
|
printf( "-------- ------- --- -------\n"
|
||||||
|
"%8lu" "%17lu%4u%% %u files\n",
|
||||||
|
total_usize, total_size, (unsigned)percents,
|
||||||
|
total_entries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2824,9 +2824,21 @@
|
|||||||
"-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n"
|
"-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n"
|
||||||
|
|
||||||
#define modprobe_trivial_usage \
|
#define modprobe_trivial_usage \
|
||||||
"[-knqrsv] MODULE [symbol=value...]"
|
IF_MODPROBE_SMALL("[-qfwrsv] MODULE [symbol=value...]") \
|
||||||
|
IF_NOT_MODPROBE_SMALL("[-" \
|
||||||
|
IF_FEATURE_2_4_MODULES("k")"nqrsv" \
|
||||||
|
IF_FEATURE_MODPROBE_BLACKLIST("b")"] MODULE [symbol=value...]")
|
||||||
#define modprobe_full_usage "\n\n" \
|
#define modprobe_full_usage "\n\n" \
|
||||||
"Options:" \
|
"Options:" \
|
||||||
|
IF_MODPROBE_SMALL( \
|
||||||
|
"\n -q Quiet" \
|
||||||
|
"\n -f Force" \
|
||||||
|
"\n -w Wait for unload" \
|
||||||
|
"\n -r Remove module (stacks) or do autoclean" \
|
||||||
|
"\n -s Report via syslog instead of stderr" \
|
||||||
|
"\n -v Verbose" \
|
||||||
|
) \
|
||||||
|
IF_NOT_MODPROBE_SMALL( \
|
||||||
IF_FEATURE_2_4_MODULES( \
|
IF_FEATURE_2_4_MODULES( \
|
||||||
"\n -k Make module autoclean-able" \
|
"\n -k Make module autoclean-able" \
|
||||||
) \
|
) \
|
||||||
@ -2837,7 +2849,8 @@
|
|||||||
"\n -v Verbose" \
|
"\n -v Verbose" \
|
||||||
IF_FEATURE_MODPROBE_BLACKLIST( \
|
IF_FEATURE_MODPROBE_BLACKLIST( \
|
||||||
"\n -b Apply blacklist to module names too" \
|
"\n -b Apply blacklist to module names too" \
|
||||||
)
|
) \
|
||||||
|
)
|
||||||
|
|
||||||
#define modprobe_notes_usage \
|
#define modprobe_notes_usage \
|
||||||
"modprobe can (un)load a stack of modules, passing each module options (when\n" \
|
"modprobe can (un)load a stack of modules, passing each module options (when\n" \
|
||||||
|
@ -44,11 +44,13 @@ struct globals {
|
|||||||
char *module_load_options;
|
char *module_load_options;
|
||||||
smallint dep_bb_seen;
|
smallint dep_bb_seen;
|
||||||
smallint wrote_dep_bb_ok;
|
smallint wrote_dep_bb_ok;
|
||||||
int module_count;
|
unsigned module_count;
|
||||||
int module_found_idx;
|
int module_found_idx;
|
||||||
int stringbuf_idx;
|
unsigned stringbuf_idx;
|
||||||
char stringbuf[32 * 1024]; /* some modules have lots of stuff */
|
unsigned stringbuf_size;
|
||||||
|
char *stringbuf; /* some modules have lots of stuff */
|
||||||
/* for example, drivers/media/video/saa7134/saa7134.ko */
|
/* for example, drivers/media/video/saa7134/saa7134.ko */
|
||||||
|
/* therefore having a fixed biggish buffer is not wise */
|
||||||
};
|
};
|
||||||
#define G (*ptr_to_globals)
|
#define G (*ptr_to_globals)
|
||||||
#define modinfo (G.modinfo )
|
#define modinfo (G.modinfo )
|
||||||
@ -58,16 +60,29 @@ struct globals {
|
|||||||
#define module_found_idx (G.module_found_idx )
|
#define module_found_idx (G.module_found_idx )
|
||||||
#define module_load_options (G.module_load_options)
|
#define module_load_options (G.module_load_options)
|
||||||
#define stringbuf_idx (G.stringbuf_idx )
|
#define stringbuf_idx (G.stringbuf_idx )
|
||||||
|
#define stringbuf_size (G.stringbuf_size )
|
||||||
#define stringbuf (G.stringbuf )
|
#define stringbuf (G.stringbuf )
|
||||||
#define INIT_G() do { \
|
#define INIT_G() do { \
|
||||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
static void append(const char *s)
|
||||||
|
{
|
||||||
|
unsigned len = strlen(s);
|
||||||
|
if (stringbuf_idx + len + 15 > stringbuf_size) {
|
||||||
|
stringbuf_size = stringbuf_idx + len + 127;
|
||||||
|
dbg2_error_msg("grow stringbuf to %u", stringbuf_size);
|
||||||
|
stringbuf = xrealloc(stringbuf, stringbuf_size);
|
||||||
|
}
|
||||||
|
memcpy(stringbuf + stringbuf_idx, s, len);
|
||||||
|
stringbuf_idx += len;
|
||||||
|
}
|
||||||
|
|
||||||
static void appendc(char c)
|
static void appendc(char c)
|
||||||
{
|
{
|
||||||
if (stringbuf_idx < sizeof(stringbuf))
|
/* We appendc() only after append(), + 15 trick in append()
|
||||||
stringbuf[stringbuf_idx++] = c;
|
* makes it unnecessary to check for overflow here */
|
||||||
|
stringbuf[stringbuf_idx++] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bksp(void)
|
static void bksp(void)
|
||||||
@ -76,15 +91,6 @@ static void bksp(void)
|
|||||||
stringbuf_idx--;
|
stringbuf_idx--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void append(const char *s)
|
|
||||||
{
|
|
||||||
size_t len = strlen(s);
|
|
||||||
if (stringbuf_idx + len < sizeof(stringbuf)) {
|
|
||||||
memcpy(stringbuf + stringbuf_idx, s, len);
|
|
||||||
stringbuf_idx += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset_stringbuf(void)
|
static void reset_stringbuf(void)
|
||||||
{
|
{
|
||||||
stringbuf_idx = 0;
|
stringbuf_idx = 0;
|
||||||
@ -92,7 +98,7 @@ static void reset_stringbuf(void)
|
|||||||
|
|
||||||
static char* copy_stringbuf(void)
|
static char* copy_stringbuf(void)
|
||||||
{
|
{
|
||||||
char *copy = xmalloc(stringbuf_idx);
|
char *copy = xzalloc(stringbuf_idx + 1); /* terminating NUL */
|
||||||
return memcpy(copy, stringbuf, stringbuf_idx);
|
return memcpy(copy, stringbuf, stringbuf_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +222,8 @@ static void parse_module(module_info *info, const char *pathname)
|
|||||||
pos = (ptr - module_image);
|
pos = (ptr - module_image);
|
||||||
}
|
}
|
||||||
bksp(); /* remove last ' ' */
|
bksp(); /* remove last ' ' */
|
||||||
appendc('\0');
|
|
||||||
info->aliases = copy_stringbuf();
|
info->aliases = copy_stringbuf();
|
||||||
|
replace(info->aliases, '-', '_');
|
||||||
|
|
||||||
/* "dependency1 depandency2" */
|
/* "dependency1 depandency2" */
|
||||||
reset_stringbuf();
|
reset_stringbuf();
|
||||||
@ -228,7 +234,6 @@ static void parse_module(module_info *info, const char *pathname)
|
|||||||
dbg2_error_msg("dep:'%s'", ptr);
|
dbg2_error_msg("dep:'%s'", ptr);
|
||||||
append(ptr);
|
append(ptr);
|
||||||
}
|
}
|
||||||
appendc('\0');
|
|
||||||
info->deps = copy_stringbuf();
|
info->deps = copy_stringbuf();
|
||||||
|
|
||||||
free(module_image);
|
free(module_image);
|
||||||
|
Loading…
Reference in New Issue
Block a user