Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
dd8232bc 09f19854

+16 -1
+8
tools/perf/util/strlist.c
··· 126 126 err = strlist__load(slist, subst); 127 127 goto out; 128 128 } 129 + 130 + if (slist->file_only) { 131 + err = -ENOENT; 132 + goto out; 133 + } 129 134 } 130 135 131 136 err = strlist__add(slist, s); ··· 162 157 163 158 if (slist != NULL) { 164 159 bool dupstr = true; 160 + bool file_only = false; 165 161 const char *dirname = NULL; 166 162 167 163 if (config) { 168 164 dupstr = !config->dont_dupstr; 169 165 dirname = config->dirname; 166 + file_only = config->file_only; 170 167 } 171 168 172 169 rblist__init(&slist->rblist); ··· 177 170 slist->rblist.node_delete = strlist__node_delete; 178 171 179 172 slist->dupstr = dupstr; 173 + slist->file_only = file_only; 180 174 181 175 if (list && strlist__parse_list(slist, list, dirname) != 0) 182 176 goto out_error;
+8 -1
tools/perf/util/strlist.h
··· 13 13 14 14 struct strlist { 15 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 25 struct strlist_config { 20 26 bool dont_dupstr; 27 + bool file_only; 21 28 const char *dirname; 22 29 }; 23 30