On 25.07.19 г. 12:33 ч., Johannes Thumshirn wrote:
> Add an option to mkfs to specify which checksum algorithm will be used for
> the filesystem.
>
> XXX this patch should go last in the series.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@xxxxxxx>
<snip>
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -346,6 +346,7 @@ static void print_usage(int ret)
> printf("\t--shrink (with --rootdir) shrink the filled filesystem to minimal size\n");
> printf("\t-K|--nodiscard do not perform whole device TRIM\n");
> printf("\t-f|--force force overwrite of existing filesystem\n");
> + printf("\t-C|--checksum checksum algorithm to use (default: crc32c)\n");
> printf(" general:\n");
> printf("\t-q|--quiet no messages except errors\n");
> printf("\t-V|--version print the mkfs.btrfs version and exit\n");
> @@ -380,6 +381,18 @@ static u64 parse_profile(const char *s)
> return 0;
> }
>
> +static u16 parse_csum_type(const char *s)
> +{
> + if (strcasecmp(s, "crc32c") == 0) {
> + return BTRFS_CSUM_TYPE_CRC32;
> + } else {
> + error("unknown csum type %s", s);
> + exit(1);
> + }
> + /* not reached */
> + return 0;
> +}
How hard would it be making this function return 'enum btrfs_csum_type'
and all further references to the checksum type be done through this
enum type? Functionally this won't bring any differences but will make
the code very explicit. Perhaps you'd have to also add a value for
invalid checksum ?
<snip>