Skip to content

Commit 9f0f169

Browse files
committed
tree: update nvme_scan_filter_t usage
Add two more arguments (nvme_ctrl_t and nvme_ns_t) to the nvme scan filter to allow the implementation to distinguish between the call sites. This allows for a more targeted approach when implementing filters. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 8d371dd commit 9f0f169

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/nvme/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int nvme_scan_topology(struct nvme_root *r, nvme_scan_filter_t f)
9797
ctrls[i]->d_name, strerror(errno));
9898
continue;
9999
}
100-
if ((f) && !f(c->s)) {
100+
if ((f) && !f(NULL, c, NULL)) {
101101
nvme_msg(r, LOG_DEBUG, "filter out controller %s\n",
102102
ctrls[i]->d_name);
103103
nvme_free_ctrl(c);
@@ -575,7 +575,7 @@ static int nvme_scan_subsystem(struct nvme_root *r, const char *name,
575575

576576
nvme_subsystem_scan_namespaces(r, s);
577577

578-
if (f && !f(s)) {
578+
if (f && !f(s, NULL, NULL)) {
579579
nvme_msg(r, LOG_DEBUG, "filter out subsystem %s\n", name);
580580
__nvme_free_subsystem(s);
581581
}

src/nvme/tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef struct nvme_subsystem *nvme_subsystem_t;
3333
typedef struct nvme_host *nvme_host_t;
3434
typedef struct nvme_root *nvme_root_t;
3535

36-
typedef bool (*nvme_scan_filter_t)(nvme_subsystem_t);
36+
typedef bool (*nvme_scan_filter_t)(nvme_subsystem_t, nvme_ctrl_t, nvme_ns_t);
3737

3838
/**
3939
* nvme_create_root() - Initialize root object

test/test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626

2727
static char *nqn_match;
2828

29-
static bool nvme_match_subsysnqn_filter(nvme_subsystem_t s)
29+
static bool nvme_match_subsysnqn_filter(nvme_subsystem_t s,
30+
nvme_ctrl_t c, nvme_ns_t ns)
3031
{
31-
return strcmp(nvme_subsystem_get_nqn(s), nqn_match) == 0;
32+
if (s)
33+
return strcmp(nvme_subsystem_get_nqn(s), nqn_match) == 0;
34+
return true;
3235
}
3336

3437
static int test_ctrl(nvme_ctrl_t c)

0 commit comments

Comments
 (0)