diff options
author | Namhyung Kim <namhyung@kernel.org> | 2016-01-09 05:16:27 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-12 10:42:07 -0500 |
commit | dd8232bc9d13b729d92590b55befd14e49f81eca (patch) | |
tree | 5a5b1ac324ce83fb1f53cd2fb456106f4415aac4 /tools | |
parent | 09f1985404aa99b9d1ad435fcb0dabd20d4ed498 (diff) |
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 <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452334589-8782-2-git-send-email-namhyung@kernel.org
[ Add documentation for strlist_config::file_only, in the struct definition */
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/strlist.c | 8 | ||||
-rw-r--r-- | tools/perf/util/strlist.h | 9 |
2 files changed, 16 insertions, 1 deletions
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c index bdf98f6f27bb..0d3dfcb919b4 100644 --- a/tools/perf/util/strlist.c +++ b/tools/perf/util/strlist.c | |||
@@ -126,6 +126,11 @@ static int strlist__parse_list_entry(struct strlist *slist, const char *s, | |||
126 | err = strlist__load(slist, subst); | 126 | err = strlist__load(slist, subst); |
127 | goto out; | 127 | goto out; |
128 | } | 128 | } |
129 | |||
130 | if (slist->file_only) { | ||
131 | err = -ENOENT; | ||
132 | goto out; | ||
133 | } | ||
129 | } | 134 | } |
130 | 135 | ||
131 | err = strlist__add(slist, s); | 136 | err = strlist__add(slist, s); |
@@ -157,11 +162,13 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf | |||
157 | 162 | ||
158 | if (slist != NULL) { | 163 | if (slist != NULL) { |
159 | bool dupstr = true; | 164 | bool dupstr = true; |
165 | bool file_only = false; | ||
160 | const char *dirname = NULL; | 166 | const char *dirname = NULL; |
161 | 167 | ||
162 | if (config) { | 168 | if (config) { |
163 | dupstr = !config->dont_dupstr; | 169 | dupstr = !config->dont_dupstr; |
164 | dirname = config->dirname; | 170 | dirname = config->dirname; |
171 | file_only = config->file_only; | ||
165 | } | 172 | } |
166 | 173 | ||
167 | rblist__init(&slist->rblist); | 174 | rblist__init(&slist->rblist); |
@@ -170,6 +177,7 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf | |||
170 | slist->rblist.node_delete = strlist__node_delete; | 177 | slist->rblist.node_delete = strlist__node_delete; |
171 | 178 | ||
172 | slist->dupstr = dupstr; | 179 | slist->dupstr = dupstr; |
180 | slist->file_only = file_only; | ||
173 | 181 | ||
174 | if (list && strlist__parse_list(slist, list, dirname) != 0) | 182 | if (list && strlist__parse_list(slist, list, dirname) != 0) |
175 | goto out_error; | 183 | goto out_error; |
diff --git a/tools/perf/util/strlist.h b/tools/perf/util/strlist.h index 297565aa7535..ca990029e243 100644 --- a/tools/perf/util/strlist.h +++ b/tools/perf/util/strlist.h | |||
@@ -13,11 +13,18 @@ struct str_node { | |||
13 | 13 | ||
14 | struct strlist { | 14 | struct strlist { |
15 | struct rblist rblist; | 15 | struct rblist rblist; |
16 | bool dupstr; | 16 | bool dupstr; |
17 | bool file_only; | ||
17 | }; | 18 | }; |
18 | 19 | ||
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 | */ | ||
19 | struct strlist_config { | 25 | struct strlist_config { |
20 | bool dont_dupstr; | 26 | bool dont_dupstr; |
27 | bool file_only; | ||
21 | const char *dirname; | 28 | const char *dirname; |
22 | }; | 29 | }; |
23 | 30 | ||