From cd5aa5c5dac87a51331b03ee08582e18f489a328 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 18 Jun 2010 11:47:45 +0200 Subject: mkfs_ext2: fix handling of -I argument -I but was treated as a character Signed-off-by: Bernhard Reutner-Fischer --- util-linux/mkfs_ext2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index fd54734fc..388bd7b88 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -210,7 +210,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) // using global "option_mask32" instead of local "opts": // we are register starved here - opt_complementary = "-1:b+:m+:i+"; + opt_complementary = "-1:b+:i+:I+:m+"; /*opts =*/ getopt32(argv, "cl:b:f:i:I:J:G:N:m:o:g:L:M:O:r:E:T:U:jnqvFS", NULL, &bs, NULL, &bpi, &user_inodesize, NULL, NULL, NULL, &reserved_percent, NULL, NULL, &label, NULL, NULL, NULL, NULL, NULL, NULL); -- cgit v1.2.3 From 5070124763a96d36b94b2a2e58df27ada3623cb8 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 18 Jun 2010 11:49:44 +0200 Subject: mkfs_ext2: reuse string function old new delta mkfs_ext2_main 2376 2378 +2 .rodata 135872 135848 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-24) Total: -22 bytes Signed-off-by: Bernhard Reutner-Fischer --- util-linux/mkfs_ext2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 388bd7b88..1748a475c 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -220,7 +220,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) xmove_fd(xopen(argv[0], O_WRONLY), fd); fstat(fd, &st); if (!S_ISBLK(st.st_mode) && !(option_mask32 & OPT_F)) - bb_error_msg_and_die("not a block device"); + bb_error_msg_and_die("%s: not a block device", argv[0]); // check if it is mounted // N.B. what if we format a file? find_mount_point will return false negative since -- cgit v1.2.3 From 0f022c05658a4c014ebdebdc55461afa890c98a0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 12:28:05 +0200 Subject: cpio.tests: mention suid bits too, not only sgid Signed-off-by: Denys Vlasenko --- testsuite/cpio.tests | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index 42e3ff8dc..5b397b01c 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests @@ -97,14 +97,14 @@ usr " "" "" SKIP= -# chown on a link was affecting file, dropping its sgid bits +# chown on a link was affecting file, dropping its suid/sgid bits rm -rf cpio.testdir optional FEATURE_CPIO_O mkdir cpio.testdir touch cpio.testdir/file -chmod 6755 cpio.testdir/file # set the suid/sgid bit +chmod 6755 cpio.testdir/file # sets suid/sgid bits ln -sf file cpio.testdir/link -testing "cpio restores sgid bits" \ +testing "cpio restores suid/sgid bits" \ "cd cpio.testdir && { echo file; echo link; } | cpio -ovHnewc >pack.cpio && rm ???? && cpio -idmvu /dev/null; stat -c '%a %n' file" \ "\ -- cgit v1.2.3 From 8f599f9a310b07b482eac1fd67e8c8a1c7a53124 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 12:40:57 +0200 Subject: mkfs_ext2: improve comments a bit Signed-off-by: Denys Vlasenko --- util-linux/mkfs_ext2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 1748a475c..14feb9288 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -140,7 +140,7 @@ static void PUT(uint64_t off, void *buf, uint32_t size) // only for directories, which never need i_size_high). // // Standard mke2fs creates a filesystem with 256-byte inodes if it is -// bigger than 0.5GB. So far, we do not do this. +// bigger than 0.5GB. // Standard mke2fs 1.41.9: // Usage: mke2fs [-c|-l filename] [-b block-size] [-f fragment-size] @@ -212,8 +212,11 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) // we are register starved here opt_complementary = "-1:b+:i+:I+:m+"; /*opts =*/ getopt32(argv, "cl:b:f:i:I:J:G:N:m:o:g:L:M:O:r:E:T:U:jnqvFS", - NULL, &bs, NULL, &bpi, &user_inodesize, NULL, NULL, NULL, - &reserved_percent, NULL, NULL, &label, NULL, NULL, NULL, NULL, NULL, NULL); + /*lbfi:*/ NULL, &bs, NULL, &bpi, + /*IJGN:*/ &user_inodesize, NULL, NULL, NULL, + /*mogL:*/ &reserved_percent, NULL, NULL, &label, + /*MOrE:*/ NULL, NULL, NULL, NULL, + /*TU:*/ NULL, NULL); argv += optind; // argv[0] -- device // open the device, check the device is a block device -- cgit v1.2.3 From f934a51c9b0020f842faebaedba9c67d4b0af73d Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 18 Jun 2010 13:26:11 +0200 Subject: ignore changes to Kbuild files, they are generated Signed-off-by: Dan Fandrich Signed-off-by: Denys Vlasenko --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b7840e494..53bd540a2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.o.* *.a *.s +Kbuild # # Never ignore these -- cgit v1.2.3 From eafc6956f6fa86cb7d4bf488e96eeee34c551819 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 17 Jun 2010 23:30:27 -0700 Subject: Allow CONFIG_VOLUMEID to be turned off Signed-off-by: Dan Fandrich Signed-off-by: Denys Vlasenko --- util-linux/Config.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util-linux/Config.src b/util-linux/Config.src index e97125917..3c3e05ec4 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src @@ -472,7 +472,7 @@ config FEATURE_USE_TERMIOS config VOLUMEID bool #No description makes it a hidden option - default y + default n config FEATURE_VOLUMEID_EXT bool "Ext filesystem" @@ -725,7 +725,7 @@ config FEATURE_MOUNT_HELPERS The idea is to use such virtual filesystems in /etc/fstab. config FEATURE_MOUNT_LABEL - bool "Support specifiying devices by label or UUID" + bool "Support specifying devices by label or UUID" default y depends on MOUNT select VOLUMEID @@ -930,7 +930,7 @@ config FEATURE_MTAB_SUPPORT If you must use this, keep in mind it's inherently brittle (for example a mount under chroot won't update it), can't handle modern features like separate per-process filesystem namespaces, requires - that your /etc directory be writeable, tends to get easily confused + that your /etc directory be writable, tends to get easily confused by --bind or --move mounts, won't update if you rename a directory that contains a mount point, and so on. (In brief: avoid.) -- cgit v1.2.3 From b76f18d331f865225f1702794e66e87818584f99 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 17 Jun 2010 21:39:44 -0700 Subject: Improve unzip's handling of stream ZIP files Search harder for the ZIP magic numbers at the end of a file by checking 16 KiB from the end instead of just 1 KiB. ZIP files with long comments (such as certain cryptographically signed files) or those sitting in a wrapper could have more than 1 KiB of data after the magic numbers, so they couldn't be read. Signed-off-by: Dan Fandrich Signed-off-by: Denys Vlasenko --- archival/unzip.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/archival/unzip.c b/archival/unzip.c index 1d3291ab8..84081c021 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -150,23 +150,26 @@ enum { zip_fd = 3 }; #if ENABLE_DESKTOP + +#define PEEK_FROM_END 16384 + /* NB: does not preserve file position! */ static uint32_t find_cdf_offset(void) { - unsigned char buf[1024]; cde_header_t cde_header; unsigned char *p; off_t end; + unsigned char *buf = xzalloc(PEEK_FROM_END); end = xlseek(zip_fd, 0, SEEK_END); - end -= 1024; + end -= PEEK_FROM_END; if (end < 0) end = 0; xlseek(zip_fd, end, SEEK_SET); - full_read(zip_fd, buf, 1024); + full_read(zip_fd, buf, PEEK_FROM_END); p = buf; - while (p <= buf + 1024 - CDE_HEADER_LEN - 4) { + while (p <= buf + PEEK_FROM_END - CDE_HEADER_LEN - 4) { if (*p != 'P') { p++; continue; @@ -180,8 +183,10 @@ static uint32_t find_cdf_offset(void) /* we found CDE! */ memcpy(cde_header.raw, p + 1, CDE_HEADER_LEN); FIX_ENDIANNESS_CDE(cde_header); + free(buf); return cde_header.formatted.cdf_offset; } + //free(buf); bb_error_msg_and_die("can't find file table"); }; -- cgit v1.2.3 From 1ed2fb40c919a25fe6920680cf898d0b4870c60e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 14:09:48 +0200 Subject: ash: cosmetics, no code changes Signed-off-by: Denys Vlasenko --- shell/ash.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 90680e849..fcaa7b18e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "shell_common.h" #include "math.h" @@ -7310,7 +7311,7 @@ shellexec(char **argv, const char *path, int idx) #endif clearredir(/*drop:*/ 1); - envp = listvars(VEXPORT, VUNSET, 0); + envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); if (strchr(argv[0], '/') != NULL #if ENABLE_FEATURE_SH_STANDALONE || (applet_no = find_applet_by_name(argv[0])) >= 0 @@ -12468,7 +12469,7 @@ unsetfunc(const char *name) struct tblentry *cmdp; cmdp = cmdlookup(name, 0); - if (cmdp!= NULL && cmdp->cmdtype == CMDFUNCTION) + if (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION) delete_cmd_entry(); } @@ -12485,7 +12486,7 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) int flag = 0; int ret = 0; - while ((i = nextopt("vf")) != '\0') { + while ((i = nextopt("vf")) != 0) { flag = i; } @@ -12502,11 +12503,6 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) return ret & 1; } - -/* setmode.c */ - -#include - static const unsigned char timescmd_str[] ALIGN1 = { ' ', offsetof(struct tms, tms_utime), '\n', offsetof(struct tms, tms_stime), @@ -12514,7 +12510,6 @@ static const unsigned char timescmd_str[] ALIGN1 = { '\n', offsetof(struct tms, tms_cstime), 0 }; - static int FAST_FUNC timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { @@ -12533,14 +12528,15 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) s/60, s%60, ((t - s * clk_tck) * 1000) / clk_tck, p[0]); - } while (*(p += 2)); + p += 2; + } while (*p); return 0; } #if ENABLE_SH_MATH_SUPPORT /* - * The let builtin. partial stolen from GNU Bash, the Bourne Again SHell. + * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell. * Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. * * Copyright (C) 2003 Vladimir Oleynik @@ -12559,18 +12555,6 @@ letcmd(int argc UNUSED_PARAM, char **argv) return !i; } -#endif /* SH_MATH_SUPPORT */ - - -/* ============ miscbltin.c - * - * Miscellaneous builtins. - */ - -#undef rflag - -#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 1 -typedef enum __rlimit_resource rlim_t; #endif /* -- cgit v1.2.3 From 7df28bbb8fa3ba2878c288401c898ec477e55df1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 14:23:47 +0200 Subject: ash: fix unset in standalone mode Signed-off-by: Denys Vlasenko --- shell/ash.c | 1 + shell/ash_test/ash-standalone/var_standalone1.right | 1 + shell/ash_test/ash-standalone/var_standalone1.tests | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 shell/ash_test/ash-standalone/var_standalone1.right create mode 100755 shell/ash_test/ash-standalone/var_standalone1.tests diff --git a/shell/ash.c b/shell/ash.c index fcaa7b18e..74fe8617b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7252,6 +7252,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char ** #if ENABLE_FEATURE_SH_STANDALONE if (applet_no >= 0) { if (APPLET_IS_NOEXEC(applet_no)) { + clearenv(); while (*envp) putenv(*envp++); run_applet_no_and_exit(applet_no, argv); diff --git a/shell/ash_test/ash-standalone/var_standalone1.right b/shell/ash_test/ash-standalone/var_standalone1.right new file mode 100644 index 000000000..37457fd74 --- /dev/null +++ b/shell/ash_test/ash-standalone/var_standalone1.right @@ -0,0 +1 @@ +Done: 1 diff --git a/shell/ash_test/ash-standalone/var_standalone1.tests b/shell/ash_test/ash-standalone/var_standalone1.tests new file mode 100755 index 000000000..1e905ba75 --- /dev/null +++ b/shell/ash_test/ash-standalone/var_standalone1.tests @@ -0,0 +1,2 @@ +VAR=42 $THIS_SH -c 'unset VAR; env | grep ^VAR' +echo Done: $? -- cgit v1.2.3 From b87c17cd16f1b23a07a65ee90a3e30a49992fa51 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 15:15:24 +0200 Subject: *: stop defining _GNU_SOURCE in source files, it's in CFLAGS anyway Signed-off-by: Denys Vlasenko --- e2fsprogs/old_e2fsprogs/e2fsck.c | 4 ---- libbb/get_line_from_file.c | 5 ----- modutils/depmod.c | 2 -- shell/ash.c | 6 ------ util-linux/hwclock.c | 7 ------- 5 files changed, 24 deletions(-) diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index 7384bc453..4c4c78d00 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c @@ -29,10 +29,6 @@ * Licensed under GPLv2 or later, see file License in this tarball for details. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 /* get strnlen() */ -#endif - #include "e2fsck.h" /*Put all of our defines here to clean things up*/ #define _(x) x diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 3cb46d240..cbfb45b7c 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c @@ -9,11 +9,6 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -/* for getline() [GNUism] -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif -*/ #include "libbb.h" /* This function reads an entire line from a text file, up to a newline diff --git a/modutils/depmod.c b/modutils/depmod.c index 4718c4dcb..c734f142b 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -8,8 +8,6 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#undef _GNU_SOURCE -#define _GNU_SOURCE #include "libbb.h" #include "modutils.h" #include /* uname() */ diff --git a/shell/ash.c b/shell/ash.c index 74fe8617b..171740768 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -36,12 +36,6 @@ #define JOBS ENABLE_ASH_JOB_CONTROL -#if DEBUG -# ifndef _GNU_SOURCE -# define _GNU_SOURCE -# endif -#endif - #include "busybox.h" /* for applet_names */ #include #include diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 416271b31..3da2e23c3 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -12,13 +12,6 @@ #include #include "rtc_.h" -#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS -# ifndef _GNU_SOURCE -# define _GNU_SOURCE -# endif -#endif - - /* diff code is disabled: it's not sys/hw clock diff, it's some useless * "time between hwclock was started and we saw CMOS tick" quantity. * It's useless since hwclock is started at a random moment, -- cgit v1.2.3 From 8cd9f343e74ca65f36c42a44e845716ba5411663 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 15:36:48 +0200 Subject: ash: times builtin: use unsigned type; take free-of-charge modulo Signed-off-by: Denys Vlasenko --- shell/ash.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 171740768..f581b5bdf 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12508,7 +12508,7 @@ static const unsigned char timescmd_str[] ALIGN1 = { static int FAST_FUNC timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { - long clk_tck, s, t; + unsigned long clk_tck, s, t; const unsigned char *p; struct tms buf; @@ -12519,9 +12519,10 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) do { t = *(clock_t *)(((char *) &buf) + p[1]); s = t / clk_tck; - out1fmt("%ldm%ld.%.3lds%c", - s/60, s%60, - ((t - s * clk_tck) * 1000) / clk_tck, + t = t % clk_tck; + out1fmt("%lum%lu.%03lus%c", + s / 60, s % 60, + (t * 1000) / clk_tck, p[0]); p += 2; } while (*p); -- cgit v1.2.3