Browse Source

Merge pull request #557 from drewvis/main

Add check for empty tracefs mounts
Alessandro Decina 1 năm trước cách đây
mục cha
commit
b13070a342
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      aya/src/programs/utils.rs

+ 7 - 1
aya/src/programs/utils.rs

@@ -33,7 +33,13 @@ pub(crate) fn find_tracefs_path() -> Result<&'static Path, ProgramError> {
             ];
 
             for mount in known_mounts {
-                if mount.exists() {
+                // Check that the mount point exists and is not empty
+                // Documented here: (https://www.kernel.org/doc/Documentation/trace/ftrace.txt)
+                // In some cases, tracefs will only mount at /sys/kernel/debug/tracing
+                // but, the kernel will still create the directory /sys/kernel/tracing.
+                // The user may be expected to manually mount the directory in order for it to
+                // exist in /sys/kernel/tracing according to the documentation.
+                if mount.exists() && mount.read_dir().ok()?.next().is_some() {
                     return Some(mount);
                 }
             }