mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
btrfs-progs: define BTRFS_UUID_UNPARSE_SIZE for uuid unparse buf size
we use 37 as the allocation size to hold the uuid_unparse, here it defines BTRFS_UUID_UNPARSE_SIZE for the same. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
457b1286dd
commit
1ecefced86
@ -27,6 +27,7 @@
|
||||
#include "print-tree.h"
|
||||
#include "transaction.h"
|
||||
#include "version.h"
|
||||
#include "utils.h"
|
||||
|
||||
static int print_usage(void)
|
||||
{
|
||||
@ -125,7 +126,7 @@ int main(int ac, char **av)
|
||||
struct extent_buffer *leaf;
|
||||
struct btrfs_disk_key disk_key;
|
||||
struct btrfs_key found_key;
|
||||
char uuidbuf[37];
|
||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
int ret;
|
||||
int slot;
|
||||
int extent_only = 0;
|
||||
@ -392,7 +393,7 @@ no_node:
|
||||
(unsigned long long)btrfs_super_total_bytes(info->super_copy));
|
||||
printf("bytes used %llu\n",
|
||||
(unsigned long long)btrfs_super_bytes_used(info->super_copy));
|
||||
uuidbuf[36] = '\0';
|
||||
uuidbuf[BTRFS_UUID_UNPARSED_SIZE - 1] = '\0';
|
||||
uuid_unparse(info->super_copy->fsid, uuidbuf);
|
||||
printf("uuid %s\n", uuidbuf);
|
||||
printf("%s\n", BTRFS_BUILD_VERSION);
|
||||
|
@ -1331,7 +1331,7 @@ static void print_subvolume_column(struct root_info *subv,
|
||||
enum btrfs_list_column_enum column)
|
||||
{
|
||||
char tstr[256];
|
||||
char uuidparse[37];
|
||||
char uuidparse[BTRFS_UUID_UNPARSED_SIZE];
|
||||
|
||||
BUG_ON(column >= BTRFS_LIST_ALL || column < 0);
|
||||
|
||||
|
@ -165,7 +165,7 @@ static int check_csum_sblock(void *sb, int csum_size)
|
||||
static void dump_superblock(struct btrfs_super_block *sb)
|
||||
{
|
||||
int i;
|
||||
char *s, buf[36+1];
|
||||
char *s, buf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
u8 *p;
|
||||
|
||||
printf("csum\t\t\t0x");
|
||||
|
@ -6123,7 +6123,7 @@ int cmd_check(int argc, char **argv)
|
||||
struct btrfs_root *root;
|
||||
struct btrfs_fs_info *info;
|
||||
u64 bytenr = 0;
|
||||
char uuidbuf[37];
|
||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
int ret;
|
||||
int num;
|
||||
int option_index = 0;
|
||||
|
@ -251,10 +251,10 @@ static int cmd_df(int argc, char **argv)
|
||||
static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label,
|
||||
char *search)
|
||||
{
|
||||
char uuidbuf[37];
|
||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
int search_len = strlen(search);
|
||||
|
||||
search_len = min(search_len, 37);
|
||||
search_len = min(search_len, BTRFS_UUID_UNPARSED_SIZE);
|
||||
uuid_unparse(fsid, uuidbuf);
|
||||
if (!strncmp(uuidbuf, search, search_len))
|
||||
return 1;
|
||||
@ -270,12 +270,12 @@ static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label,
|
||||
|
||||
static int uuid_search(struct btrfs_fs_devices *fs_devices, char *search)
|
||||
{
|
||||
char uuidbuf[37];
|
||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
struct list_head *cur;
|
||||
struct btrfs_device *device;
|
||||
int search_len = strlen(search);
|
||||
|
||||
search_len = min(search_len, 37);
|
||||
search_len = min(search_len, BTRFS_UUID_UNPARSED_SIZE);
|
||||
uuid_unparse(fs_devices->fsid, uuidbuf);
|
||||
if (!strncmp(uuidbuf, search, search_len))
|
||||
return 1;
|
||||
@ -306,7 +306,7 @@ static int cmp_device_id(void *priv, struct list_head *a,
|
||||
|
||||
static void print_one_uuid(struct btrfs_fs_devices *fs_devices)
|
||||
{
|
||||
char uuidbuf[37];
|
||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
struct list_head *cur;
|
||||
struct btrfs_device *device;
|
||||
u64 devs_found = 0;
|
||||
@ -363,7 +363,7 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
|
||||
char *label, char *path)
|
||||
{
|
||||
int i;
|
||||
char uuidbuf[37];
|
||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
struct btrfs_ioctl_dev_info_args *tmp_dev_info;
|
||||
int ret;
|
||||
|
||||
@ -421,7 +421,8 @@ static int check_arg_type(char *input)
|
||||
return BTRFS_ARG_UNKNOWN;
|
||||
}
|
||||
|
||||
if (strlen(input) == 36 && !uuid_parse(input, out))
|
||||
if (strlen(input) == (BTRFS_UUID_UNPARSED_SIZE - 1) &&
|
||||
!uuid_parse(input, out))
|
||||
return BTRFS_ARG_UUID;
|
||||
|
||||
return BTRFS_ARG_UNKNOWN;
|
||||
|
@ -867,7 +867,7 @@ static void *scrub_progress_cycle(void *ctx)
|
||||
int perr = 0; /* positive / pthread error returns */
|
||||
int old;
|
||||
int i;
|
||||
char fsid[37];
|
||||
char fsid[BTRFS_UUID_UNPARSED_SIZE];
|
||||
struct scrub_progress *sp;
|
||||
struct scrub_progress *sp_last;
|
||||
struct scrub_progress *sp_shared;
|
||||
@ -1089,7 +1089,7 @@ static int scrub_start(int argc, char **argv, int resume)
|
||||
struct scrub_file_record **past_scrubs = NULL;
|
||||
struct scrub_file_record *last_scrub = NULL;
|
||||
char *datafile = strdup(SCRUB_DATA_FILE);
|
||||
char fsid[37];
|
||||
char fsid[BTRFS_UUID_UNPARSED_SIZE];
|
||||
char sock_path[BTRFS_PATH_NAME_MAX + 1] = "";
|
||||
struct scrub_progress_cycle spc;
|
||||
pthread_mutex_t spc_write_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -1615,7 +1615,7 @@ static int cmd_scrub_status(int argc, char **argv)
|
||||
int print_raw = 0;
|
||||
int do_stats_per_dev = 0;
|
||||
int c;
|
||||
char fsid[37];
|
||||
char fsid[BTRFS_UUID_UNPARSED_SIZE];
|
||||
int fdres = -1;
|
||||
int err = 0;
|
||||
DIR *dirstream = NULL;
|
||||
|
@ -826,7 +826,7 @@ static int cmd_subvol_show(int argc, char **argv)
|
||||
struct root_info get_ri;
|
||||
struct btrfs_list_filter_set *filter_set;
|
||||
char tstr[256];
|
||||
char uuidparse[37];
|
||||
char uuidparse[BTRFS_UUID_UNPARSED_SIZE];
|
||||
char *fullpath = NULL, *svpath = NULL, *mnt = NULL;
|
||||
char raw_prefix[] = "\t\t\t\t";
|
||||
u64 sv_id, mntid;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ctree.h"
|
||||
#include "disk-io.h"
|
||||
#include "print-tree.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
static void print_dir_item_type(struct extent_buffer *eb,
|
||||
@ -187,21 +188,21 @@ static void print_dev_item(struct extent_buffer *eb,
|
||||
|
||||
static void print_uuids(struct extent_buffer *eb)
|
||||
{
|
||||
char fs_uuid[37];
|
||||
char chunk_uuid[37];
|
||||
char fs_uuid[BTRFS_UUID_UNPARSED_SIZE];
|
||||
char chunk_uuid[BTRFS_UUID_UNPARSED_SIZE];
|
||||
u8 disk_uuid[BTRFS_UUID_SIZE];
|
||||
|
||||
read_extent_buffer(eb, disk_uuid, btrfs_header_fsid(),
|
||||
BTRFS_FSID_SIZE);
|
||||
|
||||
fs_uuid[36] = '\0';
|
||||
fs_uuid[BTRFS_UUID_UNPARSED_SIZE - 1] = '\0';
|
||||
uuid_unparse(disk_uuid, fs_uuid);
|
||||
|
||||
read_extent_buffer(eb, disk_uuid,
|
||||
(unsigned long)btrfs_header_chunk_tree_uuid(eb),
|
||||
BTRFS_UUID_SIZE);
|
||||
|
||||
chunk_uuid[36] = '\0';
|
||||
chunk_uuid[BTRFS_UUID_UNPARSED_SIZE - 1] = '\0';
|
||||
uuid_unparse(disk_uuid, chunk_uuid);
|
||||
printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user