@@ -233,11 +233,30 @@ LIBBPF_API int bpf_object__load(struct bpf_object *obj);
233233 */
234234LIBBPF_API void bpf_object__close (struct bpf_object * obj );
235235
236- /* pin_maps and unpin_maps can both be called with a NULL path, in which case
237- * they will use the pin_path attribute of each map (and ignore all maps that
238- * don't have a pin_path set).
236+ /**
237+ * @brief **bpf_object__pin_maps()** pins each map contained within
238+ * the BPF object at the passed directory.
239+ * @param obj Pointer to a valid BPF object
240+ * @param path A directory where maps should be pinned.
241+ * @return 0, on success; negative error code, otherwise
242+ *
243+ * If `path` is NULL `bpf_map__pin` (which is being used on each map)
244+ * will use the pin_path attribute of each map. In this case, maps that
245+ * don't have a pin_path set will be ignored.
239246 */
240247LIBBPF_API int bpf_object__pin_maps (struct bpf_object * obj , const char * path );
248+
249+ /**
250+ * @brief **bpf_object__unpin_maps()** unpins each map contained within
251+ * the BPF object found in the passed directory.
252+ * @param obj Pointer to a valid BPF object
253+ * @param path A directory where pinned maps should be searched for.
254+ * @return 0, on success; negative error code, otherwise
255+ *
256+ * If `path` is NULL `bpf_map__unpin` (which is being used on each map)
257+ * will use the pin_path attribute of each map. In this case, maps that
258+ * don't have a pin_path set will be ignored.
259+ */
241260LIBBPF_API int bpf_object__unpin_maps (struct bpf_object * obj ,
242261 const char * path );
243262LIBBPF_API int bpf_object__pin_programs (struct bpf_object * obj ,
@@ -848,10 +867,57 @@ LIBBPF_API const void *bpf_map__initial_value(struct bpf_map *map, size_t *psize
848867 * @return true, if the map is an internal map; false, otherwise
849868 */
850869LIBBPF_API bool bpf_map__is_internal (const struct bpf_map * map );
870+
871+ /**
872+ * @brief **bpf_map__set_pin_path()** sets the path attribute that tells where the
873+ * BPF map should be pinned. This does not actually create the 'pin'.
874+ * @param map The bpf_map
875+ * @param path The path
876+ * @return 0, on success; negative error, otherwise
877+ */
851878LIBBPF_API int bpf_map__set_pin_path (struct bpf_map * map , const char * path );
879+
880+ /**
881+ * @brief **bpf_map__pin_path()** gets the path attribute that tells where the
882+ * BPF map should be pinned.
883+ * @param map The bpf_map
884+ * @return The path string; which can be NULL
885+ */
852886LIBBPF_API const char * bpf_map__pin_path (const struct bpf_map * map );
887+
888+ /**
889+ * @brief **bpf_map__is_pinned()** tells the caller whether or not the
890+ * passed map has been pinned via a 'pin' file.
891+ * @param map The bpf_map
892+ * @return true, if the map is pinned; false, otherwise
893+ */
853894LIBBPF_API bool bpf_map__is_pinned (const struct bpf_map * map );
895+
896+ /**
897+ * @brief **bpf_map__pin()** creates a file that serves as a 'pin'
898+ * for the BPF map. This increments the reference count on the
899+ * BPF map which will keep the BPF map loaded even after the
900+ * userspace process which loaded it has exited.
901+ * @param map The bpf_map to pin
902+ * @param path A file path for the 'pin'
903+ * @return 0, on success; negative error, otherwise
904+ *
905+ * If `path` is NULL the maps `pin_path` attribute will be used. If this is
906+ * also NULL, an error will be returned and the map will not be pinned.
907+ */
854908LIBBPF_API int bpf_map__pin (struct bpf_map * map , const char * path );
909+
910+ /**
911+ * @brief **bpf_map__unpin()** removes the file that serves as a
912+ * 'pin' for the BPF map.
913+ * @param map The bpf_map to unpin
914+ * @param path A file path for the 'pin'
915+ * @return 0, on success; negative error, otherwise
916+ *
917+ * The `path` parameter can be NULL, in which case the `pin_path`
918+ * map attribute is unpinned. If both the `path` parameter and
919+ * `pin_path` map attribute are set, they must be equal.
920+ */
855921LIBBPF_API int bpf_map__unpin (struct bpf_map * map , const char * path );
856922
857923LIBBPF_API int bpf_map__set_inner_map_fd (struct bpf_map * map , int fd );
0 commit comments