[PATCH 09/27] ubifs: introduce a new tool ubifs_dump
Dongsheng Yang
yangds.fnst at cn.fujitsu.com
Wed Aug 19 01:39:14 PDT 2015
Init a new tool named as ubifs_dump
Signed-off-by: Dongsheng Yang <yangds.fnst at cn.fujitsu.com>
---
Makefile | 8 ++++-
ubifs-utils/ubifs_dump/ubifs_dump.c | 68 +++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 ubifs-utils/ubifs_dump/ubifs_dump.c
diff --git a/Makefile b/Makefile
index ae02aac..cad71dc 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,8 @@ UBI_BINS = \
ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock
UBIFS_BINS = \
- mkfs.ubifs/mkfs.ubifs
+ mkfs.ubifs/mkfs.ubifs \
+ ubifs_dump/ubifs_dump
JFFSX_BINS = \
mkfs.jffs2 sumtool jffs2reader jffs2dump
FLASH_BINS = \
@@ -131,6 +132,11 @@ $(foreach v,$(UBI_BINS),$(eval $(call mkdep,ubi-utils/,$(v),libubi.a ubiutils-co
#
$(foreach v,crc16.o lpt.o compr.o devtable.o io.o hashtable.o hashtable_itr.o,$(eval UBIFS_LIBS += ../lib/$(v)))
+obj-ubifs_dump = $(UBIFS_LIBS)
+LDFLAGS_ubifs_dump = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS)
+LDLIBS_ubifs_dump = -lz -llzo2 -lm -luuid
+$(call mkdep,ubifs-utils/ubifs_dump/,ubifs_dump,,ubi-utils/libubi.a)
+
obj-mkfs.ubifs = $(UBIFS_LIBS)
LDFLAGS_mkfs.ubifs = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS)
LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid
diff --git a/ubifs-utils/ubifs_dump/ubifs_dump.c b/ubifs-utils/ubifs_dump/ubifs_dump.c
new file mode 100644
index 0000000..bbe1269
--- /dev/null
+++ b/ubifs-utils/ubifs_dump/ubifs_dump.c
@@ -0,0 +1,68 @@
+#include "ubifs_common.h"
+#define PROGRAM_NAME "ubifs-dump"
+#include "common.h"
+#include "io.h"
+
+static const char *optstring = "";
+
+static const struct option longopts[] = {
+ {NULL, 0, NULL, 0}
+};
+
+struct ubifs_info info_;
+static struct ubifs_info *c = &info_;
+
+static int get_options(int argc, char**argv)
+{
+ int opt, i;
+
+ while (1) {
+ opt = getopt_long(argc, argv, optstring, longopts, &i);
+ if (opt == -1)
+ break;
+ switch (opt) {
+ default:
+ break;
+ }
+ }
+
+ if (optind != argc && !output)
+ output = xstrdup(argv[optind]);
+
+ if (!output)
+ return err_msg("not output device or file specified");
+
+ if (open_ubi(c, output))
+ return err_msg("open ubi (%s) failed.", output);
+
+ return 0;
+}
+
+static int dump()
+{
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int err;
+
+ err = get_options(argc, argv);
+ if (err)
+ return err;
+ err = open_target(c, 1);
+ if (err)
+ return err;
+
+ err = dump();
+ if (err) {
+ close_target();
+ return err;
+ }
+
+ err = close_target();
+ if (err)
+ return err;
+
+ return 0;
+}
--
1.8.4.2
More information about the linux-mtd
mailing list