[PATCH 2/4] drm: Add dispatcher and driver identification for DRM
Dmitry V. Levin
ldv at altlinux.org
Tue Jun 9 23:10:34 UTC 2015
On Tue, Jun 09, 2015 at 01:26:42PM +0200, Patrik Jakobsson wrote:
[...]
> +static int drm_get_driver_name(struct tcb *tcp, char *name, size_t bufsize)
> +{
> + char path[PATH_MAX];
> + char link[PATH_MAX];
> + int ret;
> +
> + ret = getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1);
> + if (!ret)
> + return ret;
The return code of getfdpath() is essentially the return code of
readlink(), so the check should be the same as after readlink() below.
> +
> + snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver",
> + basename(path));
> +
> + ret = readlink(link, path, PATH_MAX - 1);
> + if (ret < 0)
> + return ret;
> +
> + path[ret] = '\0';
> + strncpy(name, basename(path), bufsize);
> +
> + return 0;
> +}
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150610/1d401aab/attachment.bin>
More information about the Strace-devel
mailing list