From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dmitry V. Levin" Subject: Re: [PATCH 2/4] drm: Add dispatcher and driver identification for DRM Date: Wed, 10 Jun 2015 01:14:20 +0300 Message-ID: <20150609221420.GA3210@altlinux.org> References: <1433849204-4125-1-git-send-email-patrik.jakobsson@linux.intel.com> <1433849204-4125-3-git-send-email-patrik.jakobsson@linux.intel.com> Reply-To: strace development list Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3327904849133264895==" Return-path: In-Reply-To: <1433849204-4125-3-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: strace-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Patrik Jakobsson Cc: intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: intel-gfx@lists.freedesktop.org --===============3327904849133264895== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VbJkn9YxBvnuCH5J" Content-Disposition: inline --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D \ > 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include No need to include header files already included by "defs.h". Most likely no need to include or . > +#define DRM_MAX_NAME_LEN 128 > + > +inline int drm_is_priv(const unsigned int num) > +{ > + return (_IOC_NR(num) >=3D DRM_COMMAND_BASE && > + _IOC_NR(num) < DRM_COMMAND_END); > +} > + > +static int drm_get_driver_name(struct tcb *tcp, char *name, size_t bufsi= ze) > +{ > + char path[PATH_MAX]; > + char link[PATH_MAX]; > + int ret; > + > + ret =3D 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 =3D readlink(link, path, PATH_MAX - 1); > + if (ret < 0) > + return ret; > + > + path[ret] =3D '\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 =3D drm_get_driver_name(tcp, drv, DRM_MAX_NAME_LEN); > + if (ret) > + return 0; > + > + return strcmp(name, drv) =3D=3D 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. --=20 ldv --VbJkn9YxBvnuCH5J Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlV3ZTwACgkQfKvmrJ41Nh6ZbwCfQNdfEm7LcLev1L6lOEOSB8aR +fAAoLPMiU/n1dHV/JHe2oo7K9dsTY1n =kyGi -----END PGP SIGNATURE----- --VbJkn9YxBvnuCH5J-- --===============3327904849133264895== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ --===============3327904849133264895== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Strace-devel mailing list Strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/strace-devel --===============3327904849133264895==--