aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-24 14:53:18 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-24 14:53:18 +0000
commitcf30cc82a343802b601f01ae153916887f11eb7b (patch)
treedd5af380364efe67c7bd302d6c1c6d70f303f959
parent376ce1e775a97a01f1c454497fbe34d326043328 (diff)
downloadbusybox-w32-cf30cc82a343802b601f01ae153916887f11eb7b.tar.gz
busybox-w32-cf30cc82a343802b601f01ae153916887f11eb7b.tar.bz2
busybox-w32-cf30cc82a343802b601f01ae153916887f11eb7b.zip
header_verbose_list: stop truncating file size in listing
-rw-r--r--archival/libunarchive/get_header_tar.c41
-rw-r--r--archival/libunarchive/header_verbose_list.c7
-rw-r--r--archival/tar.c6
-rw-r--r--coreutils/dd.c4
-rw-r--r--coreutils/ls.c4
-rw-r--r--include/libbb.h11
-rw-r--r--networking/ftpgetput.c2
-rw-r--r--networking/httpd.c4
-rw-r--r--networking/wget.c4
-rw-r--r--util-linux/fdisk.c2
10 files changed, 42 insertions, 43 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index b5cae9f12..68f7b2b9b 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -111,25 +111,6 @@ char get_header_tar(archive_handle_t *archive_handle)
111 bb_error_msg_and_die("invalid tar header checksum"); 111 bb_error_msg_and_die("invalid tar header checksum");
112 } 112 }
113 113
114#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
115 if (longname) {
116 file_header->name = longname;
117 longname = NULL;
118 }
119 else if (linkname) {
120 file_header->name = linkname;
121 linkname = NULL;
122 } else
123#endif
124 {
125 file_header->name = xstrndup(tar.name, sizeof(tar.name));
126 if (tar.prefix[0]) {
127 char *temp = file_header->name;
128 file_header->name = concat_path_file(tar.prefix, temp);
129 free(temp);
130 }
131 }
132
133 /* getOctal trashes subsequent field, therefore we call it 114 /* getOctal trashes subsequent field, therefore we call it
134 * on fields in reverse order */ 115 * on fields in reverse order */
135#define GET_OCTAL(a) getOctal((a), sizeof(a)) 116#define GET_OCTAL(a) getOctal((a), sizeof(a))
@@ -148,6 +129,24 @@ char get_header_tar(archive_handle_t *archive_handle)
148 file_header->mode = 07777 & GET_OCTAL(tar.mode); 129 file_header->mode = 07777 & GET_OCTAL(tar.mode);
149#undef GET_OCTAL 130#undef GET_OCTAL
150 131
132#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
133 if (longname) {
134 file_header->name = longname;
135 longname = NULL;
136 }
137 else if (linkname) {
138 file_header->name = linkname;
139 linkname = NULL;
140 } else
141#endif
142 { /* we trash mode[0] here, it's ok */
143 tar.name[sizeof(tar.name)] = '\0';
144 if (tar.prefix[0])
145 file_header->name = concat_path_file(tar.prefix, tar.name);
146 else
147 file_header->name = xstrdup(tar.name);
148 }
149
151 /* Set bits 12-15 of the files mode */ 150 /* Set bits 12-15 of the files mode */
152 switch (tar.typeflag) { 151 switch (tar.typeflag) {
153 /* busybox identifies hard links as being regular files with 0 size and a link name */ 152 /* 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)
209 /* Strip trailing '/' in directories */ 208 /* Strip trailing '/' in directories */
210 /* Must be done after mode is set as '/' is used to check if its a directory */ 209 /* Must be done after mode is set as '/' is used to check if its a directory */
211 cp = last_char_is(file_header->name, '/'); 210 cp = last_char_is(file_header->name, '/');
212 if (cp) *cp = '\0';
213 211
214 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { 212 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
215 archive_handle->action_header(archive_handle->file_header); 213 archive_handle->action_header(archive_handle->file_header);
214 /* Note that we kill the '/' only after action_header() */
215 /* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
216 if (cp) *cp = '\0';
216 archive_handle->flags |= ARCHIVE_EXTRACT_QUIET; 217 archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
217 archive_handle->action_data(archive_handle); 218 archive_handle->action_data(archive_handle);
218 llist_add_to(&(archive_handle->passed), file_header->name); 219 llist_add_to(&(archive_handle->passed), file_header->name);
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c
index 130b6a268..7b97e524c 100644
--- a/archival/libunarchive/header_verbose_list.c
+++ b/archival/libunarchive/header_verbose_list.c
@@ -3,9 +3,6 @@
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
4 */ 4 */
5 5
6#include <stdio.h>
7#include <string.h>
8#include <time.h>
9#include "libbb.h" 6#include "libbb.h"
10#include "unarchive.h" 7#include "unarchive.h"
11 8
@@ -13,11 +10,11 @@ void header_verbose_list(const file_header_t *file_header)
13{ 10{
14 struct tm *mtime = localtime(&(file_header->mtime)); 11 struct tm *mtime = localtime(&(file_header->mtime));
15 12
16 printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s", 13 printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
17 bb_mode_string(file_header->mode), 14 bb_mode_string(file_header->mode),
18 file_header->uid, 15 file_header->uid,
19 file_header->gid, 16 file_header->gid,
20 (unsigned int) file_header->size, 17 file_header->size,
21 1900 + mtime->tm_year, 18 1900 + mtime->tm_year,
22 1 + mtime->tm_mon, 19 1 + mtime->tm_mon,
23 mtime->tm_mday, 20 mtime->tm_mday,
diff --git a/archival/tar.c b/archival/tar.c
index 911c2d35e..6aaa42273 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -563,9 +563,9 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
563 archive_handle->seek = seek_by_read; 563 archive_handle->seek = seek_by_read;
564 564
565 /* do the decompression, and cleanup */ 565 /* do the decompression, and cleanup */
566 if (xread_char(archive_handle->src_fd) != 0x1f || 566 if (xread_char(archive_handle->src_fd) != 0x1f
567 xread_char(archive_handle->src_fd) != 0x9d) 567 || xread_char(archive_handle->src_fd) != 0x9d
568 { 568 ) {
569 bb_error_msg_and_die("invalid magic"); 569 bb_error_msg_and_die("invalid magic");
570 } 570 }
571 571
diff --git a/coreutils/dd.c b/coreutils/dd.c
index c0df0b75c..96ea32f06 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -29,8 +29,8 @@ static off_t out_full, out_part, in_full, in_part;
29 29
30static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) 30static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
31{ 31{
32 fprintf(stderr, "%"OFF_FMT"+%"OFF_FMT" records in\n" 32 fprintf(stderr, "%"OFF_FMT"d+%"OFF_FMT"d records in\n"
33 "%"OFF_FMT"+%"OFF_FMT" records out\n", 33 "%"OFF_FMT"d+%"OFF_FMT"d records out\n",
34 in_full, in_part, 34 in_full, in_part,
35 out_full, out_part); 35 out_full, out_part);
36} 36}
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 909f4d54e..79e47ee6b 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -574,7 +574,7 @@ static int list_single(struct dnode *dn)
574 column += printf("%7ld ", (long) dn->dstat.st_ino); 574 column += printf("%7ld ", (long) dn->dstat.st_ino);
575 break; 575 break;
576 case LIST_BLOCKS: 576 case LIST_BLOCKS:
577 column += printf("%4"OFF_FMT" ", (off_t) dn->dstat.st_blocks >> 1); 577 column += printf("%4"OFF_FMT"d ", (off_t) dn->dstat.st_blocks >> 1);
578 break; 578 break;
579 case LIST_MODEBITS: 579 case LIST_MODEBITS:
580 column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); 580 column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
@@ -604,7 +604,7 @@ static int list_single(struct dnode *dn)
604 column += printf("%9s ", 604 column += printf("%9s ",
605 make_human_readable_str(dn->dstat.st_size, 1, 0)); 605 make_human_readable_str(dn->dstat.st_size, 1, 0));
606 } else { 606 } else {
607 column += printf("%9"OFF_FMT" ", (off_t) dn->dstat.st_size); 607 column += printf("%9"OFF_FMT"d ", (off_t) dn->dstat.st_size);
608 } 608 }
609 } 609 }
610 break; 610 break;
diff --git a/include/libbb.h b/include/libbb.h
index 2ccb6e7bb..ad64bad84 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -88,13 +88,14 @@
88# define STRTOOFF strtol 88# define STRTOOFF strtol
89# define SAFE_STRTOOFF safe_strtol 89# define SAFE_STRTOOFF safe_strtol
90# define XSTRTOUOFF xstrtoul 90# define XSTRTOUOFF xstrtoul
91# define OFF_FMT "ld" 91/* usage: printf("size: %"OFF_FMT"d (%"OFF_FMT"x)\n", sz, sz); */
92# define OFF_FMT "l"
92# else 93# else
93/* "long" is too short, need "long long" */ 94/* "long" is too short, need "long long" */
94# define STRTOOFF strtoll 95# define STRTOOFF strtoll
95# define SAFE_STRTOOFF safe_strtoll 96# define SAFE_STRTOOFF safe_strtoll
96# define XSTRTOUOFF xstrtoull 97# define XSTRTOUOFF xstrtoull
97# define OFF_FMT "lld" 98# define OFF_FMT "ll"
98# endif 99# endif
99#else 100#else
100# if 0 /* #if UINT_MAX == 0xffffffff */ 101# if 0 /* #if UINT_MAX == 0xffffffff */
@@ -103,12 +104,12 @@
103# define STRTOOFF strtol 104# define STRTOOFF strtol
104# define SAFE_STRTOOFF safe_strtoi 105# define SAFE_STRTOOFF safe_strtoi
105# define XSTRTOUOFF xstrtou 106# define XSTRTOUOFF xstrtou
106# define OFF_FMT "d" 107# define OFF_FMT ""
107# else 108# else
108# define STRTOOFF strtol 109# define STRTOOFF strtol
109# define SAFE_STRTOOFF safe_strtol 110# define SAFE_STRTOOFF safe_strtol
110# define XSTRTOUOFF xstrtoul 111# define XSTRTOUOFF xstrtoul
111# define OFF_FMT "ld" 112# define OFF_FMT "l"
112# endif 113# endif
113#endif 114#endif
114/* scary. better ideas? (but do *test* them first!) */ 115/* scary. better ideas? (but do *test* them first!) */
@@ -703,7 +704,7 @@ extern const char bb_default_login_shell[];
703#define RB_POWER_OFF 0x4321fedc 704#define RB_POWER_OFF 0x4321fedc
704#endif 705#endif
705 706
706// Make sure we call functions instead of macros. 707/* Make sure we call functions instead of macros. */
707#undef isalnum 708#undef isalnum
708#undef isalpha 709#undef isalpha
709#undef isascii 710#undef isascii
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 739a44155..a842401c0 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -149,7 +149,7 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
149 } 149 }
150 150
151 if (do_continue) { 151 if (do_continue) {
152 sprintf(buf, "REST %"OFF_FMT, beg_range); 152 sprintf(buf, "REST %"OFF_FMT"d", beg_range);
153 if (ftpcmd(buf, NULL, control_stream, buf) != 350) { 153 if (ftpcmd(buf, NULL, control_stream, buf) != 350) {
154 do_continue = 0; 154 do_continue = 0;
155 } else { 155 } else {
diff --git a/networking/httpd.c b/networking/httpd.c
index 97b04fb03..0de60ba06 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -889,8 +889,8 @@ static int sendHeaders(HttpResponseNum responseNum)
889 889
890 if (config->ContentLength != -1) { /* file */ 890 if (config->ContentLength != -1) { /* file */
891 strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod)); 891 strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod));
892 len += sprintf(buf+len, "Last-Modified: %s\r\n%s %"OFF_FMT"\r\n", 892 len += sprintf(buf+len, "Last-Modified: %s\r\n%s %"OFF_FMT"d\r\n",
893 timeStr, "Content-length:", (off_t) config->ContentLength); 893 timeStr, "Content-length:", config->ContentLength);
894 } 894 }
895 strcat(buf, "\r\n"); 895 strcat(buf, "\r\n");
896 len += 2; 896 len += 2;
diff --git a/networking/wget.c b/networking/wget.c
index f9a94627f..5a547ce1f 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -287,7 +287,7 @@ int wget_main(int argc, char **argv)
287#endif 287#endif
288 288
289 if (beg_range) 289 if (beg_range)
290 fprintf(sfp, "Range: bytes=%"OFF_FMT"-\r\n", beg_range); 290 fprintf(sfp, "Range: bytes=%"OFF_FMT"d-\r\n", beg_range);
291#if ENABLE_FEATURE_WGET_LONG_OPTIONS 291#if ENABLE_FEATURE_WGET_LONG_OPTIONS
292 if (extra_headers) 292 if (extra_headers)
293 fputs(extra_headers, sfp); 293 fputs(extra_headers, sfp);
@@ -431,7 +431,7 @@ int wget_main(int argc, char **argv)
431 dfp = open_socket(&s_in); 431 dfp = open_socket(&s_in);
432 432
433 if (beg_range) { 433 if (beg_range) {
434 sprintf(buf, "REST %"OFF_FMT, beg_range); 434 sprintf(buf, "REST %"OFF_FMT"d", beg_range);
435 if (ftpcmd(buf, NULL, sfp, buf) == 350) 435 if (ftpcmd(buf, NULL, sfp, buf) == 350)
436 content_len -= beg_range; 436 content_len -= beg_range;
437 } 437 }
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index bd2f1e87f..74c7710da 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -2277,7 +2277,7 @@ add_partition(int n, int sys)
2277 if (start > limit) 2277 if (start > limit)
2278 break; 2278 break;
2279 if (start >= temp+units_per_sector && num_read) { 2279 if (start >= temp+units_per_sector && num_read) {
2280 printf(_("Sector %"OFF_FMT" is already allocated\n"), temp); 2280 printf(_("Sector %"OFF_FMT"d is already allocated\n"), temp);
2281 temp = start; 2281 temp = start;
2282 num_read = 0; 2282 num_read = 0;
2283 } 2283 }