mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-17 04:25:48 +00:00
btrfs-progs: Factor out common print_device_info
This function has been copied twice in chunk-recover and super-recover. Factor it out into utils.c/h and use it. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
058fad5b92
commit
6eccbe81f1
@ -451,24 +451,6 @@ static void print_device_extent_tree(struct device_extent_tree *tree)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void print_device_info(struct btrfs_device *device, char *prefix)
|
||||
{
|
||||
if (prefix)
|
||||
printf("%s", prefix);
|
||||
printf("Device: id = %llu, name = %s\n",
|
||||
device->devid, device->name);
|
||||
}
|
||||
|
||||
static void print_all_devices(struct list_head *devices)
|
||||
{
|
||||
struct btrfs_device *dev;
|
||||
|
||||
printf("All Devices:\n");
|
||||
list_for_each_entry(dev, devices, dev_list)
|
||||
print_device_info(dev, "\t");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void print_scan_result(struct recover_control *rc)
|
||||
{
|
||||
if (!rc->verbose)
|
||||
|
@ -186,19 +186,6 @@ static struct super_block_record *recover_get_good_super(
|
||||
return record;
|
||||
}
|
||||
|
||||
static void print_all_devices(struct list_head *devices)
|
||||
{
|
||||
struct btrfs_device *dev;
|
||||
|
||||
printf("All Devices:\n");
|
||||
list_for_each_entry(dev, devices, dev_list) {
|
||||
printf("\t");
|
||||
printf("Device: id = %llu, name = %s\n",
|
||||
dev->devid, dev->name);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void print_super_info(struct super_block_record *record)
|
||||
{
|
||||
printf("\t\tdevice name = %s\n", record->device_name);
|
||||
|
18
utils.c
18
utils.c
@ -2716,3 +2716,21 @@ unsigned long total_memory(void)
|
||||
}
|
||||
return si.totalram * si.mem_unit; /* bytes */
|
||||
}
|
||||
|
||||
void print_device_info(struct btrfs_device *device, char *prefix)
|
||||
{
|
||||
if (prefix)
|
||||
printf("%s", prefix);
|
||||
printf("Device: id = %llu, name = %s\n",
|
||||
device->devid, device->name);
|
||||
}
|
||||
|
||||
void print_all_devices(struct list_head *devices)
|
||||
{
|
||||
struct btrfs_device *dev;
|
||||
|
||||
printf("All Devices:\n");
|
||||
list_for_each_entry(dev, devices, dev_list)
|
||||
print_device_info(dev, "\t");
|
||||
printf("\n");
|
||||
}
|
||||
|
3
utils.h
3
utils.h
@ -173,6 +173,9 @@ int prefixcmp(const char *str, const char *prefix);
|
||||
|
||||
unsigned long total_memory(void);
|
||||
|
||||
void print_device_info(struct btrfs_device *device, char *prefix);
|
||||
void print_all_devices(struct list_head *devices);
|
||||
|
||||
/*
|
||||
* Global program state, configurable by command line and available to
|
||||
* functions without extra context passing.
|
||||
|
Loading…
Reference in New Issue
Block a user