Skip to content

Commit 665c098

Browse files
committed
btrfs-progs: rename and move get_device_info
The helper belongs to the device-utils, move it there and use the common prefix. Signed-off-by: David Sterba <[email protected]>
1 parent bd272bc commit 665c098

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

cmds/filesystem-usage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static int load_device_info(int fd, struct device_info **devinfo_ret,
776776
goto out;
777777
}
778778
memset(&dev_info, 0, sizeof(dev_info));
779-
ret = get_device_info(fd, i, &dev_info);
779+
ret = device_get_info(fd, i, &dev_info);
780780

781781
if (ret == -ENODEV)
782782
continue;

common/device-utils.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,17 @@ int device_get_rotational(const char *file)
530530
return (rotational == '0');
531531
}
532532

533+
int device_get_info(int fd, u64 devid, struct btrfs_ioctl_dev_info_args *di_args)
534+
{
535+
int ret;
536+
537+
di_args->devid = devid;
538+
memset(&di_args->uuid, 0, sizeof(di_args->uuid));
539+
ret = ioctl(fd, BTRFS_IOC_DEV_INFO, di_args);
540+
541+
return ret < 0 ? -errno : 0;
542+
}
543+
533544
ssize_t btrfs_direct_pread(int fd, void *buf, size_t count, off_t offset)
534545
{
535546
int alignment;

common/device-utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <sys/stat.h>
2222
#include <stdbool.h>
2323
#include <unistd.h>
24+
#include "kernel-shared/uapi/btrfs.h"
2425

2526
/*
2627
* Options for btrfs_prepare_device
@@ -45,6 +46,7 @@ int device_get_queue_param(const char *file, const char *param, char *buf, size_
4546
u64 device_get_zone_unusable(int fd, u64 flags);
4647
u64 device_get_zone_size(int fd, const char *name);
4748
int device_get_rotational(const char *file);
49+
int device_get_info(int fd, u64 devid, struct btrfs_ioctl_dev_info_args *di_args);
4850
/*
4951
* Updates to devices with btrfs-specific changs
5052
*/

common/utils.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "kernel-shared/disk-io.h"
3535
#include "kernel-shared/volumes.h"
3636
#include "common/utils.h"
37+
#include "common/device-utils.h"
3738
#include "common/path-utils.h"
3839
#include "common/open-utils.h"
3940
#include "common/sysfs-utils.h"
@@ -67,18 +68,6 @@ void btrfs_format_csum(u16 csum_type, const u8 *data, char *output)
6768
}
6869
}
6970

70-
int get_device_info(int fd, u64 devid,
71-
struct btrfs_ioctl_dev_info_args *di_args)
72-
{
73-
int ret;
74-
75-
di_args->devid = devid;
76-
memset(&di_args->uuid, '\0', sizeof(di_args->uuid));
77-
78-
ret = ioctl(fd, BTRFS_IOC_DEV_INFO, di_args);
79-
return ret < 0 ? -errno : 0;
80-
}
81-
8271
int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
8372
{
8473
u64 count = 0;
@@ -281,7 +270,7 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
281270
* search_chunk_tree_for_fs_info() will lacks the devid 0
282271
* so manual probe for it here.
283272
*/
284-
ret = get_device_info(fd, 0, &tmp);
273+
ret = device_get_info(fd, 0, &tmp);
285274
if (!ret) {
286275
fi_args->num_devices++;
287276
ndevs++;
@@ -304,7 +293,7 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
304293
memcpy(di_args, &tmp, sizeof(tmp));
305294
for (; last_devid <= fi_args->max_id && ndevs < fi_args->num_devices;
306295
last_devid++) {
307-
ret = get_device_info(fd, last_devid, &di_args[ndevs]);
296+
ret = device_get_info(fd, last_devid, &di_args[ndevs]);
308297
if (ret == -ENODEV)
309298
continue;
310299
if (ret)

common/utils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ int ask_user(const char *question);
5959
int lookup_path_rootid(int fd, u64 *rootid);
6060
int find_mount_fsroot(const char *subvol, const char *subvolid, char **mount);
6161
int find_mount_root(const char *path, char **mount_root);
62-
int get_device_info(int fd, u64 devid,
63-
struct btrfs_ioctl_dev_info_args *di_args);
6462
int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret);
6563

6664
const char *subvol_strip_mountpoint(const char *mnt, const char *full_path);

0 commit comments

Comments
 (0)