[BusyBox] [PATCH] add ibs= and obs= to dd
Hideki IWAMOTO
h-iwamoto at kit.hi-ho.ne.jp
Thu Apr 22 12:57:45 UTC 2004
On Mon, 05 Apr 2004 08:32:04 -0600, Erik Andersen wrote...
> On Sun Apr 04, 2004 at 05:10:47PM +0900, Hideki IWAMOTO wrote:
> > This patch adds support of ibs= and obs= to dd.
>
> Added as busybox/patches/dd_ibs_and_obs.diff
>
This is an additional patch for making raw I/O possible.
This is dependent on patches/dd_ibs_and_obs.diff.
diff -urN -x '*.orig' ../busybox-1.00-pre10.org/coreutils/Config.in ./coreutils/Config.in
--- ../busybox-1.00-pre10.org/coreutils/Config.in 2004-03-15 17:28:19.000000000 +0900
+++ ./coreutils/Config.in 2004-04-22 20:49:48.000000000 +0900
@@ -103,6 +103,13 @@
by default) using specific input and output blocksizes,
while optionally performing conversions on it.
+config CONFIG_FEATURE_DD_PAGE_ALIGNED_BUFFER
+ bool " Use page-aligned buffer"
+ default n
+ depends on CONFIG_DD
+ help
+ page-aligned buffer is required for raw I/O.
+
config CONFIG_DF
bool "df"
default n
diff -urN -x '*.orig' ../busybox-1.00-pre10.org/coreutils/dd.c ./coreutils/dd.c
--- ../busybox-1.00-pre10.org/coreutils/dd.c 2004-04-22 20:49:26.000000000 +0900
+++ ./coreutils/dd.c 2004-04-22 20:49:48.000000000 +0900
@@ -35,6 +35,12 @@
#define C_SYNC 0x0004
#define C_TWOBUFS 0x0008
+#ifdef CONFIG_FEATURE_DD_PAGE_ALIGNED_BUFFER
+#define BUFFER_ALLOC_FUNC xvalloc
+#else
+#define BUFFER_ALLOC_FUNC xmalloc
+#endif
+
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
@@ -114,10 +120,10 @@
bb_show_usage();
}
- ibuf = xmalloc(ibs);
+ ibuf = BUFFER_ALLOC_FUNC(ibs);
if (dd_flags & C_TWOBUFS)
- obuf = xmalloc(obs);
+ obuf = BUFFER_ALLOC_FUNC(obs);
else
obuf = ibuf;
diff -urN -x '*.orig' ../busybox-1.00-pre10.org/include/libbb.h ./include/libbb.h
--- ../busybox-1.00-pre10.org/include/libbb.h 2004-03-15 17:28:38.000000000 +0900
+++ ./include/libbb.h 2004-04-22 20:49:48.000000000 +0900
@@ -182,9 +182,10 @@
//#warning is this needed anymore?
#ifndef DMALLOC
-extern void *xmalloc (size_t size);
+extern void *xmalloc(size_t size);
extern void *xrealloc(void *old, size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
+extern void *xvalloc(size_t size);
#endif
extern char *bb_xstrdup (const char *s);
extern char *bb_xstrndup (const char *s, int n);
diff -urN -x '*.orig' ../busybox-1.00-pre10.org/libbb/Makefile.in ./libbb/Makefile.in
--- ../busybox-1.00-pre10.org/libbb/Makefile.in 2004-03-07 07:11:45.000000000 +0900
+++ ./libbb/Makefile.in 2004-04-22 20:49:48.000000000 +0900
@@ -63,7 +63,8 @@
LIBBB_MSRC1:=$(LIBBB_DIR)xfuncs.c
LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \
xfopen.o xopen.o xread.o xread_all.o xread_char.o \
- xferror.o xferror_stdout.o xfflush_stdout.o strlen.o
+ xferror.o xferror_stdout.o xfflush_stdout.o strlen.o \
+ xvalloc.o
LIBBB_MSRC2:=$(LIBBB_DIR)printf.c
LIBBB_MOBJ2:=bb_vfprintf.o bb_vprintf.o bb_fprintf.o bb_printf.o
diff -urN -x '*.orig' ../busybox-1.00-pre10.org/libbb/xfuncs.c ./libbb/xfuncs.c
--- ../busybox-1.00-pre10.org/libbb/xfuncs.c 2004-03-15 17:28:44.000000000 +0900
+++ ./libbb/xfuncs.c 2004-04-22 20:49:48.000000000 +0900
@@ -59,6 +59,16 @@
return ptr;
}
#endif
+
+#ifdef L_xvalloc
+extern void *xvalloc(size_t size)
+{
+ void *ptr = valloc(size);
+ if (ptr == NULL && size != 0)
+ bb_error_msg_and_die(bb_msg_memory_exhausted);
+ return ptr;
+}
+#endif
#endif /* DMALLOC */
#ifdef L_xstrdup
----
Hideki IWAMOTO h-iwamoto at kit.hi-ho.ne.jp
More information about the busybox
mailing list