btrfs-progs: path-utils: rename is_block_device

Add the path_ prefix and update all callers.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2019-07-01 21:29:43 +02:00
parent f83e81c61b
commit c3b0e6970b
6 changed files with 17 additions and 15 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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];

View File

@ -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);
}
}