Re: [PATCH 1/5] tools lib fs: Add helper to find mounted file systems

From: Jiri Olsa
Date: Sun Jan 25 2015 - 11:41:28 EST


On Sat, Jan 24, 2015 at 01:13:31PM -0500, Steven Rostedt wrote:

SNIP

> /* find the path to the mounted debugfs */
> const char *debugfs_find_mountpoint(void)
> {
> - const char * const *ptr;
> - char type[100];
> - FILE *fp;
> -
> if (debugfs_found)
> return (const char *)debugfs_mountpoint;
>
> - ptr = debugfs_known_mountpoints;
> - while (*ptr) {
> - if (debugfs_valid_mountpoint(*ptr) == 0) {
> - debugfs_found = true;
> - strcpy(debugfs_mountpoint, *ptr);
> - return debugfs_mountpoint;
> - }
> - ptr++;
> - }
> -
> - /* give up and parse /proc/mounts */
> - fp = fopen("/proc/mounts", "r");
> - if (fp == NULL)
> - return NULL;
> -
> - while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
> - debugfs_mountpoint, type) == 2) {
> - if (strcmp(type, "debugfs") == 0)
> - break;
> - }
> - fclose(fp);
> -
> - if (strcmp(type, "debugfs") != 0)
> - return NULL;
> -
> - debugfs_found = true;
> -
> - return debugfs_mountpoint;
> + return find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
> + debugfs_mountpoint, PATH_MAX + 1,
> + debugfs_known_mountpoints);
> }

debugfs_found is no longer set 'true' by debugfs_find_mountpoint

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/