+
+int pretty_size_snprintf(u64 size, char *str, size_t str_bytes, unsigned unit_mode);
+#define pretty_size(size) pretty_size_mode(size, UNITS_DEFAULT)
+#define pretty_size_mode(size, mode) \
+ ({ \
+ static __thread char _str[32]; \
+ (void)pretty_size_snprintf((size), _str, sizeof(_str), (mode)); \
+ _str; \
+ })
+
+int get_mountpt(char *dev, char *mntpt, size_t size);
+int btrfs_scan_block_devices(int run_ioctl);
+u64 parse_size(char *s);
+u64 arg_strtou64(const char *str);
+int open_file_or_dir(const char *fname, DIR **dirstream);
+int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags);
+void close_file_or_dir(int fd, DIR *dirstream);
+int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args,
+ struct btrfs_ioctl_dev_info_args **di_ret);
+int get_label(const char *btrfs_dev, char *label);
+int set_label(const char *btrfs_dev, const char *label);
+
+char *__strncpy__null(char *dest, const char *src, size_t n);
+int is_block_device(const char *file);
+int is_mount_point(const char *file);
+int open_path_or_dev_mnt(const char *path, DIR **dirstream);
+u64 btrfs_device_size(int fd, struct stat *st);
+/* Helper to always get proper size of the destination string */
+#define strncpy_null(dest, src) __strncpy__null(dest, src, sizeof(dest))
+int test_dev_for_mkfs(char *file, int force_overwrite, char *estr);
+int get_label_mounted(const char *mount_path, char *labelp);
+int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
+ u64 dev_cnt, int mixed, char *estr);
+int is_vol_small(char *file);
+int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
+ int verify);
+int ask_user(char *question);
+int lookup_ino_rootid(int fd, u64 *rootid);
+int btrfs_scan_lblkid(int update_kernel);
+int get_btrfs_mount(const char *dev, char *mp, size_t mp_size);
+int find_mount_root(const char *path, char **mount_root);
+int get_device_info(int fd, u64 devid,
+ struct btrfs_ioctl_dev_info_args *di_args);
+int test_uuid_unique(char *fs_uuid);
+
+int test_minimum_size(const char *file, u32 leafsize);
+int test_issubvolname(const char *name);
+int test_isdir(const char *path);
+
+/*
+ * Btrfs minimum size calculation is complicated, it should include at least:
+ * 1. system group size
+ * 2. minimum global block reserve
+ * 3. metadata used at mkfs
+ * 4. space reservation to create uuid for first mount.
+ * Also, raid factor should also be taken into consideration.
+ * To avoid the overkill calculation, (system group + global block rsv) * 2
+ * for *EACH* device should be good enough.
+ */
+static inline u64 btrfs_min_global_blk_rsv_size(u32 leafsize)
+{
+ return leafsize << 10;
+}
+static inline u64 btrfs_min_dev_size(u32 leafsize)
+{
+ return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
+ btrfs_min_global_blk_rsv_size(leafsize));
+}
+
+int find_next_key(struct btrfs_path *path, struct btrfs_key *key);
+