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 openwrt#2
  • Loading branch information
nwf committed Jun 24, 2023
1 parent 3a07943 commit 0c49b7f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion block.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,15 @@ static void cache_load(int mtd)
_cache_load("/dev/dm-*");
}

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 @@ -1253,7 +1262,8 @@ 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))
Expand Down

0 comments on commit 0c49b7f

Please sign in to comment.