Lines Matching +full:d +full:- +full:cache +full:- +full:block +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
3 * builtin-buildid-cache.c
5 * Builtin buildid-cache command: Manages build-id cache
21 #include <subcmd/parse-options.h>
23 #include "util/build-id.h"
27 #include "util/time-utils.h"
29 #include "util/probe-file.h"
43 return -1; in build_id_cache__kcore_buildid()
59 int i, err = -1; in same_kallsyms_reloc()
86 int ret = -1; in build_id_cache__kcore_existing()
87 DIR *d; in build_id_cache__kcore_existing() local
89 d = opendir(to_dir); in build_id_cache__kcore_existing()
90 if (!d) in build_id_cache__kcore_existing()
91 return -1; in build_id_cache__kcore_existing()
96 dent = readdir(d); in build_id_cache__kcore_existing()
99 if (dent->d_type != DT_DIR) in build_id_cache__kcore_existing()
102 dent->d_name); in build_id_cache__kcore_existing()
104 to_dir, dent->d_name); in build_id_cache__kcore_existing()
113 closedir(d); in build_id_cache__kcore_existing()
128 return -1; in build_id_cache__add_kcore()
132 return -1; in build_id_cache__add_kcore()
144 return -1; in build_id_cache__add_kcore()
150 return -1; in build_id_cache__add_kcore()
167 return -1; in build_id_cache__add_kcore()
170 pr_debug("kcore added to build-id cache directory %s\n", to_dir); in build_id_cache__add_kcore()
178 struct build_id bid = { .size = 0, }; in build_id_cache__add_file()
183 err = filename__read_build_id(filename, &bid, /*block=*/true); in build_id_cache__add_file()
186 pr_debug("Couldn't read a build-id in %s\n", filename); in build_id_cache__add_file()
187 return -1; in build_id_cache__add_file()
201 struct build_id bid = { .size = 0, }; in build_id_cache__remove_file()
207 err = filename__read_build_id(filename, &bid, /*block=*/true); in build_id_cache__remove_file()
210 pr_debug("Couldn't read a build-id in %s\n", filename); in build_id_cache__remove_file()
211 return -1; in build_id_cache__remove_file()
233 err = build_id_cache__remove_s(pos->s); in build_id_cache__purge_path()
234 pr_debug("Removing %s %s: %s\n", pos->s, pathname, in build_id_cache__purge_path()
256 pr_debug("Failed to get buildids: -%d\n", errno); in build_id_cache__purge_all()
257 return -EINVAL; in build_id_cache__purge_all()
261 buf = build_id_cache__origname(pos->s); in build_id_cache__purge_all()
262 err = build_id_cache__remove_s(pos->s); in build_id_cache__purge_all()
263 pr_debug("Removing %s (%s): %s\n", buf, pos->s, in build_id_cache__purge_all()
278 struct build_id bid = { .size = 0, }; in dso__missing_buildid_cache()
283 if (filename__read_build_id(filename, &bid, /*block=*/true) == -1) { in dso__missing_buildid_cache()
287 pr_warning("Problems with %s file, consider removing it from the cache\n", in dso__missing_buildid_cache()
289 } else if (memcmp(dso__bid(dso)->data, bid.data, bid.size)) { in dso__missing_buildid_cache()
290 pr_warning("Problems with %s file, consider removing it from the cache\n", in dso__missing_buildid_cache()
306 struct build_id bid = { .size = 0, }; in build_id_cache__update_file()
312 err = filename__read_build_id(filename, &bid, /*block=*/true); in build_id_cache__update_file()
315 pr_debug("Couldn't read a build-id in %s\n", filename); in build_id_cache__update_file()
316 return -1; in build_id_cache__update_file()
342 pr_debug("Failed to get buildids: -%d\n", errno); in build_id_cache__show_all()
343 return -1; in build_id_cache__show_all()
346 buf = build_id_cache__origname(nd->s); in build_id_cache__show_all()
347 fprintf(stdout, "%s %s\n", nd->s, buf); in build_id_cache__show_all()
358 if (!strcmp(var, "buildid-cache.debuginfod")) { in perf_buildid_cache_config()
359 di->urls = strdup(value); in perf_buildid_cache_config()
360 if (!di->urls) in perf_buildid_cache_config()
361 return -ENOMEM; in perf_buildid_cache_config()
362 di->set = true; in perf_buildid_cache_config()
372 int ret, ns_id = -1; in cmd_buildid_cache()
401 OPT_BOOLEAN('P', "purge-all", &purge_all, "purge all cached files"), in cmd_buildid_cache()
404 "to find missing build ids in the cache"), in cmd_buildid_cache()
413 OPT_INTEGER(0, "target-ns", &ns_id, "target pid for namespace context"), in cmd_buildid_cache()
417 "perf buildid-cache [<options>]", in cmd_buildid_cache()
438 /* -l is exclusive. It can not be used with other options. */ in cmd_buildid_cache()
441 buildid_cache_options, "-l is exclusive.\n"); in cmd_buildid_cache()
470 if (build_id_cache__add_file(pos->s, nsi)) { in cmd_buildid_cache()
472 pr_debug("%s already in the cache\n", in cmd_buildid_cache()
473 pos->s); in cmd_buildid_cache()
477 pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); in cmd_buildid_cache()
488 if (build_id_cache__remove_file(pos->s, nsi)) { in cmd_buildid_cache()
490 pr_debug("%s wasn't in the cache\n", in cmd_buildid_cache()
491 pos->s); in cmd_buildid_cache()
495 pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); in cmd_buildid_cache()
506 if (build_id_cache__purge_path(pos->s, nsi)) { in cmd_buildid_cache()
508 pr_debug("%s wasn't in the cache\n", in cmd_buildid_cache()
509 pos->s); in cmd_buildid_cache()
513 pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); in cmd_buildid_cache()
534 if (build_id_cache__update_file(pos->s, nsi)) { in cmd_buildid_cache()
536 pr_debug("%s wasn't in the cache\n", in cmd_buildid_cache()
537 pos->s); in cmd_buildid_cache()
541 pos->s, str_error_r(errno, sbuf, sizeof(sbuf))); in cmd_buildid_cache()