mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-24 12:07:54 +00:00
btrfs-progs: slightly enhance btrfs_format_csum()
- Change it void The old one always return csum_size. - Use snprintf() Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
991a598f53
commit
773afad3e6
17
check/main.c
17
check/main.c
@ -7959,6 +7959,23 @@ static int record_unaligned_extent_rec(struct extent_record *rec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skip)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we repaired something and restarted we could potentially
|
||||||
|
* try to add this unaligned record multiple times, so check
|
||||||
|
* before we add a new one.
|
||||||
|
*/
|
||||||
|
list_for_each_entry(urec, &dest_root->unaligned_extent_recs, list) {
|
||||||
|
if (urec->objectid == dest_root->objectid &&
|
||||||
|
urec->owner == dback->owner &&
|
||||||
|
urec->bytenr == rec->start) {
|
||||||
|
skip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (skip)
|
if (skip)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -385,18 +385,20 @@ enum btrfs_csum_type parse_csum_type(const char *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int btrfs_format_csum(u16 csum_type, const u8 *data, char *output)
|
void btrfs_format_csum(u16 csum_type, const u8 *data, char *output)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int cur = 0;
|
||||||
const int csum_size = btrfs_csum_type_size(csum_type);
|
const int csum_size = btrfs_csum_type_size(csum_type);
|
||||||
|
|
||||||
sprintf(output, "0x");
|
output[0] = '\0';
|
||||||
|
snprintf(output, BTRFS_CSUM_STRING_LEN, "0x");
|
||||||
|
cur += strlen("0x");
|
||||||
for (i = 0; i < csum_size; i++) {
|
for (i = 0; i < csum_size; i++) {
|
||||||
output += 2;
|
snprintf(output + cur, BTRFS_CSUM_STRING_LEN - cur, "%02x",
|
||||||
sprintf(output, "%02x", data[i]);
|
data[i]);
|
||||||
|
cur += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return csum_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_device_info(int fd, u64 devid,
|
int get_device_info(int fd, u64 devid,
|
||||||
|
@ -46,7 +46,7 @@ enum btrfs_csum_type parse_csum_type(const char *s);
|
|||||||
|
|
||||||
/* 2 for "0x", 2 for each byte, plus nul */
|
/* 2 for "0x", 2 for each byte, plus nul */
|
||||||
#define BTRFS_CSUM_STRING_LEN (2 + 2 * BTRFS_CSUM_SIZE + 1)
|
#define BTRFS_CSUM_STRING_LEN (2 + 2 * BTRFS_CSUM_SIZE + 1)
|
||||||
int btrfs_format_csum(u16 csum_type, const u8 *data, char *output);
|
void btrfs_format_csum(u16 csum_type, const u8 *data, char *output);
|
||||||
u64 parse_size_from_string(const char *s);
|
u64 parse_size_from_string(const char *s);
|
||||||
u64 parse_qgroupid(const char *p);
|
u64 parse_qgroupid(const char *p);
|
||||||
u64 arg_strtou64(const char *str);
|
u64 arg_strtou64(const char *str);
|
||||||
|
Loading…
Reference in New Issue
Block a user