mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-08 00:00:12 +03:00
Merge pull request #437 from himikof/show_super_fixes
Small improvements in show-super output
This commit is contained in:
commit
35052fc376
@ -58,6 +58,9 @@ static void print_one_member(struct printbuf *out, sb_names sb_names,
|
||||
struct bch_sb_field_disk_groups *gi,
|
||||
struct bch_member m, unsigned idx)
|
||||
{
|
||||
if (!bch2_member_alive(&m))
|
||||
return;
|
||||
|
||||
struct sb_name *name = sb_dev_to_name(sb_names, idx);
|
||||
prt_printf(out, "Device %u:\t%s\t", idx, name ? name->name : "(not found)");
|
||||
|
||||
|
||||
@ -632,27 +632,27 @@ char *fd_to_dev_model(int fd)
|
||||
|
||||
/* partition? try parent */
|
||||
|
||||
char buf[1024];
|
||||
if (readlink(sysfs_path, buf, sizeof(buf)) < 0)
|
||||
die("readlink error on %s: %m", sysfs_path);
|
||||
|
||||
free(sysfs_path);
|
||||
sysfs_path = strdup(buf);
|
||||
|
||||
*strrchr(sysfs_path, '/') = 0;
|
||||
model_path = mprintf("%s/device/model", sysfs_path);
|
||||
model_path = mprintf("%s/../device/model", sysfs_path);
|
||||
if (!access(model_path, R_OK))
|
||||
goto got_model;
|
||||
free(model_path);
|
||||
|
||||
return strdup("(unknown device)");
|
||||
char *model;
|
||||
/* loop device? try loop/backing_file */
|
||||
|
||||
model_path = mprintf("%s/loop/backing_file", sysfs_path);
|
||||
if (!access(model_path, R_OK))
|
||||
goto got_model;
|
||||
free(model_path);
|
||||
|
||||
free(sysfs_path);
|
||||
return strdup("(unknown model)");
|
||||
got_model:
|
||||
model = read_file_str(AT_FDCWD, model_path);
|
||||
char* model = read_file_str(AT_FDCWD, model_path);
|
||||
free(model_path);
|
||||
free(sysfs_path);
|
||||
return model;
|
||||
} else {
|
||||
return strdup("(reg file)");
|
||||
return strdup("(image file)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user