diff options
-rw-r--r-- | coreutils/dd.c | 31 | ||||
-rw-r--r-- | e2fsprogs/chattr.c | 8 | ||||
-rw-r--r-- | e2fsprogs/lsattr.c | 8 | ||||
-rw-r--r-- | e2fsprogs/util.c | 9 | ||||
-rw-r--r-- | include/libbb.h | 25 | ||||
-rw-r--r-- | networking/httpd.c | 12 | ||||
-rw-r--r-- | networking/wget.c | 16 |
7 files changed, 46 insertions, 63 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index 8d859ef5c..e63244d81 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -17,6 +17,7 @@ static const struct suffix_mult dd_suffixes[] = { { "b", 512 }, { "kD", 1000 }, { "k", 1024 }, + { "K", 1024 }, // compat with coreutils dd { "MD", 1000000 }, { "M", 1048576 }, { "GD", 1000000000 }, @@ -24,25 +25,26 @@ static const struct suffix_mult dd_suffixes[] = { { NULL, 0 } }; -static size_t out_full, out_part, in_full, in_part; +static FILEOFF_TYPE out_full, out_part, in_full, in_part; static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) { - bb_fprintf(stderr, "%ld+%ld records in\n%ld+%ld records out\n", - (long)in_full, (long)in_part, - (long)out_full, (long)out_part); + bb_fprintf(stderr, FILEOFF_FMT"+"FILEOFF_FMT" records in\n" + FILEOFF_FMT"+"FILEOFF_FMT" records out\n", + in_full, in_part, + out_full, out_part); } int dd_main(int argc, char **argv) { -#define sync_flag (1<<0) -#define noerror (1<<1) -#define trunc_flag (1<<2) +#define sync_flag (1<<0) +#define noerror (1<<1) +#define trunc_flag (1<<2) #define twobufs_flag (1<<3) int flags = trunc_flag; - size_t count = -1, oc = 0, ibs = 512, obs = 512; + size_t oc = 0, ibs = 512, obs = 512; ssize_t n; - off_t seek = 0, skip = 0; + FILEOFF_TYPE seek = 0, skip = 0, count = MAX_FILEOFF_TYPE; int oflag, ifd, ofd; const char *infile = NULL, *outfile = NULL; char *ibuf, *obuf; @@ -58,6 +60,7 @@ int dd_main(int argc, char **argv) } for (n = 1; n < argc; n++) { + // FIXME: make them capable of eating LARGE numbers if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("ibs=", argv[n], 4)) { ibs = bb_xparse_number(argv[n]+4, dd_suffixes); flags |= twobufs_flag; @@ -80,7 +83,7 @@ int dd_main(int argc, char **argv) ibuf = argv[n]+5; while (1) { if (!strncmp("notrunc", ibuf, 7)) { - flags ^= trunc_flag; + flags &= ~trunc_flag; ibuf += 7; } else if (!strncmp("sync", ibuf, 4)) { flags |= sync_flag; @@ -105,14 +108,14 @@ int dd_main(int argc, char **argv) obuf = ibuf; if (infile != NULL) - ifd = xopen(infile, O_RDONLY); + ifd = xopen(infile, O_RDONLY | (O_LARGEFILE * ENABLE_LFS)); else { ifd = STDIN_FILENO; infile = bb_msg_standard_input; } if (outfile != NULL) { - oflag = O_WRONLY | O_CREAT; + oflag = O_WRONLY | O_CREAT | (O_LARGEFILE * ENABLE_LFS); if (!seek && (flags & trunc_flag)) oflag |= O_TRUNC; @@ -134,7 +137,7 @@ int dd_main(int argc, char **argv) } if (skip) { - if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { + if (LSEEK(ifd, skip * ibs, SEEK_CUR) < 0) { while (skip-- > 0) { n = safe_read(ifd, ibuf, ibs); if (n < 0) @@ -146,7 +149,7 @@ int dd_main(int argc, char **argv) } if (seek) { - if (lseek(ofd, seek * obs, SEEK_CUR) < 0) + if (LSEEK(ofd, seek * obs, SEEK_CUR) < 0) goto die_outfile; } diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c index 2cb75e86f..618d8c440 100644 --- a/e2fsprogs/chattr.c +++ b/e2fsprogs/chattr.c @@ -53,14 +53,6 @@ static unsigned long af; static unsigned long rf; static unsigned long sf; -#ifdef CONFIG_LFS -# define LSTAT lstat64 -# define STRUCT_STAT struct stat64 -#else -# define LSTAT lstat -# define STRUCT_STAT struct stat -#endif - struct flags_char { unsigned long flag; char optchar; diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c index e76f8d9d7..1b7cf44aa 100644 --- a/e2fsprogs/lsattr.c +++ b/e2fsprogs/lsattr.c @@ -41,14 +41,6 @@ #define OPT_GENERATION 16 static int flags; -#ifdef CONFIG_LFS -# define LSTAT lstat64 -# define STRUCT_STAT struct stat64 -#else -# define LSTAT lstat -# define STRUCT_STAT struct stat -#endif - static void list_attributes(const char *name) { unsigned long fsflags; diff --git a/e2fsprogs/util.c b/e2fsprogs/util.c index efb128f59..aaee50ae6 100644 --- a/e2fsprogs/util.c +++ b/e2fsprogs/util.c @@ -33,13 +33,8 @@ void proceed_question(void) void check_plausibility(const char *device, int force) { int val; -#ifdef CONFIG_LFS - struct stat64 s; - val = stat64(device, &s); -#else - struct stat s; - val = stat(device, &s); -#endif + STRUCT_STAT s; + val = STAT(device, &s); if (force) return; if(val == -1) diff --git a/include/libbb.h b/include/libbb.h index 84c8af4b6..11e1e62d9 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -61,6 +61,31 @@ #define PATH_MAX 256 #endif +/* Large file support */ +#ifdef CONFIG_LFS +# define FILEOFF_TYPE off64_t +# define FILEOFF_FMT "%lld" +# define LSEEK lseek64 +# define STAT stat64 +# define LSTAT lstat64 +# define STRUCT_STAT struct stat64 +# define STRTOOFF strtoll +# define SAFE_STRTOOFF safe_strtoll +#else +# define FILEOFF_TYPE off_t +# define FILEOFF_FMT "%ld" +# define LSEEK lseek +# define STAT stat +# define LSTAT lstat +# define STRUCT_STAT struct stat +# define STRTOOFF strtol +# define SAFE_STRTOOFF safe_strtol +/* Do we need to undefine O_LARGEFILE? */ +#endif +/* scary. better ideas? (but do *test* them first!) */ +#define MAX_FILEOFF_TYPE \ + ((FILEOFF_TYPE)~((FILEOFF_TYPE)1 << (sizeof(FILEOFF_TYPE)*8-1))) + /* Some useful definitions */ #undef FALSE #define FALSE ((int) 0) diff --git a/networking/httpd.c b/networking/httpd.c index 8f985774e..0e471ba58 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -97,14 +97,6 @@ static const char default_path_httpd_conf[] = "/etc"; static const char httpd_conf[] = "httpd.conf"; static const char home[] = "./"; -#if ENABLE_LFS -# define cont_l_fmt "%lld" -# define cont_l_type (long long) -#else -# define cont_l_fmt "%ld" -# define cont_l_type (long) -#endif - #define TIMEOUT 60 // Note: busybox xfuncs are not used because we want the server to keep running @@ -927,8 +919,8 @@ static int sendHeaders(HttpResponseNum responseNum) if (config->ContentLength != -1) { /* file */ strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod)); - len += sprintf(buf+len, "Last-Modified: %s\r\n%s " cont_l_fmt "\r\n", - timeStr, Content_length, cont_l_type config->ContentLength); + len += sprintf(buf+len, "Last-Modified: %s\r\n%s "FILEOFF_FMT"\r\n", + timeStr, Content_length, (FILEOFF_TYPE) config->ContentLength); } strcat(buf, "\r\n"); len += 2; diff --git a/networking/wget.c b/networking/wget.c index 788c291b9..eda0bb87c 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -13,22 +13,6 @@ #include "busybox.h" #include <getopt.h> /* for struct option */ -#ifdef CONFIG_LFS -# define FILEOFF_TYPE off64_t -# define FILEOFF_FMT "%lld" -# define LSEEK lseek64 -# define STRTOOFF strtoll -# define SAFE_STRTOOFF safe_strtoll -/* stat64 etc as needed... */ -#else -# define FILEOFF_TYPE off_t -# define FILEOFF_FMT "%ld" -# define LSEEK lseek -# define STRTOOFF strtol -# define SAFE_STRTOOFF safe_strtol -/* Do we need to undefine O_LARGEFILE? */ -#endif - struct host_info { // May be used if we ever will want to free() all xstrdup()s... /* char *allocated; */ |