On Thu, Apr 20, 2017 at 11:13:47AM +0300, Abdiel Janulgue wrote:
> Signed-off-by: Abdiel Janulgue <[email protected]>
> ---
>  lib/igt_debugfs.c | 26 ++++++++++++++++++++++++++
>  lib/igt_debugfs.h |  1 +
>  2 files changed, 27 insertions(+)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 7584be5..b019c3b 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -22,6 +22,9 @@
>   *
>   */
>  
> +#ifndef ANDROID
> +#define _GNU_SOURCE
> +#endif
>  #include <inttypes.h>
>  #include <sys/stat.h>
>  #include <sys/mount.h>
> @@ -198,6 +201,29 @@ int igt_debugfs_dir(int device)
>       igt_debug("Opening debugfs directory '%s'\n", path);
>       return open(path, O_RDONLY);
>  }
> +\
> +/**
> + * igt_debugfs_path:
> + * @device: fd of the device
> + *
> + * Returns:
> + * The path to the debugfs directory corresponding to device
> + */
> +const char *igt_debugfs_path(int device)
> +{





> +     char *path = 0;
> +
> +     if (!path) {


??




--
Petri Latvala





> +             char *linkname;
> +             int debugfs;
> +             igt_assert((debugfs = igt_debugfs_dir(device)) != -1);
> +             igt_assert(path = calloc(PATH_MAX, sizeof(char)));
> +             igt_assert(asprintf(&linkname, "/proc/self/fd/%d", debugfs) != 
> -1);
> +             igt_assert(readlink(linkname, path, PATH_MAX * sizeof(char)) != 
> -1);
> +     }
> +
> +     return path;
> +}
>  
>  /**
>   * igt_debugfs_open:
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index 7b846a8..76cf409 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -204,5 +204,6 @@ void igt_enable_prefault(void);
>   */
>  int igt_get_stable_obj_count(int driver);
>  void igt_debugfs_dump(int device, const char *filename);
> +const char *igt_debugfs_path(int device);
>  
>  #endif /* __IGT_DEBUGFS_H__ */
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to