Merge pull request #437 from himikof/show_super_fixes

Small improvements in show-super output
This commit is contained in:
koverstreet 2025-09-27 22:24:08 -04:00 committed by GitHub
commit 35052fc376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 13 deletions

View File

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

View File

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