Skip to content

Commit dd8232b

Browse files
namhyungacmel
authored andcommitted
perf tools: Add file_only config option to strlist
If strlist_config.dirname is present, the strlist__new() tries to load stirngs from dirname/list file first but if it failes it falls back to add 'list' as string. But sometimes it's not desired so adds new file_only field to prevent it. Signed-off-by: Namhyung Kim <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ Add documentation for strlist_config::file_only, in the struct definition */ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 09f1985 commit dd8232b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tools/perf/util/strlist.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ static int strlist__parse_list_entry(struct strlist *slist, const char *s,
126126
err = strlist__load(slist, subst);
127127
goto out;
128128
}
129+
130+
if (slist->file_only) {
131+
err = -ENOENT;
132+
goto out;
133+
}
129134
}
130135

131136
err = strlist__add(slist, s);
@@ -157,11 +162,13 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
157162

158163
if (slist != NULL) {
159164
bool dupstr = true;
165+
bool file_only = false;
160166
const char *dirname = NULL;
161167

162168
if (config) {
163169
dupstr = !config->dont_dupstr;
164170
dirname = config->dirname;
171+
file_only = config->file_only;
165172
}
166173

167174
rblist__init(&slist->rblist);
@@ -170,6 +177,7 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
170177
slist->rblist.node_delete = strlist__node_delete;
171178

172179
slist->dupstr = dupstr;
180+
slist->file_only = file_only;
173181

174182
if (list && strlist__parse_list(slist, list, dirname) != 0)
175183
goto out_error;

tools/perf/util/strlist.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ struct str_node {
1313

1414
struct strlist {
1515
struct rblist rblist;
16-
bool dupstr;
16+
bool dupstr;
17+
bool file_only;
1718
};
1819

20+
/*
21+
* @file_only: When dirname is present, only consider entries as filenames,
22+
* that should not be added to the list if dirname/entry is not
23+
* found
24+
*/
1925
struct strlist_config {
2026
bool dont_dupstr;
27+
bool file_only;
2128
const char *dirname;
2229
};
2330

0 commit comments

Comments
 (0)