[PATCH bpf-next] bpf: uapi: Document front truncation in bpf_d_path()

From: Daniel Xu
Date: Mon Dec 30 2024 - 16:55:58 EST


bpf_d_path() will truncate the resolved path from the front if the
provided buffer is too small. This is somewhat non-intuitive but makes
sense when you think about it. So document it.

Signed-off-by: Daniel Xu <dxu@xxxxxxxxx>
---
include/uapi/linux/bpf.h | 4 ++++
tools/include/uapi/linux/bpf.h | 4 ++++
2 files changed, 8 insertions(+)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 2acf9b336371..91218c5fd207 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -4845,6 +4845,10 @@ union bpf_attr {
* including the trailing NUL character. On error, a negative
* value.
*
+ * If *buf* is too small, the resolved path is truncated from
+ * the front and -ENAMETOOLONG is returned. The buffer is valid
+ * in this case.
+ *
* long bpf_copy_from_user(void *dst, u32 size, const void *user_ptr)
* Description
* Read *size* bytes from user space address *user_ptr* and store
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 2acf9b336371..91218c5fd207 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -4845,6 +4845,10 @@ union bpf_attr {
* including the trailing NUL character. On error, a negative
* value.
*
+ * If *buf* is too small, the resolved path is truncated from
+ * the front and -ENAMETOOLONG is returned. The buffer is valid
+ * in this case.
+ *
* long bpf_copy_from_user(void *dst, u32 size, const void *user_ptr)
* Description
* Read *size* bytes from user space address *user_ptr* and store
--
2.47.1