mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-03-10 00:00:04 +03:00
bcacheadm: add "list-cachesets --internal_uuid UUID" option
This shows the superblock set_uuid, given the user_uuid. Signed-off-by: Jacob Malevich <jam@daterainc.com> Issue DAT-1913 Change-Id: If5f81427ac02bceeb609ae119f044de3fb5a0d77
This commit is contained in:
parent
8c9ab06141
commit
3fa318e8b7
31
bcacheadm.c
31
bcacheadm.c
@ -79,6 +79,7 @@ bool udev = false;
|
|||||||
/* list globals */
|
/* list globals */
|
||||||
char *cset_dir = "/sys/fs/bcache";
|
char *cset_dir = "/sys/fs/bcache";
|
||||||
bool list_devs = false;
|
bool list_devs = false;
|
||||||
|
static const char *internal_uuid = NULL;
|
||||||
|
|
||||||
/* status globals */
|
/* status globals */
|
||||||
bool status_all = false;
|
bool status_all = false;
|
||||||
@ -248,6 +249,7 @@ static NihOption query_devs_options[] = {
|
|||||||
static NihOption list_cachesets_options[] = {
|
static NihOption list_cachesets_options[] = {
|
||||||
{'d', "dir", N_("directory"), NULL, NULL, &cset_dir, NULL},
|
{'d', "dir", N_("directory"), NULL, NULL, &cset_dir, NULL},
|
||||||
{0, "list-devs", N_("list all devices in the cache sets as well"), NULL, NULL, &list_devs, NULL},
|
{0, "list-devs", N_("list all devices in the cache sets as well"), NULL, NULL, &list_devs, NULL},
|
||||||
|
{0, "internal_uuid", N_("Show the internal UUID for the given cacheset UUID"), NULL, "UUID", &internal_uuid, NULL},
|
||||||
NIH_OPTION_LAST
|
NIH_OPTION_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -550,13 +552,34 @@ err:
|
|||||||
int bcache_list_cachesets(NihCommand *command, char *const *args)
|
int bcache_list_cachesets(NihCommand *command, char *const *args)
|
||||||
{
|
{
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
err = list_cachesets(cset_dir, list_devs);
|
|
||||||
if (err) {
|
if (internal_uuid) {
|
||||||
printf("bcache_list_cachesets error :%s\n", err);
|
char uuid_path[MAX_PATH];
|
||||||
return -1;
|
DIR *uuid_dir;
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
|
snprintf(uuid_path, MAX_PATH, "%s/%s", cset_dir, internal_uuid);
|
||||||
|
|
||||||
|
err = "uuid does not exist";
|
||||||
|
if((uuid_dir = opendir(uuid_path)) == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
err = read_stat_dir(uuid_dir, uuid_path, "/internal/internal_uuid", buf);
|
||||||
|
if (err)
|
||||||
|
goto err;
|
||||||
|
printf("%s", buf);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = list_cachesets(cset_dir, list_devs);
|
||||||
|
if (err)
|
||||||
|
goto err;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
printf("bcache_list_cachesets error :%s\n", err);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bcache_query_devs(NihCommand *command, char *const *args)
|
int bcache_query_devs(NihCommand *command, char *const *args)
|
||||||
|
Loading…
Reference in New Issue
Block a user