diff --git a/btrfs-sb-mod.c b/btrfs-sb-mod.c index 6dde98b2..f56388bd 100644 --- a/btrfs-sb-mod.c +++ b/btrfs-sb-mod.c @@ -215,6 +215,18 @@ static bool op_is_write(enum field_op op) return op != OP_GET; } +static const char * const type_to_string(enum field_type type) +{ + switch (type) { + case TYPE_U8: return "u8"; + case TYPE_U16: return "u16"; + case TYPE_U32: return "u32"; + case TYPE_U64: return "u64"; + case TYPE_UNKNOWN: + } + return "UNKNOWN"; +} + static void mod_field_by_name(struct btrfs_super_block *sb, int set, const char *name, u64 *val) { @@ -329,10 +341,15 @@ int main(int argc, char **argv) memset(spec, 0, sizeof(spec)); if (argc <= 2) { - printf("Usage: %s image [fieldspec...]\n", argv[0]); - printf("Where fileldspec is: member op\n"); - printf(" member: name of the superblock member\n"); - printf(" op: single character optionally followed by a value\n"); + printf("Usage: %s [options] image [fieldspec...]\n", argv[0]); + printf("\n"); + printf("Modify or read a a member of the primary superblock on a given image (file or block device),\n"); + printf("checksum is recalculated after any modification (ie. it is not when just reading the values).\n"); + printf("Use 'btrfs inspect dump-super image' to read the whole superblock\n"); + printf("\n"); + printf("fileldspec is a sequence of pairs 'member op':\n"); + printf(" member: name of the superblock member, listed below\n"); + printf(" op: single character optionally followed by a value (eg. =0x42)\n"); printf(" . read the member value (no value)\n"); printf(" ? read the member value (no value)\n"); printf(" = set member to the exact value (value required)\n"); @@ -340,6 +357,15 @@ int main(int argc, char **argv) printf(" - subtract this value from member (value required)\n"); printf(" ^ xor member with this value (value required)\n"); printf(" @ byteswap of the member (no value)\n"); + printf("\n"); + printf(" member (type)\n"); + + for (i = 0; i < ARRAY_SIZE(known_fields); i++) { + const int width = 24; + + printf(" %-*s %s\n", width, known_fields[i].name, + type_to_string(known_fields[i].type)); + } exit(1); } fd = open(argv[1], O_RDWR | O_EXCL);