Re: [RFC V2 PATCH]debugfs:Fix terminology inconsistency of dir name to mount debugfs filesystem.

From: Steven Rostedt
Date: Sat May 30 2009 - 09:37:04 EST



On Sat, 30 May 2009, GeunSik Lim wrote:
> > Here's the function I use:
> >
> > #define _STR(x) x
> > #define STR(x) _STR(x)
> > #define MAX_PATH 256
> >
> > const char *find_debugfs(void)
> > {
> > Â Â Â Âstatic char debugfs[MAX_PATH+1];
> > Â Â Â Âstatic int debugfs_found;
> > Â Â Â Âchar type[100];
> > Â Â Â ÂFILE *fp;
> >
> > Â Â Â Âif (debugfs_found)
> > Â Â Â Â Â Â Â Âreturn debugfs;
> >
> >
> > Â Â Â Âif ((fp = fopen("/proc/mounts","r")) == NULL) {
> > Â Â Â Â Â Â Â Âperror("/proc/mounts");
> > Â Â Â Â Â Â Â Âreturn NULL;
> > Â Â Â Â}
> >
> > Â Â Â Âwhile (fscanf(fp, "%*s %"
> > Â Â Â Â Â Â Â Â Â Â ÂSTR(MAX_PATH)
> > Â Â Â Â Â Â Â Â Â Â Â"s %99s %*s %*d %*d\n",
> > Â Â Â Â Â Â Â Â Â Â Âdebugfs, type) == 2) {
> > Â Â Â Â Â Â Â Âif (strcmp(type, "debugfs") == 0)
> > Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> > Â Â Â Â}
> > Â Â Â Âfclose(fp);
> >
> > Â Â Â Âif (strcmp(type, "debugfs") != 0) {
> > Â Â Â Â Â Â Â Âfprintf(stderr, "debugfs not mounted");
> > Â Â Â Â Â Â Â Âreturn NULL;
> > Â Â Â Â}
> >
> > Â Â Â Âdebugfs_found = 1;
> >
> > Â Â Â Âreturn debugfs;
> > }
> >
> > This might be a good idea to show it. This is the most robust since it
> > does not hard code the debugfs directory.
> Yes, I think so. I have one opinion in the above find_debugfs() function.
> Default directory is "/sys/kernel/debug/tracing" in ftrace.txt file
> as you mentioned.
> I will append below code for "***/tracing/" directory name.
>
> int size;
> [...]
> size = MAX_PATH - strlen(debugfs);
> strncat(debugfs, "/tracing/", size);
> return debugfs;

Heh, I usually have another function to add the /tracing part. But sure,
we could do that too.

-- Steve