diff --git a/cmds/ptable.c b/cmds/ptable.c index a84d3842..af632081 100644 --- a/cmds/ptable.c +++ b/cmds/ptable.c @@ -43,6 +43,7 @@ static void cmd_ptableInfo(void) static int partPrint(ptable_t *p) { + const char *type; unsigned int i = p->count; unsigned int j = 0; @@ -52,11 +53,12 @@ static int partPrint(ptable_t *p) while (i-- != 0) { ptable_part_t *entry = &p->parts[i]; + type = ptable_typeName(entry->type); lib_printf( - PTABLE_ENTRY_FORMAT, - ++j, entry->name, entry->offset, entry->offset + entry->size, - entry->size / ptable_common.blksz, entry->size, - ptable_typeName(entry->type)); + PTABLE_ENTRY_FORMAT, + ++j, entry->name, entry->offset, entry->offset + entry->size, + entry->size / ptable_common.blksz, entry->size, + (type != NULL) ? type : "???"); } return 0; diff --git a/lib/ptable.c b/lib/ptable.c index 16f257d2..3fafabba 100644 --- a/lib/ptable.c +++ b/lib/ptable.c @@ -18,17 +18,6 @@ #define htole32(a) (a) -const char *ptable_typeName(int type) -{ - switch (type) { - case ptable_raw: return "raw"; - case ptable_jffs2: return "jffs2"; - case ptable_meterfs: return "meterfs"; - default: return "unknown"; - } -} - - static inline u32 ptable_crc32(const void *data, size_t len) { return ~lib_crc32(data, len, 0xffffffff); diff --git a/lib/ptable.h b/lib/ptable.h index 849a34f7..feaeaae1 100644 --- a/lib/ptable.h +++ b/lib/ptable.h @@ -14,6 +14,8 @@ #ifndef _LIB_PTABLE_H_ #define _LIB_PTABLE_H_ +#include + /* Changelog: * version 2: Add checksum and version fields */ @@ -30,17 +32,18 @@ * NOTE: data in partition table should be stored in little endian */ -/* clang-format off */ /* Partition table magic signature */ static const u8 ptable_magic[] = { 0xde, 0xad, 0xfc, 0xbe }; /* Supported partition types */ -enum { ptable_raw = 0x51, ptable_jffs2 = 0x72, ptable_meterfs = 0x75 }; - +/* clang-format off */ +enum { ptable_raw = 0x51, ptable_jffs2 = 0x72, ptable_meterfs = 0x75, ptable_futurefs = 0x78 }; /* clang-format on */ +static const u8 ptable_knownTypes[] = { ptable_raw, ptable_jffs2, ptable_meterfs, ptable_futurefs }; + typedef struct { u8 name[8]; /* Partition name */ @@ -61,6 +64,18 @@ typedef struct { } ptable_t; +static inline const char *ptable_typeName(int type) +{ + switch (type) { + case ptable_raw: return "raw"; + case ptable_jffs2: return "jffs2"; + case ptable_meterfs: return "meterfs"; + case ptable_futurefs: return "futurefs"; + default: return NULL; + } +}; + + /* Returns partition table size provided partition count */ static inline u32 ptable_size(u32 count) { @@ -68,9 +83,6 @@ static inline u32 ptable_size(u32 count) } -extern const char *ptable_typeName(int type); - - /* Converts partition table to host endianness and verifies it */ extern int ptable_deserialize(ptable_t *ptable, u32 memsz, u32 blksz);