From c26ce774a7209012c0505ee841d54898c6665e20 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 15 Mar 2017 12:12:12 +0100 Subject: 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 --- misc-utils/lsmtd.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 misc-utils/lsmtd.h (limited to 'misc-utils/lsmtd.h') 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 +#include + +#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 */ + -- cgit v1.2.3