From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dmitry V. Levin" Subject: Re: [PATCH v4 3/5] drm: Add dispatcher and driver identification for DRM Date: Tue, 8 Sep 2015 03:36:25 +0300 Message-ID: <20150908003624.GA17781@altlinux.org> References: <1440420170-13337-1-git-send-email-patrik.jakobsson@linux.intel.com> <1440420170-13337-4-git-send-email-patrik.jakobsson@linux.intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1956723097==" Return-path: Received: from pegasus3.altlinux.org (pegasus3.altlinux.org [194.107.17.103]) by gabe.freedesktop.org (Postfix) with ESMTP id DDEAC6E41E for ; Mon, 7 Sep 2015 17:36:27 -0700 (PDT) In-Reply-To: <1440420170-13337-4-git-send-email-patrik.jakobsson@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Patrik Jakobsson Cc: intel-gfx@lists.freedesktop.org, strace-devel@lists.sourceforge.net List-Id: intel-gfx@lists.freedesktop.org --===============1956723097== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GvXjxJ+pjyke8COw" Content-Disposition: inline --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 24, 2015 at 02:42:48PM +0200, Patrik Jakobsson wrote: > * Makefile.am: Add compilation of drm.c. > * defs.h: Add extern declaration of drm_ioctl when drm headers are found. > * drm.c: New file. > * ioctl.c (ioctl_decode): Dispatch drm ioctls when drm headers are found. * defs.h (drm_decode_number, drm_ioctl): New prototypes. * drm.c: New file. * Makefile.am (strace_SOURCES): Add it. * ioctl.c (ioctl_decode_command_number, ioctl_decode) [HAVE_DRM_H || HAVE_DRM_DRM_H]: Dispatch drm ioctls. > --- a/defs.h > +++ b/defs.h > @@ -612,6 +612,9 @@ extern const char *sprint_open_modes(int); > extern void print_seccomp_filter(struct tcb *tcp, unsigned long); > =20 > extern int block_ioctl(struct tcb *, const unsigned int, long); > +#if defined(HAVE_DRM_H) || defined(HAVE_DRM_DRM_H) > +extern int drm_ioctl(struct tcb *, const unsigned int, long); > +#endif I think function these prototypes could be added unconditionally. Note that v3 version of this patch also declared drm_decode_number(). > --- /dev/null > +++ b/drm.c [...] > +#include "defs.h" > + > +#if defined(HAVE_DRM_H) || defined(HAVE_DRM_DRM_H) > + > +#ifdef HAVE_DRM_H > +#include > +#else > +#include > +#endif > + > +#include Let's include before drm stuff. > +#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); > +} This function has to be static, and like other static functions, it has to be added along with its first user, otherwise the project won't build with --enable-gcc-Werror. > +static char *drm_get_driver_name(struct tcb *tcp) > +{ > + char path[PATH_MAX]; > + char link[PATH_MAX]; > + int ret; > + > + if (getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1) < 0) > + return NULL; > + > + snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", > + basename(path)); if (snprintf(link, sizeof(link), ...) >=3D sizeof(link)) return NULL; > +static void drm_free_priv(void *data) > +{ > + free(data); > +} Do we really need a wrapper for free(3)? > --- a/ioctl.c > +++ b/ioctl.c > @@ -248,6 +248,10 @@ ioctl_decode(struct tcb *tcp) > case 0x22: > return scsi_ioctl(tcp, code, arg); > #endif > +#if defined(HAVE_DRM_H) || defined(HAVE_DRM_DRM_H) > + case 'd': > + return drm_ioctl(tcp, code, arg); > +#endif > case 'L': > return loop_ioctl(tcp, code, arg); > case 'M': v3 version also patched ioctl_decode_command_number() to call drm_decode_number(). --=20 ldv --GvXjxJ+pjyke8COw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlXuLYgACgkQfKvmrJ41Nh5qyQCff3P3DRWet6Q5kyZF6uCBMyyU IEEAoIg/MjAoQ12fUBvtTDFD5k9tymcU =AFDr -----END PGP SIGNATURE----- --GvXjxJ+pjyke8COw-- --===============1956723097== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pbnRlbC1nZngK --===============1956723097==--