|
@@ -1357,6 +1357,28 @@ int bpf_program__pin(struct bpf_program *prog, const char *path)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+int bpf_map__pin(struct bpf_map *map, const char *path)
|
|
|
+{
|
|
|
+ int err;
|
|
|
+
|
|
|
+ err = check_path(path);
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ if (map == NULL) {
|
|
|
+ pr_warning("invalid map pointer\n");
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bpf_obj_pin(map->fd, path)) {
|
|
|
+ pr_warning("failed to pin map: %s\n", strerror(errno));
|
|
|
+ return -errno;
|
|
|
+ }
|
|
|
+
|
|
|
+ pr_debug("pinned map '%s'\n", path);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
void bpf_object__close(struct bpf_object *obj)
|
|
|
{
|
|
|
size_t i;
|