Skip to content

Commit

Permalink
btrfs-progs: convert device info to struct array
Browse files Browse the repository at this point in the history
The device infos are passed as two parameters, use struct array for that.

Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
kdave committed Jul 17, 2023
1 parent 26fcce7 commit 271696c
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 103 deletions.
19 changes: 10 additions & 9 deletions cmds/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,25 +835,26 @@ static const char * const cmd_device_usage_usage[] = {

static int _cmd_device_usage(int fd, const char *path, unsigned unit_mode)
{
int i;
int ret = 0;
struct array chunkinfos = { 0 };
struct device_info *devinfo = NULL;
int devcount = 0;
struct array devinfos = { 0 };

ret = load_chunk_and_device_info(fd, &chunkinfos, &devinfo, &devcount);
ret = load_chunk_and_device_info(fd, &chunkinfos, &devinfos);
if (ret)
goto out;

for (i = 0; i < devcount; i++) {
pr_verbose(LOG_DEFAULT, "%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
print_device_sizes(&devinfo[i], unit_mode);
print_device_chunks(&devinfo[i], &chunkinfos, unit_mode);
for (int i = 0; i < devinfos.length; i++) {
const struct device_info *devinfo = devinfos.data[i];

pr_verbose(LOG_DEFAULT, "%s, ID: %llu\n", devinfo->path, devinfo->devid);
print_device_sizes(devinfo, unit_mode);
print_device_chunks(devinfo, &chunkinfos, unit_mode);
pr_verbose(LOG_DEFAULT, "\n");
}

out:
free(devinfo);
array_free_elements(&devinfos);
array_free(&devinfos);
array_free_elements(&chunkinfos);
array_free(&chunkinfos);

Expand Down
Loading

0 comments on commit 271696c

Please sign in to comment.