btrfs-progs: common: update include lists, part 1

The tool IWYU (include what you use) suggests to remove and add some
includes. This is only partial to avoid accidental build breakage, the
includes are entangled and will have to be cleaned in the future again.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-09-15 13:59:39 +02:00
parent 40c4ba74ec
commit b5aac254c7
33 changed files with 99 additions and 46 deletions

View File

@ -27,6 +27,7 @@
#include "common/string-utils.h"
#include "common/help.h"
#include "common/box.h"
#include "common/messages.h"
#include "cmds/commands.h"
static const char * const btrfs_cmd_group_usage[] = {
@ -108,8 +109,7 @@ static void check_output_format(const struct cmd_struct *cmd)
return;
if (!(cmd->flags & bconf.output_format & CMD_FORMAT_MASK)) {
fprintf(stderr,
"ERROR: output format %s is unsupported for this command\n",
error("output format %s is unsupported for this command",
output_format_name(bconf.output_format));
exit(1);
}

View File

@ -961,7 +961,7 @@ loop:
ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
if (ret < 0) {
fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret);
error("couldn't search slot: %d", ret);
goto out;
}
@ -1006,7 +1006,7 @@ loop:
count = alloc_count(&disk_key, leaf, item);
if (!count) {
ret = ENOMEM;
fprintf(stderr, "ERROR: out of memory\n");
error("out of memory");
goto out;
}
@ -1176,7 +1176,7 @@ static int scan_extents(struct btrfs_fs_info *info,
ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
if (ret < 0) {
fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret);
error("couldn't search slot: %d", ret);
goto out;
}
path.reada = READA_BACK;
@ -1246,8 +1246,7 @@ static int scan_extents(struct btrfs_fs_info *info,
ret = btrfs_next_leaf(root, &path);
if (ret != 0) {
if (ret < 0) {
fprintf(stderr,
"ERROR: Next leaf failed: %d\n", ret);
error("next leaf failed: %d", ret);
goto out;
}
break;
@ -1415,14 +1414,13 @@ int qgroup_verify_all(struct btrfs_fs_info *info)
tree_blocks = ulist_alloc(0);
if (!tree_blocks) {
fprintf(stderr,
"ERROR: Out of memory while allocating ulist.\n");
error("out of memory while allocating ulist");
return ENOMEM;
}
ret = load_quota_info(info);
if (ret) {
fprintf(stderr, "ERROR: Loading qgroups from disk: %d\n", ret);
error("loading qgroups from disk: %d", ret);
goto out;
}
@ -1442,15 +1440,14 @@ int qgroup_verify_all(struct btrfs_fs_info *info)
ret = scan_extents(info, bg->start,
bg->start + bg->length - 1);
if (ret) {
fprintf(stderr, "ERROR: while scanning extent tree: %d\n",
ret);
error("while scanning extent tree: %d", ret);
goto out;
}
}
ret = map_implied_refs(info);
if (ret) {
fprintf(stderr, "ERROR: while mapping refs: %d\n", ret);
error("while mapping refs: %d", ret);
goto out;
}

View File

@ -20,6 +20,7 @@
#include "kerncompat.h"
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <stdlib.h>
#include <stdio.h>
@ -28,6 +29,8 @@
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
#include <limits.h>
#include <stdbool.h>
#include <blkid/blkid.h>
#include <uuid/uuid.h>
#ifdef HAVE_LIBUDEV
@ -35,6 +38,7 @@
#include <libudev.h>
#endif
#include "kernel-lib/overflow.h"
#include "kernel-lib/list.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/volumes.h"
#include "kernel-shared/disk-io.h"

View File

@ -36,8 +36,6 @@
struct btrfs_root;
struct btrfs_trans_handle;
struct seen_fsid;
struct DIR;
struct seen_fsid {
u8 fsid[BTRFS_FSID_SIZE];

View File

@ -15,9 +15,12 @@
*/
#include <sys/ioctl.h>
#include <sys/statfs.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/limits.h>
#ifdef BTRFS_ZONED
#include <linux/blkzoned.h>
#endif
#include <linux/fs.h>
#include <limits.h>
#include <stdio.h>
@ -26,9 +29,11 @@
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <blkid/blkid.h>
#include "kernel-lib/sizes.h"
#include "kernel-shared/disk-io.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/zoned.h"
#include "common/device-utils.h"
#include "common/path-utils.h"

View File

@ -19,6 +19,7 @@
#include "kerncompat.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "common/extent-cache.h"
#include "common/rbtree-utils.h"

View File

@ -21,6 +21,7 @@
#include "kerncompat.h"
#include "kernel-lib/rbtree.h"
#include "kernel-lib/rbtree_types.h"
struct cache_tree {
struct rb_root root;

View File

@ -18,6 +18,8 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "kernel-shared/ctree.h"
#include "kernel-shared/disk-io.h"
#include "kernel-shared/transaction.h"
@ -25,7 +27,6 @@
#include "common/messages.h"
#include "common/open-utils.h"
#include "common/path-utils.h"
#include "ioctl.h"
/*
* For a given:

View File

@ -17,6 +17,8 @@
#ifndef __BTRFS_FILESYSTEM_UTILS_H__
#define __BTRFS_FILESYSTEM_UTILS_H__
#include "kerncompat.h"
int lookup_path_rootid(int fd, u64 *rootid);
int get_label(const char *btrfs_dev, char *label);
int set_label(const char *btrfs_dev, const char *label);

View File

@ -16,6 +16,11 @@
#include "kerncompat.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <uuid/uuid.h>
#include "common/defs.h"
#include "common/format-output.h"

View File

@ -17,6 +17,8 @@
#ifndef __BTRFS_FORMAT_OUTPUT_H__
#define __BTRFS_FORMAT_OUTPUT_H__
#include <stddef.h>
struct rowspec {
/* Identifier for the row */
const char *key;

View File

@ -19,10 +19,17 @@
#include <sys/ioctl.h>
#include <linux/version.h>
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "kernel-lib/sizes.h"
#include "kernel-shared/ctree.h"
#include "common/fsfeatures.h"
#include "common/string-utils.h"
#include "common/utils.h"
#include "common/messages.h"
#include "ioctl.h"
/*
* Insert a root item for temporary tree root

View File

@ -18,6 +18,8 @@
#define __BTRFS_FSFEATURES_H__
#include "kerncompat.h"
#include <stdio.h>
#include "kernel-lib/sizes.h"
#define BTRFS_MKFS_DEFAULT_NODE_SIZE SZ_16K
#define BTRFS_MKFS_DEFAULT_FEATURES \

View File

@ -14,12 +14,11 @@
* Boston, MA 021110-1307, USA.
*/
#include "kerncompat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <getopt.h>
#include "common/utils.h"
#include "common/help.h"
#include "common/string-utils.h"
#include "cmds/commands.h"

View File

@ -17,6 +17,12 @@
#ifndef __BTRFS_HELP_H__
#define __BTRFS_HELP_H__
#include <limits.h>
#include <stdbool.h>
struct cmd_struct;
struct cmd_group;
/* User defined long options first option */
#define GETOPT_VAL_FIRST 256
@ -68,9 +74,6 @@
#define HELPINFO_INSERT_VERBOSE "-v|--verbose increase output verbosity"
#define HELPINFO_INSERT_QUIET "-q|--quiet print only errors"
struct cmd_struct;
struct cmd_group;
/*
* Descriptor of output format
*/

View File

@ -21,6 +21,11 @@
#include <unistd.h>
#include <fcntl.h>
#include <mntent.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "kernel-lib/list.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/volumes.h"
#include "kernel-shared/disk-io.h"

View File

@ -17,6 +17,7 @@
#ifndef __OPEN_UTILS_H__
#define __OPEN_UTILS_H__
#include <stddef.h>
#include <dirent.h>
struct btrfs_fs_devices;

View File

@ -15,11 +15,14 @@
*/
#include "kerncompat.h"
#include <sys/stat.h>
#include <limits.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "libbtrfsutil/btrfsutil.h"
#include "kernel-shared/volumes.h"
#include "common/parse-utils.h"

View File

@ -15,7 +15,6 @@
*/
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/ioctl.h>
#include <linux/major.h>
#include <linux/kdev_t.h>
@ -30,6 +29,7 @@
#include <errno.h>
#include <ctype.h>
#include <libgen.h>
#include <limits.h>
#include "common/path-utils.h"
/*

View File

@ -16,6 +16,10 @@
* Boston, MA 021110-1307, USA.
*/
#include <errno.h>
#include <stddef.h>
#include "kernel-lib/rbtree.h"
#include "kernel-lib/rbtree_types.h"
#include "common/rbtree-utils.h"
int rb_insert(struct rb_root *root, struct rb_node *node,

View File

@ -16,11 +16,18 @@
* Boston, MA 021110-1307, USA.
*/
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel-lib/list.h"
#include "kernel-lib/rbtree.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/transaction.h"
#include "kernel-shared/extent_io.h"
#include "kernel-shared/disk-io.h"
#include "common/extent-cache.h"
#include "common/utils.h"
#include "common/repair.h"
int repair = 0;

View File

@ -19,7 +19,12 @@
#ifndef __BTRFS_REPAIR_H__
#define __BTRFS_REPAIR_H__
#include "kerncompat.h"
#include "kernel-shared/ctree.h"
#include "common/extent-cache.h"
struct btrfs_trans_handle;
struct extent_io_tree;
extern int repair; /* repair mode */

View File

@ -17,11 +17,16 @@
*/
#include <unistd.h>
#include <uuid/uuid.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "kernel-shared/ctree.h"
#include "kernel-shared/send.h"
#include "crypto/crc32c.h"
#include "common/send-stream.h"
#include "common/utils.h"
#include "common/messages.h"
#include "ioctl.h"
struct btrfs_send_attribute {
u16 tlv_type;

View File

@ -21,7 +21,9 @@
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
#include <uuid/uuid.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel-shared/ctree.h"
#include "common/send-utils.h"
#include "common/messages.h"

View File

@ -20,7 +20,7 @@
#define __BTRFS_SEND_UTILS_H__
#include "kerncompat.h"
#include "kernel-lib/rbtree.h"
#include <stddef.h>
#include "kernel-shared/ctree.h"
enum subvol_search_type {

View File

@ -17,6 +17,8 @@
#ifndef __STRING_TABLE_H__
#define __STRING_TABLE_H__
#include <stdarg.h>
struct string_table {
int ncols;
int nrows;

View File

@ -17,6 +17,8 @@
#ifndef __BTRFS_STRING_UTILS_H__
#define __BTRFS_STRING_UTILS_H__
#include "kerncompat.h"
int string_is_numerical(const char *str);
int prefixcmp(const char *str, const char *prefix);
u64 arg_strtou64(const char *str);

View File

@ -16,7 +16,6 @@
#include <sys/timerfd.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

View File

@ -18,6 +18,7 @@
#define __TASK_UTILS_H__
#include "kerncompat.h"
#include <time.h>
#include <pthread.h>
struct periodic_info {

View File

@ -14,6 +14,8 @@
* Boston, MA 021110-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include "common/units.h"
/*

View File

@ -18,6 +18,7 @@
#define __BTRFS_UNITS_H__
#include "kerncompat.h"
#include <stddef.h>
/*
* Output modes of size

View File

@ -19,13 +19,7 @@
#include "kerncompat.h"
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/sysinfo.h>
#include <sys/vfs.h>
#include <sys/statfs.h>
#include <sys/stat.h>
#include <linux/magic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -34,20 +28,12 @@
#include <mntent.h>
#include <ctype.h>
#include <limits.h>
#include <getopt.h>
#include <blkid/blkid.h>
#include <uuid/uuid.h>
#include "libbtrfsutil/btrfsutil.h"
#include "kernel-lib/radix-tree.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/disk-io.h"
#include "kernel-shared/volumes.h"
#include "kernel-shared/transaction.h"
#include "crypto/crc32c.h"
#include "common/utils.h"
#include "common/path-utils.h"
#include "common/device-scan.h"
#include "common/parse-utils.h"
#include "common/open-utils.h"
#include "cmds/commands.h"
#include "mkfs/common.h"

View File

@ -19,9 +19,10 @@
#ifndef __BTRFS_UTILS_H__
#define __BTRFS_UTILS_H__
#include <sys/stat.h>
#include <dirent.h>
#include "kerncompat.h"
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include "kernel-lib/sizes.h"
#include "kernel-shared/ctree.h"
#include "common/defs.h"