From: "Dmitry V. Levin" <ldv-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>
To: Patrik Jakobsson
<patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 2/4] drm: Add dispatcher and driver identification for DRM
Date: Wed, 10 Jun 2015 01:14:20 +0300 [thread overview]
Message-ID: <20150609221420.GA3210@altlinux.org> (raw)
In-Reply-To: <1433849204-4125-3-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 2550 bytes --]
On Tue, Jun 09, 2015 at 01:26:42PM +0200, Patrik Jakobsson wrote:
[...]
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -121,6 +121,7 @@ strace_SOURCES = \
> utime.c \
> utimes.c \
> v4l2.c \
> + drm.c \
> vsprintf.c \
> wait.c \
> xattr.c
Starting with v4.7-166-g7ae73a9, we keep strace_SOURCES list sorted.
> --- /dev/null
> +++ b/drm.c
[...]
> +#include "defs.h"
> +
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <linux/limits.h>
> +#include <stdint.h>
> +#include <sys/ioctl.h>
> +#include <linux/types.h>
> +#include <drm.h>
No need to include header files already included by "defs.h".
Most likely no need to include <linux/limits.h> or <linux/types.h>.
> +#define DRM_MAX_NAME_LEN 128
> +
> +inline int drm_is_priv(const unsigned int num)
> +{
> + return (_IOC_NR(num) >= DRM_COMMAND_BASE &&
> + _IOC_NR(num) < DRM_COMMAND_END);
> +}
> +
> +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;
> +
> + 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;
> +}
> +
> +int drm_is_driver(struct tcb *tcp, const char *name)
> +{
> + char drv[DRM_MAX_NAME_LEN];
> + int ret;
> +
> + ret = drm_get_driver_name(tcp, drv, DRM_MAX_NAME_LEN);
> + if (ret)
> + return 0;
> +
> + return strcmp(name, drv) == 0;
> +}
This interface will result to several getfdpath() calls per
ioctl_decode(). If the only purpose of drm_is_driver() is to help finding
the most appropriate function, let's create a table of pairs
{driver name, function} and pass this table to a function that will do a
single getfdpath() call, calculate the driver name, and choose the right
function from the table.
[...]
> @@ -284,6 +294,7 @@ ioctl_decode(struct tcb *tcp, unsigned int code, long arg)
> * d sys/des.h (possible overlap)
> * d vax/dkio.h (possible overlap)
> * d vaxuba/rxreg.h (possible overlap)
> + * d drm/drm.h
> * f sys/filio.h
> * g sunwindow/win_ioctl.h -no overlap-
> * g sunwindowdev/winioctl.c !no manifest constant! -no overlap-
This is a history, no need to patch it.
--
ldv
[-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --]
[-- Attachment #2: Type: text/plain, Size: 79 bytes --]
------------------------------------------------------------------------------
[-- Attachment #3: Type: text/plain, Size: 195 bytes --]
_______________________________________________
Strace-devel mailing list
Strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/strace-devel
next prev parent reply other threads:[~2015-06-09 22:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 11:26 [PATCH 0/4] drm: Add decoding for DRM/KMS and i915 ioctls Patrik Jakobsson
2015-06-09 11:26 ` [PATCH 1/4] drm: Add config for detecting libdrm Patrik Jakobsson
2015-06-09 11:26 ` [PATCH 2/4] drm: Add dispatcher and driver identification for DRM Patrik Jakobsson
2015-06-09 13:51 ` Gabriel Laskar
2015-06-09 14:35 ` Patrik Jakobsson
[not found] ` <1433849204-4125-3-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-06-09 22:14 ` Dmitry V. Levin [this message]
2015-06-10 11:52 ` Patrik Jakobsson
2015-06-10 23:26 ` Dmitry V. Levin
2015-06-11 14:11 ` Patrik Jakobsson
2015-06-12 23:41 ` Dmitry V. Levin
2015-06-14 11:12 ` Patrik Jakobsson
2015-06-14 21:56 ` [Intel-gfx] " Dmitry V. Levin
2015-06-09 23:10 ` Dmitry V. Levin
[not found] ` <1433849204-4125-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-06-09 11:26 ` [PATCH 3/4] drm: Add decoding of i915 ioctls Patrik Jakobsson
2015-06-09 22:35 ` Dmitry V. Levin
2015-06-10 12:45 ` Patrik Jakobsson
2015-06-10 23:27 ` Dmitry V. Levin
2015-06-11 13:34 ` Patrik Jakobsson
2015-06-12 23:48 ` Dmitry V. Levin
2015-06-14 11:10 ` Patrik Jakobsson
2015-06-09 11:26 ` [PATCH 4/4] drm: Add decoding of DRM and KMS ioctls Patrik Jakobsson
2015-06-09 13:51 ` Gabriel Laskar
2015-06-09 14:29 ` Patrik Jakobsson
2015-06-09 14:38 ` Gabriel Laskar
2015-06-09 22:55 ` Dmitry V. Levin
2015-06-09 22:46 ` Dmitry V. Levin
2015-06-10 14:27 ` Patrik Jakobsson
2015-06-09 13:51 ` [PATCH 0/4] drm: Add decoding for DRM/KMS and i915 ioctls Gabriel Laskar
[not found] ` <20150609155105.77ac6a9a-krIL5v34lyW+8jMViQwUxmazZaUMDOZU@public.gmane.org>
2015-06-09 14:36 ` Patrik Jakobsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150609221420.GA3210@altlinux.org \
--to=ldv-u2l5pomzf/vg9huczpvpmw@public.gmane.org \
--cc=intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox