From c3b0e6970b2f0ba6958d5653a4b4ce3599e24796 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 1 Jul 2019 21:29:43 +0200 Subject: [PATCH] btrfs-progs: path-utils: rename is_block_device Add the path_ prefix and update all callers. Signed-off-by: David Sterba --- cmds/device.c | 6 +++--- cmds/replace.c | 2 +- common/path-utils.c | 10 ++++++---- common/path-utils.h | 2 +- common/utils.c | 8 ++++---- mkfs/main.c | 4 ++-- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/cmds/device.c b/cmds/device.c index 5c96a1e6..54b0309a 100644 --- a/cmds/device.c +++ b/cmds/device.c @@ -174,7 +174,7 @@ static int _cmd_device_remove(const struct cmd_struct *cmd, argv2.devid = arg_strtou64(argv[i]); argv2.flags = BTRFS_DEVICE_SPEC_BY_ID; is_devid = 1; - } else if (is_block_device(argv[i]) == 1 || + } else if (path_is_block_device(argv[i]) == 1 || strcmp(argv[i], "missing") == 0) { strncpy_null(argv2.name, argv[i]); } else { @@ -365,7 +365,7 @@ static int cmd_device_scan(const struct cmd_struct *cmd, int argc, char **argv) for( i = devstart ; i < argc ; i++ ){ char *path; - if (is_block_device(argv[i]) != 1) { + if (path_is_block_device(argv[i]) != 1) { error("not a block device: %s", argv[i]); ret = 1; goto out; @@ -430,7 +430,7 @@ static int cmd_device_ready(const struct cmd_struct *cmd, int argc, char **argv) goto out; } - if (is_block_device(path) != 1) { + if (path_is_block_device(path) != 1) { error("not a block device: %s", path); ret = 1; goto out; diff --git a/cmds/replace.c b/cmds/replace.c index 017a22aa..2f59af45 100644 --- a/cmds/replace.c +++ b/cmds/replace.c @@ -230,7 +230,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd, srcdev, path); goto leave_with_error; } - } else if (is_block_device(srcdev) > 0) { + } else if (path_is_block_device(srcdev) > 0) { strncpy((char *)start_args.start.srcdev_name, srcdev, BTRFS_DEVICE_PATH_NAME_MAX); start_args.start.srcdevid = 0; diff --git a/common/path-utils.c b/common/path-utils.c index 6a0053df..62492610 100644 --- a/common/path-utils.c +++ b/common/path-utils.c @@ -32,11 +32,13 @@ #include "common/path-utils.h" /* - * checks if a path is a block device node - * Returns negative errno on failure, otherwise - * returns 1 for blockdev, 0 for not-blockdev + * Check if @path is a block device node + * Returns: + * 1 - path is a block device + * 0 - not a block device + * <0 - negative errno */ -int is_block_device(const char *path) +int path_is_block_device(const char *path) { struct stat statbuf; diff --git a/common/path-utils.h b/common/path-utils.h index c78714dd..39c32ca4 100644 --- a/common/path-utils.h +++ b/common/path-utils.h @@ -28,7 +28,7 @@ char *__strncpy_null(char *dest, const char *src, size_t n); /* Helper to always get proper size of the destination string */ #define strncpy_null(dest, src) __strncpy_null(dest, src, sizeof(dest)) -int is_block_device(const char *file); +int path_is_block_device(const char *file); int is_mount_point(const char *file); int is_path_exist(const char *file); int is_reg_file(const char *path); diff --git a/common/utils.c b/common/utils.c index 57cb7ba7..f6d53ee4 100644 --- a/common/utils.c +++ b/common/utils.c @@ -431,7 +431,7 @@ int check_arg_type(const char *input) return -EINVAL; if (realpath(input, path)) { - if (is_block_device(path) == 1) + if (path_is_block_device(path) == 1) return BTRFS_ARG_BLKDEV; if (is_mount_point(path) == 1) @@ -463,7 +463,7 @@ int get_btrfs_mount(const char *dev, char *mp, size_t mp_size) int ret; int fd = -1; - ret = is_block_device(dev); + ret = path_is_block_device(dev); if (ret <= 0) { if (!ret) { error("not a block device: %s", dev); @@ -506,7 +506,7 @@ int open_path_or_dev_mnt(const char *path, DIR **dirstream, int verbose) char mp[PATH_MAX]; int ret; - if (is_block_device(path)) { + if (path_is_block_device(path)) { ret = get_btrfs_mount(path, mp, sizeof(mp)); if (ret < 0) { /* not a mounted btrfs dev */ @@ -1406,7 +1406,7 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args, memset(fi_args, 0, sizeof(*fi_args)); - if (is_block_device(path) == 1) { + if (path_is_block_device(path) == 1) { struct btrfs_super_block *disk_super; char buf[BTRFS_SUPER_INFO_SIZE]; diff --git a/mkfs/main.c b/mkfs/main.c index 52f82ba8..3ea1fd17 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -973,7 +973,7 @@ int main(int argc, char **argv) file = argv[optind++]; if (source_dir_set && is_path_exist(file) == 0) ret = 0; - else if (is_block_device(file) == 1) + else if (path_is_block_device(file) == 1) ret = test_dev_for_mkfs(file, force_overwrite); else ret = test_status_for_mkfs(file, force_overwrite); @@ -1367,7 +1367,7 @@ out: dev_cnt = argc - optind; while (dev_cnt-- > 0) { file = argv[optind++]; - if (is_block_device(file) == 1) + if (path_is_block_device(file) == 1) btrfs_register_one_device(file); } }