Skip to content

Commit

Permalink
mount_action: populate just one device in cache
Browse files Browse the repository at this point in the history
We're given the device basename as a parameter and then search through
the cache to find it.  Just load the one device, saving the probes for
the ones we don't care about.

FIXES #2
  • Loading branch information
nwf committed Jun 2, 2024
1 parent 08cd708 commit a3f2c15
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,15 @@ static void cache_load(int mtd)
_cache_load("/dev/fit*");
}

static int cache_load_dev_by_base_name(const char *name)
{
char fullpath[PATH_MAX];
int res = snprintf(fullpath, sizeof(fullpath), "/dev/%s", name);
if (res < 0 || res >= PATH_MAX)
return -1;
_cache_load(fullpath);
return 0;
}

static struct probe_info* find_block_info(char *uuid, char *label, char *path)
{
Expand Down Expand Up @@ -1254,11 +1263,15 @@ static int mount_action(char *action, char *device, int type)
if (config_load(NULL))
return -1;

cache_load(1);
if (cache_load_dev_by_base_name(device))
return -1;

list_for_each_entry(pr, &devices, list)
if (!strcmp(basename(pr->dev), device))
list_for_each_entry(pr, &devices, list) {
if (!strcmp(basename(pr->dev), device)) {
path = pr->dev;
break;
}
}

if (!path)
return -1;
Expand Down

0 comments on commit a3f2c15

Please sign in to comment.