From ff044e71420ccaf066adc02d27df53edffc76b5b Mon Sep 17 00:00:00 2001 From: Clark Williams Date: Wed, 7 Sep 2011 15:32:54 -0500 Subject: [PATCH] handle stupid systemd automount of debugfs Signed-off-by: Clark Williams --- src/lib/rt-utils.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c index 952ad7f..4776c00 100644 --- a/src/lib/rt-utils.c +++ b/src/lib/rt-utils.c @@ -25,6 +25,7 @@ char *get_debugfileprefix(void) char type[100]; FILE *fp; int size; + int found = 0; if (debugfileprefix[0] != '\0') return debugfileprefix; @@ -36,12 +37,19 @@ char *get_debugfileprefix(void) STR(MAX_PATH) "s %99s %*s %*d %*d\n", debugfileprefix, type) == 2) { - if (strcmp(type, "debugfs") == 0) + if (strcmp(type, "debugfs") == 0) { + found = 1; break; + } + if ((strcmp(debugfileprefix, "/sys/kernel/debug") == 0) && + (strcmp(type, "systemd") == 0)) { + found = 1; + break; + } } fclose(fp); - if (strcmp(type, "debugfs") != 0) { + if (!found) { debugfileprefix[0] = '\0'; return debugfileprefix; } @@ -56,15 +64,23 @@ int mount_debugfs(char *path) { char *mountpoint = path; char cmd[MAX_PATH]; + char *prefix; int ret; - if (get_debugfileprefix()) + if (!path) + printf("mount_debugfs: null input\n"); + + prefix = get_debugfileprefix(); + if (strlen(prefix)) { + printf("mount_debugfs: current debug fileprefix: %s\n", prefix); return 0; + } if (!mountpoint) mountpoint = "/sys/kernel/debug"; sprintf(cmd, "mount -t debugfs debugfs %s", mountpoint); + printf("running: %s\n", cmd); ret = system(cmd); if (ret != 0) { fprintf(stderr, "Error mounting debugfs at %s: %s\n", mountpoint, strerror(errno));