#include "print-tree.h"
#include "transaction.h"
#include "version.h"
+#include "utils.h"
static int print_usage(void)
{
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;
(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);
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);
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");
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
#include "ctree.h"
#include "disk-io.h"
#include "print-tree.h"
+#include "utils.h"
static void print_dir_item_type(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);
}
#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);