# HG changeset patch # User Pascal Bellard # Date 1204027201 0 # Node ID b10bd3feab54450a2838d8b88c3184d5b6937e32 # Parent dce74a419f9892e2640c03586021b51d72f55ed0 Busybox: add df -i & hexdump -R diff -r dce74a419f98 -r b10bd3feab54 busybox/receipt --- a/busybox/receipt Tue Feb 26 11:58:04 2008 +0000 +++ b/busybox/receipt Tue Feb 26 12:00:01 2008 +0000 @@ -6,6 +6,7 @@ SHORT_DESC="Busybox combines tiny versions of many common UNIX utilities." MAINTAINER="pankso@slitaz.org" DEPENDS="slitaz-base-files" +BUILD_DEPENDS="bzip2" TARBALL="$PACKAGE-$VERSION.tar.bz2" WEB_SITE="http://www.busybox.net/" WGET_URL="http://www.busybox.net/downloads/$TARBALL" @@ -13,6 +14,8 @@ # Rules to configure and make the package. compile_rules() { + patch -p0 < stuff/$PACKAGE-$VERSION-hexdump.u + patch -p0 < stuff/$PACKAGE-$VERSION-df.u cp stuff/$PACKAGE-$VERSION.config $PACKAGE-$VERSION/.config cd $PACKAGE-$VERSION make oldconfig diff -r dce74a419f98 -r b10bd3feab54 busybox/stuff/busybox-1.7.3-df.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.7.3-df.u Tue Feb 26 12:00:01 2008 +0000 @@ -0,0 +1,42 @@ +--- busybox-1.7.3/coreutils/df.c ++++ busybox-1.7.3/coreutils/df.c +@@ -47,7 +47,7 @@ + + #if ENABLE_FEATURE_HUMAN_READABLE + opt_complementary = "h-km:k-hm:m-hk"; +- opt = getopt32(argv, "hmk"); ++ opt = getopt32(argv, "hmik"); + if (opt & 1) { + df_disp_hr = 0; + disp_units_hdr = " Size"; +@@ -56,9 +56,14 @@ + df_disp_hr = 1024*1024; + disp_units_hdr = "1M-blocks"; + } ++#define OPT_INODE 4 + #else ++#define OPT_INODE 1 + opt = getopt32(argv, "k"); + #endif ++ if (opt & OPT_INODE) { ++ disp_units_hdr = " Inodes"; ++ } + + printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", + "", disp_units_hdr); +@@ -105,6 +110,15 @@ + } + + if ((s.f_blocks > 0) || !mount_table){ ++ if (opt & OPT_INODE) { ++ s.f_blocks = s.f_files; ++ s.f_bavail = s.f_bfree = s.f_ffree; ++ s.f_bsize = 1; ++#if ENABLE_FEATURE_HUMAN_READABLE ++ if (df_disp_hr) ++ df_disp_hr = 1; ++#endif ++ } + blocks_used = s.f_blocks - s.f_bfree; + blocks_percent_used = 0; + if (blocks_used + s.f_bavail) { diff -r dce74a419f98 -r b10bd3feab54 busybox/stuff/busybox-1.7.3-hexdump.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.7.3-hexdump.u Tue Feb 26 12:00:01 2008 +0000 @@ -0,0 +1,77 @@ +--- busybox-1.7.3/util-linux/hexdump.c ++++ busybox-1.7.3/util-linux/hexdump.c +@@ -45,7 +45,7 @@ + + static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\""; + +-static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v"; ++static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:vR"; + + static const struct suffix_mult suffixes[] = { + { "b", 512 }, +@@ -59,6 +59,8 @@ + { + const char *p; + int ch; ++ FILE *fp; ++ smallint rdump = 0; + + bb_dump_vflag = FIRST; + bb_dump_length = -1; +@@ -70,7 +72,7 @@ + if ((p - hexdump_opts) < 5) { + bb_dump_add(add_first); + bb_dump_add(add_strings[(int)(p - hexdump_opts)]); +- } else if (ch == 'C') { ++ } if (ch == 'C') { + bb_dump_add("\"%08.8_Ax\n\""); + bb_dump_add("\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" "); + bb_dump_add("\" |\" 16/1 \"%_p\" \"|\\n\""); +@@ -90,6 +92,9 @@ + } /* else */ + if (ch == 'v') { + bb_dump_vflag = ALL; ++ } /* else */ ++ if (ch == 'R') { ++ rdump = 1; + } + } + } +@@ -101,5 +106,36 @@ + + argv += optind; + +- return bb_dump_dump(argv); ++ if (!rdump) { ++ return bb_dump_dump(argv); ++ } ++ ++ /* -R: reverse of 'hexdump -Cv' */ ++ fp = stdin; ++ if (!*argv) { ++ argv--; ++ goto jump_in; ++ } ++ ++ do { ++ char *buf; ++ fp = xfopen(*argv, "r"); ++ jump_in: ++ while ((buf = xmalloc_getline(fp)) != NULL) { ++ p = buf; ++ while (1) { ++ /* skip address or previous byte */ ++ while (isxdigit(*p)) p++; ++ while (*p == ' ') p++; ++ /* '|' char will break the line */ ++ if (!isxdigit(*p) || sscanf(p, "%x ", &ch) != 1) ++ break; ++ putchar(ch); ++ } ++ free(buf); ++ } ++ fclose(fp); ++ } while (*++argv); ++ ++ fflush_stdout_and_exit(EXIT_SUCCESS); + }