btrfs-progs: define BTRFS_UUID_UNPARSE_SIZE for uuid unparse buf size
PATCH 1/1 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 <[email protected]>
--- btrfs-debug-tree.c | 5 +++-- btrfs-list.c | 2 +- btrfs-show-super.c | 2 +- cmds-check.c | 2 +- cmds-filesystem.c | 17 +++++++++-------- cmds-scrub.c | 6 +++--- cmds-subvolume.c | 2 +- print-tree.c | 9 +++++---- utils.h | 2 ++ 9 files changed, 26 insertions(+), 21 deletions(-)
btrfs-debug-tree.c +3 -2
@@ -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 );
btrfs-list.c +1 -1
@@ -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 );
btrfs-show-super.c +1 -1
@@ -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" );
cmds-check.c +1 -1
@@ -6128,7 +6128,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 ;
cmds-filesystem.c +9 -8
@@ -183,10 +183,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 ;
@@ -202,12 +202,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 ;
@@ -238,7 +238,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 ;
@@ -292,7 +292,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;uuid_unparse (fs_info->fsid, uuidbuf);
@@ -366,7 +366,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 ;
@@ -469,7 +470,7 @@ static int cmd_show(int argc, char **argv)char mp[BTRFS_PATH_NAME_MAX +1 ];char path[PATH_MAX ];__u8 fsid[BTRFS_FSID_SIZE ]; -char uuid_buf[37 ]; +char uuid_buf[BTRFS_UUID_UNPARSED_SIZE ];while (1 ) {int long_index;
cmds-scrub.c +3 -3
@@ -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 ;
cmds-subvolume.c +1 -1
@@ -823,7 +823,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;
print-tree.c +5 -4
@@ -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); }
utils.h +2 -0
@@ -37,6 +37,8 @@#define BTRFS_ARG_UUID 2#define BTRFS_ARG_BLKDEV 3 +#define BTRFS_UUID_UNPARSED_SIZE 37 +int make_btrfs (int fd,const char *device,const char *label,u64 blocks[6 ],u64 num_bytes,u32 nodesize,u32 leafsize,u32 sectorsize,u32 stripesize,u64 features);
Signature · 1 line
1.7.1