Add dump_metadata subcommand
Subsystems (2)
Eric Biggers
maintainercover Add dump_metadata subcommand
Add new subcommand 'fsverity dump_metadata' which wraps the proposed FS_IOC_READ_VERITY_METADATA ioctl
(https://lkml.kernel.org/linux-fscrypt/[email protected]/T/#u).
This subcommand is useful for xfstests and for debugging.
Eric Biggers (2):
Upgrade to latest fsverity_uapi.h
programs/fsverity: Add dump_metadata subcommand
Makefile | 1 + common/fsverity_uapi.h | 14 +++ programs/cmd_dump_metadata.c | 167 +++++++++++++++++++++++++++++++++++ programs/fsverity.c | 6 ++ programs/fsverity.h | 6 ++ 5 files changed, 194 insertions(+) create mode 100644 programs/cmd_dump_metadata.c
Signature · 8 lines
2.30.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Eric Biggers
maintainerRFC PATCH 1/2 Upgrade to latest fsverity_uapi.h
From: Eric Biggers <[email protected]>
Add the FS_IOC_READ_VERITY_METADATA ioctl.
--- common/fsverity_uapi.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
common/fsverity_uapi.h +14 -0
@@ -85,7 +85,21 @@ struct fsverity_formatted_digest { __u8 digest[]; }; +#define FS_VERITY_METADATA_TYPE_MERKLE_TREE 1 +#define FS_VERITY_METADATA_TYPE_DESCRIPTOR 2 +#define FS_VERITY_METADATA_TYPE_SIGNATURE 3 + +struct fsverity_read_metadata_arg { +__u64 metadata_type; +__u64 offset; +__u64 length; +__u64 buf_ptr; +__u64 __reserved; +}; +#define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg)#define FS_IOC_MEASURE_VERITY _IOWR('f', 134, struct fsverity_digest) +#define FS_IOC_READ_VERITY_METADATA \ + _IOWR('f', 135, struct fsverity_read_metadata_arg)#endif /* _UAPI_LINUX_FSVERITY_H */
Signature · 8 lines
2.30.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Eric Biggers
maintainerRFC PATCH 2/2 programs/fsverity: Add dump_metadata subcommand
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add a 'fsverity dump_metadata' subcommand which calls FS_IOC_READ_VERITY_METADATA on a file and prints the returned metadata to stdout. There are three subsubcommands, one for each type of metadata that can be read using the ioctl:
fsverity dump_metadata merkle_tree FILE
fsverity dump_metadata descriptor FILE
fsverity dump_metadata signature FILE
By default the whole metadata item is dumped. --length and --offset can be specified to dump only a particular range of the item.
This subcommand will be used by xfstests to test the FS_IOC_READ_VERITY_METADATA ioctl.
--- Makefile | 1 + programs/cmd_dump_metadata.c | 167 +++++++++++++++++++++++++++++++++++ programs/fsverity.c | 6 ++ programs/fsverity.h | 6 ++ 4 files changed, 180 insertions(+) create mode 100644 programs/cmd_dump_metadata.c
Makefile +1 -0
@@ -160,6 +160,7 @@ FSVERITY_PROG_OBJ := $(PROG_COMMON_OBJ) \ programs/fsverity.o ifneq ($(MINGW),1) FSVERITY_PROG_OBJ += \ + programs/cmd_dump_metadata.o \ programs/cmd_enable.o \ programs/cmd_measure.o endif
programs/cmd_dump_metadata.c new file +167 -0
167 lines not on this page · raw message
programs/fsverity.c +6 -0
@@ -29,6 +29,12 @@ static const struct fsverity_command {" [--hash-alg=HASH_ALG] [--block-size=BLOCK_SIZE] [--salt=SALT]\n" " [--compact] [--for-builtin-sig]\n" #ifndef _WIN32 + }, { + .name = "dump_metadata", + .func = fsverity_cmd_dump_metadata, + .short_desc = "Dump the fs-verity metadata of the given file", + .usage_str = +" fsverity dump_metadata TYPE FILE [--offset=OFFSET] [--length=LENGTH]\n" }, { .name = "enable", .func = fsverity_cmd_enable,
programs/fsverity.h +6 -0
@@ -27,6 +27,8 @@ enum {OPT_FOR_BUILTIN_SIG ,OPT_HASH_ALG ,OPT_KEY , +OPT_LENGTH , +OPT_OFFSET ,OPT_SALT , OPT_SIGNATURE, };
@@ -37,6 +39,10 @@ struct fsverity_command;int fsverity_cmd_digest (const struct fsverity_command *cmd,int argc,char *argv[]); +/* cmd_dump_metadata.c */ +int fsverity_cmd_dump_metadata (const struct fsverity_command *cmd, +int argc,char *argv[]); +/* cmd_enable.c */ int fsverity_cmd_enable (const struct fsverity_command *cmd,int argc,char *argv[]);
Signature · 8 lines
2.30.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel