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>
This commit is contained in:
parent
09f1985404
commit
dd8232bc9d
2 changed files with 16 additions and 1 deletions
|
@ -126,6 +126,11 @@ static int strlist__parse_list_entry(struct strlist *slist, const char *s,
|
||||||
err = strlist__load(slist, subst);
|
err = strlist__load(slist, subst);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (slist->file_only) {
|
||||||
|
err = -ENOENT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = strlist__add(slist, s);
|
err = strlist__add(slist, s);
|
||||||
|
@ -157,11 +162,13 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
|
||||||
|
|
||||||
if (slist != NULL) {
|
if (slist != NULL) {
|
||||||
bool dupstr = true;
|
bool dupstr = true;
|
||||||
|
bool file_only = false;
|
||||||
const char *dirname = NULL;
|
const char *dirname = NULL;
|
||||||
|
|
||||||
if (config) {
|
if (config) {
|
||||||
dupstr = !config->dont_dupstr;
|
dupstr = !config->dont_dupstr;
|
||||||
dirname = config->dirname;
|
dirname = config->dirname;
|
||||||
|
file_only = config->file_only;
|
||||||
}
|
}
|
||||||
|
|
||||||
rblist__init(&slist->rblist);
|
rblist__init(&slist->rblist);
|
||||||
|
@ -170,6 +177,7 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
|
||||||
slist->rblist.node_delete = strlist__node_delete;
|
slist->rblist.node_delete = strlist__node_delete;
|
||||||
|
|
||||||
slist->dupstr = dupstr;
|
slist->dupstr = dupstr;
|
||||||
|
slist->file_only = file_only;
|
||||||
|
|
||||||
if (list && strlist__parse_list(slist, list, dirname) != 0)
|
if (list && strlist__parse_list(slist, list, dirname) != 0)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
|
|
|
@ -13,11 +13,18 @@ struct str_node {
|
||||||
|
|
||||||
struct strlist {
|
struct strlist {
|
||||||
struct rblist rblist;
|
struct rblist rblist;
|
||||||
bool dupstr;
|
bool dupstr;
|
||||||
|
bool file_only;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @file_only: When dirname is present, only consider entries as filenames,
|
||||||
|
* that should not be added to the list if dirname/entry is not
|
||||||
|
* found
|
||||||
|
*/
|
||||||
struct strlist_config {
|
struct strlist_config {
|
||||||
bool dont_dupstr;
|
bool dont_dupstr;
|
||||||
|
bool file_only;
|
||||||
const char *dirname;
|
const char *dirname;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue