btrfs-progs: move parse_csum_type to utils

This will be used by convert.

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2019-11-05 19:34:07 +01:00
parent 78a3831d46
commit 65efb419a2
3 changed files with 21 additions and 20 deletions

View File

@ -762,6 +762,26 @@ err:
exit(-1);
}
enum btrfs_csum_type parse_csum_type(const char *s)
{
if (strcasecmp(s, "crc32c") == 0) {
return BTRFS_CSUM_TYPE_CRC32;
} else if (strcasecmp(s, "xxhash64") == 0 ||
strcasecmp(s, "xxhash") == 0) {
return BTRFS_CSUM_TYPE_XXHASH;
} else if (strcasecmp(s, "sha256") == 0) {
return BTRFS_CSUM_TYPE_SHA256;
} else if (strcasecmp(s, "blake2b") == 0 ||
strcasecmp(s, "blake2") == 0) {
return BTRFS_CSUM_TYPE_BLAKE2;
} else {
error("unknown csum type %s", s);
exit(1);
}
/* not reached */
return 0;
}
int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags)
{
int ret;

View File

@ -65,6 +65,7 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_bytes, unsigned unit_mo
#define pretty_size(size) pretty_size_mode(size, UNITS_DEFAULT)
const char *pretty_size_mode(u64 size, unsigned mode);
enum btrfs_csum_type parse_csum_type(const char *s);
u64 parse_size(const char *s);
u64 parse_qgroupid(const char *p);
u64 arg_strtou64(const char *str);

View File

@ -388,26 +388,6 @@ static u64 parse_profile(const char *s)
return 0;
}
static enum btrfs_csum_type parse_csum_type(const char *s)
{
if (strcasecmp(s, "crc32c") == 0) {
return BTRFS_CSUM_TYPE_CRC32;
} else if (strcasecmp(s, "xxhash64") == 0 ||
strcasecmp(s, "xxhash") == 0) {
return BTRFS_CSUM_TYPE_XXHASH;
} else if (strcasecmp(s, "sha256") == 0) {
return BTRFS_CSUM_TYPE_SHA256;
} else if (strcasecmp(s, "blake2b") == 0 ||
strcasecmp(s, "blake2") == 0) {
return BTRFS_CSUM_TYPE_BLAKE2;
} else {
error("unknown csum type %s", s);
exit(1);
}
/* not reached */
return 0;
}
static char *parse_label(const char *input)
{
int len = strlen(input);