[PATCH v2] wpa_debug: prefer tracefs over debugfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Berg <johannes.berg@xxxxxxxxx>

With Linux 6.17, having /sys/kernel/debug/tracing/ is
now optional (CONFIG_TRACEFS_AUTOMOUNT_DEPRECATED),
since tracefs has been around for a long time. Prefer
tracefs when finding the trace_marker file.

Note the "!buf[0]" condition which serves to keep the
logic identical to before when tracefs isn't present,
using the first debugfs rather than the last. That is
not likely to matter, but still.

Also mount tracefs in the scripts for running in VMs.

Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
---
v2: add the mount
---
 src/utils/wpa_debug.c    | 24 +++++++++++++++++-------
 tests/hwsim/vm/inside.sh |  1 +
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
index 7f3dd185f100..78686e5af1cd 100644
--- a/src/utils/wpa_debug.c
+++ b/src/utils/wpa_debug.c
@@ -130,7 +130,7 @@ int wpa_debug_open_linux_tracing(void)
 	int mounts, trace_fd;
 	char buf[4096] = {};
 	ssize_t buflen;
-	char *line, *tmp1, *path = NULL;
+	char *line, *tmp1;
 
 	mounts = open("/proc/mounts", O_RDONLY);
 	if (mounts < 0) {
@@ -153,21 +153,31 @@ int wpa_debug_open_linux_tracing(void)
 		strtok_r(line, " ", &tmp2);
 		tmp_path = strtok_r(NULL, " ", &tmp2);
 		fstype = strtok_r(NULL, " ", &tmp2);
-		if (fstype && strcmp(fstype, "debugfs") == 0) {
-			path = tmp_path;
+
+		if (!buf[0] && fstype && strcmp(fstype, "debugfs") == 0) {
+			snprintf(buf, sizeof(buf) - 1, "%s/tracing/trace_marker",
+				 tmp_path);
+			/*
+			 * don't break to prefer tracefs, which if present may
+			 * mean debugfs doesn't have tracing/ (depending on the
+			 * kernel version)
+			 */
+		}
+
+		if (fstype && strcmp(fstype, "tracefs") == 0) {
+			snprintf(buf, sizeof(buf) - 1, "%s/trace_marker",
+				 tmp_path);
 			break;
 		}
 
 		line = strtok_r(NULL, "\n", &tmp1);
 	}
 
-	if (path == NULL) {
-		printf("debugfs mountpoint not found\n");
+	if (!buf[0]) {
+		printf("tracefs/debugfs not found\n");
 		return -1;
 	}
 
-	snprintf(buf, sizeof(buf) - 1, "%s/tracing/trace_marker", path);
-
 	trace_fd = open(buf, O_WRONLY);
 	if (trace_fd < 0) {
 		printf("failed to open trace_marker file\n");
diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh
index 31dfb9d5708c..53d67472cd50 100755
--- a/tests/hwsim/vm/inside.sh
+++ b/tests/hwsim/vm/inside.sh
@@ -14,6 +14,7 @@ mount proc -t proc /proc
 mount sysfs -t sysfs /sys
 # needed for tracing
 mount debugfs -t debugfs /sys/kernel/debug
+mount tracefs -t tracefs /sys/kernel/tracing
 
 mkdir /tmp/wireshark-share
 mount --bind /usr/share/wireshark /tmp/wireshark-share
-- 
2.51.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux