Skip to content

Instantly share code, notes, and snippets.

@alban
Created October 16, 2018 09:07
Show Gist options
  • Save alban/fbf77c5bec89a2bd567a2923458d4508 to your computer and use it in GitHub Desktop.
Save alban/fbf77c5bec89a2bd567a2923458d4508 to your computer and use it in GitHub Desktop.
diff --git a/docs/reference_guide.md b/docs/reference_guide.md
index 512064f..f0e2229 100644
--- a/docs/reference_guide.md
+++ b/docs/reference_guide.md
@@ -1121,6 +1121,7 @@ Note that for this example to work, bash had to be recompiled with frame pointer
- `usym(void *p)` - Resolve user space address
- `kaddr(char *name)` - Resolve kernel symbol name
- `uaddr(char *name)` - Resolve user-level symbol name
+- `cgroupid(char *path)` - Resolve cgroup id
- `reg(char *name)` - Returns the value stored in the named register
- `system(char *fmt)` - Execute shell command
- `exit()` - Quit bpftrace
@@ -1267,6 +1268,29 @@ PS1: \[\e[34;1m\]\u@\h:\w>\[\e[0m\]
This is printing the `ps1_prompt` string from /bin/bash, whenever a `readline()` function is executed.
+## 10. `cgroupid()`: cgroup id resolution, user-level
+
+Syntax: `cgroupid(char *path)`
+
+Examples:
+
+```
+# bpftrace -e 'tracepoint:syscalls:sys_enter_openat /cgroup == cgroupid("/sys/fs/cgroup/unified/mycg")/ { printf("%s\n", str(args->filename)); }':
+Attaching 1 probe...
+/etc/ld.so.cache
+/lib64/libc.so.6
+/usr/lib/locale/locale-archive
+/etc/shadow
+^C
+```
+
+```
+# echo $$ > /sys/fs/cgroup/unified/mycg/cgroup.procs
+# cat /etc/shadow
+```
+
+This is
+
## 10. `reg()`: Registers
Syntax: `reg(char *name)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment