aboutsummaryrefslogtreecommitdiff
path: root/misc-utils/lsmtd.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2017-03-15 12:12:12 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2018-06-18 12:22:26 +0200
commitc26ce774a7209012c0505ee841d54898c6665e20 (patch)
tree8067e5dbd7af0f50018cca26c9a6d10bd20a1bde /misc-utils/lsmtd.h
parentf1feccec5ad848b4f763376480a006a9d58fa721 (diff)
Add lsmtd program
This patch adds a program called "lsmtd". The program produces a pretty printed list of the hierarchy of UBI and MTD devices on a system. It tries to imitate the lsblk program from util-linux as closely as possible. A number of command line switches are available to fine tune what information should be exposed and in what output format. The goal is to have a simple way of displaying the complete MTD stack on a system in a human readable form instead of piecing details together from proc files and various UBI utilities. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'misc-utils/lsmtd.h')
-rw-r--r--misc-utils/lsmtd.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/misc-utils/lsmtd.h b/misc-utils/lsmtd.h
new file mode 100644
index 0000000..11d219e
--- /dev/null
+++ b/misc-utils/lsmtd.h
@@ -0,0 +1,67 @@
+#ifndef LSMTD_H
+#define LSMTD_H
+
+#define PROGRAM_NAME "lsmtd"
+#include "common.h"
+#include "xalloc.h"
+
+#include <libmtd.h>
+#include <libubi.h>
+
+#define COL_DEVNAME 1
+#define COL_DEVNUM 2
+#define COL_TYPE 3
+#define COL_NAME 4
+#define COL_SIZE 5
+#define COL_EBSIZE 6
+#define COL_EBCOUNT 7
+#define COL_MINIO 8
+#define COL_SUBSIZE 9
+#define COL_OOBSIZE 10
+#define COL_MAXEC 11
+#define COL_FREE 12
+#define COL_FREE_LEB 13
+#define COL_BAD_COUNT 14
+#define COL_BAD_RSVD 15
+#define COL_RO 16
+#define COL_BB 17
+#define COL_REGION 18
+#define COL_CORRUPTED 19
+
+#define COL_DT_STRING 1
+#define COL_DT_NUMBER 2
+#define COL_DT_SIZE 3
+#define COL_DT_BOOL 4
+
+struct ubi_node {
+ struct ubi_dev_info info;
+ struct ubi_vol_info *vol_info;
+};
+
+struct mtd_node {
+ struct mtd_dev_info info;
+ struct ubi_node *ubi;
+};
+
+struct column {
+ const char *name;
+ const char *desc;
+ int type;
+ int datatype;
+ size_t width;
+};
+
+extern struct ubi_node *ubi_dev;
+extern int num_ubi_devices;
+
+extern struct mtd_node *mtd_dev;
+extern int num_mtd_devices;
+
+extern struct column *sort_by;
+
+int scan_mtd(libmtd_t lib_mtd);
+int scan_ubi(libubi_t lib_ubi);
+void scan_free(void);
+
+#endif /* LSMTD_H */
+