mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
header_verbose_list: stop truncating file size in listing
This commit is contained in:
parent
376ce1e775
commit
cf30cc82a3
@ -111,25 +111,6 @@ char get_header_tar(archive_handle_t *archive_handle)
|
|||||||
bb_error_msg_and_die("invalid tar header checksum");
|
bb_error_msg_and_die("invalid tar header checksum");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
|
||||||
if (longname) {
|
|
||||||
file_header->name = longname;
|
|
||||||
longname = NULL;
|
|
||||||
}
|
|
||||||
else if (linkname) {
|
|
||||||
file_header->name = linkname;
|
|
||||||
linkname = NULL;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
file_header->name = xstrndup(tar.name, sizeof(tar.name));
|
|
||||||
if (tar.prefix[0]) {
|
|
||||||
char *temp = file_header->name;
|
|
||||||
file_header->name = concat_path_file(tar.prefix, temp);
|
|
||||||
free(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* getOctal trashes subsequent field, therefore we call it
|
/* getOctal trashes subsequent field, therefore we call it
|
||||||
* on fields in reverse order */
|
* on fields in reverse order */
|
||||||
#define GET_OCTAL(a) getOctal((a), sizeof(a))
|
#define GET_OCTAL(a) getOctal((a), sizeof(a))
|
||||||
@ -148,6 +129,24 @@ char get_header_tar(archive_handle_t *archive_handle)
|
|||||||
file_header->mode = 07777 & GET_OCTAL(tar.mode);
|
file_header->mode = 07777 & GET_OCTAL(tar.mode);
|
||||||
#undef GET_OCTAL
|
#undef GET_OCTAL
|
||||||
|
|
||||||
|
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||||
|
if (longname) {
|
||||||
|
file_header->name = longname;
|
||||||
|
longname = NULL;
|
||||||
|
}
|
||||||
|
else if (linkname) {
|
||||||
|
file_header->name = linkname;
|
||||||
|
linkname = NULL;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{ /* we trash mode[0] here, it's ok */
|
||||||
|
tar.name[sizeof(tar.name)] = '\0';
|
||||||
|
if (tar.prefix[0])
|
||||||
|
file_header->name = concat_path_file(tar.prefix, tar.name);
|
||||||
|
else
|
||||||
|
file_header->name = xstrdup(tar.name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set bits 12-15 of the files mode */
|
/* Set bits 12-15 of the files mode */
|
||||||
switch (tar.typeflag) {
|
switch (tar.typeflag) {
|
||||||
/* busybox identifies hard links as being regular files with 0 size and a link name */
|
/* busybox identifies hard links as being regular files with 0 size and a link name */
|
||||||
@ -209,10 +208,12 @@ char get_header_tar(archive_handle_t *archive_handle)
|
|||||||
/* Strip trailing '/' in directories */
|
/* Strip trailing '/' in directories */
|
||||||
/* Must be done after mode is set as '/' is used to check if its a directory */
|
/* Must be done after mode is set as '/' is used to check if its a directory */
|
||||||
cp = last_char_is(file_header->name, '/');
|
cp = last_char_is(file_header->name, '/');
|
||||||
if (cp) *cp = '\0';
|
|
||||||
|
|
||||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||||
archive_handle->action_header(archive_handle->file_header);
|
archive_handle->action_header(archive_handle->file_header);
|
||||||
|
/* Note that we kill the '/' only after action_header() */
|
||||||
|
/* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
|
||||||
|
if (cp) *cp = '\0';
|
||||||
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
||||||
archive_handle->action_data(archive_handle);
|
archive_handle->action_data(archive_handle);
|
||||||
llist_add_to(&(archive_handle->passed), file_header->name);
|
llist_add_to(&(archive_handle->passed), file_header->name);
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
* 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 <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#include "unarchive.h"
|
#include "unarchive.h"
|
||||||
|
|
||||||
@ -13,11 +10,11 @@ void header_verbose_list(const file_header_t *file_header)
|
|||||||
{
|
{
|
||||||
struct tm *mtime = localtime(&(file_header->mtime));
|
struct tm *mtime = localtime(&(file_header->mtime));
|
||||||
|
|
||||||
printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
|
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||||
bb_mode_string(file_header->mode),
|
bb_mode_string(file_header->mode),
|
||||||
file_header->uid,
|
file_header->uid,
|
||||||
file_header->gid,
|
file_header->gid,
|
||||||
(unsigned int) file_header->size,
|
file_header->size,
|
||||||
1900 + mtime->tm_year,
|
1900 + mtime->tm_year,
|
||||||
1 + mtime->tm_mon,
|
1 + mtime->tm_mon,
|
||||||
mtime->tm_mday,
|
mtime->tm_mday,
|
||||||
|
@ -563,9 +563,9 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
|
|||||||
archive_handle->seek = seek_by_read;
|
archive_handle->seek = seek_by_read;
|
||||||
|
|
||||||
/* do the decompression, and cleanup */
|
/* do the decompression, and cleanup */
|
||||||
if (xread_char(archive_handle->src_fd) != 0x1f ||
|
if (xread_char(archive_handle->src_fd) != 0x1f
|
||||||
xread_char(archive_handle->src_fd) != 0x9d)
|
|| xread_char(archive_handle->src_fd) != 0x9d
|
||||||
{
|
) {
|
||||||
bb_error_msg_and_die("invalid magic");
|
bb_error_msg_and_die("invalid magic");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ static off_t out_full, out_part, in_full, in_part;
|
|||||||
|
|
||||||
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
|
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%"OFF_FMT"+%"OFF_FMT" records in\n"
|
fprintf(stderr, "%"OFF_FMT"d+%"OFF_FMT"d records in\n"
|
||||||
"%"OFF_FMT"+%"OFF_FMT" records out\n",
|
"%"OFF_FMT"d+%"OFF_FMT"d records out\n",
|
||||||
in_full, in_part,
|
in_full, in_part,
|
||||||
out_full, out_part);
|
out_full, out_part);
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ static int list_single(struct dnode *dn)
|
|||||||
column += printf("%7ld ", (long) dn->dstat.st_ino);
|
column += printf("%7ld ", (long) dn->dstat.st_ino);
|
||||||
break;
|
break;
|
||||||
case LIST_BLOCKS:
|
case LIST_BLOCKS:
|
||||||
column += printf("%4"OFF_FMT" ", (off_t) dn->dstat.st_blocks >> 1);
|
column += printf("%4"OFF_FMT"d ", (off_t) dn->dstat.st_blocks >> 1);
|
||||||
break;
|
break;
|
||||||
case LIST_MODEBITS:
|
case LIST_MODEBITS:
|
||||||
column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
|
column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
|
||||||
@ -604,7 +604,7 @@ static int list_single(struct dnode *dn)
|
|||||||
column += printf("%9s ",
|
column += printf("%9s ",
|
||||||
make_human_readable_str(dn->dstat.st_size, 1, 0));
|
make_human_readable_str(dn->dstat.st_size, 1, 0));
|
||||||
} else {
|
} else {
|
||||||
column += printf("%9"OFF_FMT" ", (off_t) dn->dstat.st_size);
|
column += printf("%9"OFF_FMT"d ", (off_t) dn->dstat.st_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -88,13 +88,14 @@
|
|||||||
# define STRTOOFF strtol
|
# define STRTOOFF strtol
|
||||||
# define SAFE_STRTOOFF safe_strtol
|
# define SAFE_STRTOOFF safe_strtol
|
||||||
# define XSTRTOUOFF xstrtoul
|
# define XSTRTOUOFF xstrtoul
|
||||||
# define OFF_FMT "ld"
|
/* usage: printf("size: %"OFF_FMT"d (%"OFF_FMT"x)\n", sz, sz); */
|
||||||
|
# define OFF_FMT "l"
|
||||||
# else
|
# else
|
||||||
/* "long" is too short, need "long 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 XSTRTOUOFF xstrtoull
|
||||||
# define OFF_FMT "lld"
|
# define OFF_FMT "ll"
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# if 0 /* #if UINT_MAX == 0xffffffff */
|
# if 0 /* #if UINT_MAX == 0xffffffff */
|
||||||
@ -103,12 +104,12 @@
|
|||||||
# define STRTOOFF strtol
|
# define STRTOOFF strtol
|
||||||
# define SAFE_STRTOOFF safe_strtoi
|
# define SAFE_STRTOOFF safe_strtoi
|
||||||
# define XSTRTOUOFF xstrtou
|
# define XSTRTOUOFF xstrtou
|
||||||
# define OFF_FMT "d"
|
# define OFF_FMT ""
|
||||||
# else
|
# else
|
||||||
# define STRTOOFF strtol
|
# define STRTOOFF strtol
|
||||||
# define SAFE_STRTOOFF safe_strtol
|
# define SAFE_STRTOOFF safe_strtol
|
||||||
# define XSTRTOUOFF xstrtoul
|
# define XSTRTOUOFF xstrtoul
|
||||||
# define OFF_FMT "ld"
|
# define OFF_FMT "l"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
/* scary. better ideas? (but do *test* them first!) */
|
/* scary. better ideas? (but do *test* them first!) */
|
||||||
@ -703,7 +704,7 @@ extern const char bb_default_login_shell[];
|
|||||||
#define RB_POWER_OFF 0x4321fedc
|
#define RB_POWER_OFF 0x4321fedc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make sure we call functions instead of macros.
|
/* Make sure we call functions instead of macros. */
|
||||||
#undef isalnum
|
#undef isalnum
|
||||||
#undef isalpha
|
#undef isalpha
|
||||||
#undef isascii
|
#undef isascii
|
||||||
|
@ -149,7 +149,7 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (do_continue) {
|
if (do_continue) {
|
||||||
sprintf(buf, "REST %"OFF_FMT, beg_range);
|
sprintf(buf, "REST %"OFF_FMT"d", beg_range);
|
||||||
if (ftpcmd(buf, NULL, control_stream, buf) != 350) {
|
if (ftpcmd(buf, NULL, control_stream, buf) != 350) {
|
||||||
do_continue = 0;
|
do_continue = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -889,8 +889,8 @@ static int sendHeaders(HttpResponseNum responseNum)
|
|||||||
|
|
||||||
if (config->ContentLength != -1) { /* file */
|
if (config->ContentLength != -1) { /* file */
|
||||||
strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod));
|
strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod));
|
||||||
len += sprintf(buf+len, "Last-Modified: %s\r\n%s %"OFF_FMT"\r\n",
|
len += sprintf(buf+len, "Last-Modified: %s\r\n%s %"OFF_FMT"d\r\n",
|
||||||
timeStr, "Content-length:", (off_t) config->ContentLength);
|
timeStr, "Content-length:", config->ContentLength);
|
||||||
}
|
}
|
||||||
strcat(buf, "\r\n");
|
strcat(buf, "\r\n");
|
||||||
len += 2;
|
len += 2;
|
||||||
|
@ -287,7 +287,7 @@ int wget_main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (beg_range)
|
if (beg_range)
|
||||||
fprintf(sfp, "Range: bytes=%"OFF_FMT"-\r\n", beg_range);
|
fprintf(sfp, "Range: bytes=%"OFF_FMT"d-\r\n", beg_range);
|
||||||
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
|
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
|
||||||
if (extra_headers)
|
if (extra_headers)
|
||||||
fputs(extra_headers, sfp);
|
fputs(extra_headers, sfp);
|
||||||
@ -431,7 +431,7 @@ int wget_main(int argc, char **argv)
|
|||||||
dfp = open_socket(&s_in);
|
dfp = open_socket(&s_in);
|
||||||
|
|
||||||
if (beg_range) {
|
if (beg_range) {
|
||||||
sprintf(buf, "REST %"OFF_FMT, beg_range);
|
sprintf(buf, "REST %"OFF_FMT"d", beg_range);
|
||||||
if (ftpcmd(buf, NULL, sfp, buf) == 350)
|
if (ftpcmd(buf, NULL, sfp, buf) == 350)
|
||||||
content_len -= beg_range;
|
content_len -= beg_range;
|
||||||
}
|
}
|
||||||
|
@ -2277,7 +2277,7 @@ add_partition(int n, int sys)
|
|||||||
if (start > limit)
|
if (start > limit)
|
||||||
break;
|
break;
|
||||||
if (start >= temp+units_per_sector && num_read) {
|
if (start >= temp+units_per_sector && num_read) {
|
||||||
printf(_("Sector %"OFF_FMT" is already allocated\n"), temp);
|
printf(_("Sector %"OFF_FMT"d is already allocated\n"), temp);
|
||||||
temp = start;
|
temp = start;
|
||||||
num_read = 0;
|
num_read = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user