On Tue, 9 Jun 2015 13:26:42 +0200 Patrik Jakobsson <patrik.jakobsson@xxxxxxxxxxxxxxx> wrote: > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@xxxxxxxxxxxxxxx> > --- > Makefile.am | 1 + > defs.h | 6 ++++- > drm.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > io.c | 2 +- > ioctl.c | 13 ++++++++- > 5 files changed, 107 insertions(+), 3 deletions(-) > create mode 100644 drm.c > > diff --git a/Makefile.am b/Makefile.am > index 549aebc..50d5140 100644 > --- 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 If I remember correctly source files were sorted in alphabetic order. Same remark for drm_i915.c in the next patch. (This is nitpicking) > diff --git a/defs.h b/defs.h > index 77c819c..f77330b 100644 > --- a/defs.h > +++ b/defs.h > @@ -559,7 +559,7 @@ extern const struct_ioctlent *ioctl_lookup(const unsigned int); > extern const struct_ioctlent *ioctl_next_match(const struct_ioctlent *); > extern void ioctl_print_code(const unsigned int); > extern int ioctl_decode(struct tcb *, const unsigned int, long); > -extern int ioctl_decode_command_number(const unsigned int); > +extern int ioctl_decode_command_number(struct tcb *, const unsigned int); > extern int block_ioctl(struct tcb *, const unsigned int, long); > extern int evdev_ioctl(struct tcb *, const unsigned int, long); > extern int loop_ioctl(struct tcb *, const unsigned int, long); > @@ -572,6 +572,10 @@ extern int term_ioctl(struct tcb *, const unsigned int, long); > extern int ubi_ioctl(struct tcb *, const unsigned int, long); > extern int v4l2_ioctl(struct tcb *, const unsigned int, long); > > +extern int drm_is_priv(const unsigned int); > +extern int drm_is_driver(struct tcb *tcp, const char *name); > +extern int drm_ioctl(struct tcb *, const unsigned int, long); > + > extern int tv_nz(const struct timeval *); > extern int tv_cmp(const struct timeval *, const struct timeval *); > extern double tv_float(const struct timeval *); > diff --git a/drm.c b/drm.c > new file mode 100644 > index 0000000..56ef98b > --- /dev/null > +++ b/drm.c > @@ -0,0 +1,88 @@ > +/* > + * Copyright (c) 2015 Intel Corporation > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * 3. The name of the author may not be used to endorse or promote products > + * derived from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + * > + * Authors: > + * Patrik Jakobsson <patrik.jakobsson@xxxxxxxxxxxxxxx> > + */ > + > +#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> If I remember correctly, headers are mostly sorted in strace files also > + > +#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; > +} > + > +int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg) > +{ > + return 0; > +} > diff --git a/io.c b/io.c > index 30ed578..6810a45 100644 > --- a/io.c > +++ b/io.c > @@ -391,7 +391,7 @@ SYS_FUNC(ioctl) > if (entering(tcp)) { > printfd(tcp, tcp->u_arg[0]); > tprints(", "); > - if (!ioctl_decode_command_number(tcp->u_arg[1])) { > + if (!ioctl_decode_command_number(tcp, tcp->u_arg[1])) { > iop = ioctl_lookup(tcp->u_arg[1]); > if (iop) { > tprints(iop->symbol); > diff --git a/ioctl.c b/ioctl.c > index c67d048..690e7aa 100644 > --- a/ioctl.c > +++ b/ioctl.c > @@ -181,8 +181,14 @@ hiddev_decode_number(unsigned int arg) > return 0; > } > > +static int > +drm_decode_number(struct tcb *tcp, unsigned int arg) > +{ > + return 0; > +} > + If you push drm_decode_number() inside drm.c you will have less function to export, and avoir polluting to much defs.h. For the other *_decode_number(), there was no files with the specific argument decoding attached to it, so it maked sense at that time to not have separated files for each of them (this makes me think that for evdev ioctls, we could move that part inside evdev.c.) > int > -ioctl_decode_command_number(unsigned int arg) > +ioctl_decode_command_number(struct tcb *tcp, unsigned int arg) > { > switch (_IOC_TYPE(arg)) { > case 'E': > @@ -216,6 +222,8 @@ ioctl_decode_command_number(unsigned int arg) > return 1; > } > return 0; > + case 'd': > + return drm_decode_number(tcp, arg); > default: > return 0; > } > @@ -252,6 +260,8 @@ ioctl_decode(struct tcb *tcp, unsigned int code, long arg) > return ubi_ioctl(tcp, code, arg); > case 'V': > return v4l2_ioctl(tcp, code, arg); > + case 'd': > + return drm_ioctl(tcp, code, arg); > case '=': > return ptp_ioctl(tcp, code, arg); > #ifdef HAVE_LINUX_INPUT_H > @@ -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- -- Gabriel Laskar _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx