intel_stub: Wrap fcntl64

Submitted by Ian Romanick on June 6, 2019, 11:30 p.m.

Details

Message ID 20190606233034.1585-1-idr@freedesktop.org
State New
Headers show
Series "intel_stub: Wrap fcntl64" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Ian Romanick June 6, 2019, 11:30 p.m.
From: Ian Romanick <ian.d.romanick@intel.com>

This makes the wrapper work on glibc 2.29 on Fedora 30.
---
 intel_stub.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Patch hide | download patch | download mbox

diff --git a/intel_stub.c b/intel_stub.c
index 8b8db64..590792e 100644
--- a/intel_stub.c
+++ b/intel_stub.c
@@ -50,6 +50,7 @@  static int (*libc_fstat64)(int fd, struct stat64 *buf);
 static int (*libc__fxstat)(int ver, int fd, struct stat *buf);
 static int (*libc__fxstat64)(int ver, int fd, struct stat64 *buf);
 static int (*libc_fcntl)(int fd, int cmd, int param);
+static int (*libc_fcntl64)(int fd, int cmd, int param);
 static ssize_t (*libc_readlink)(const char *pathname, char *buf, size_t bufsiz);
 
 static int drm_fd = 0x0000BEEF;
@@ -198,6 +199,22 @@  fcntl(int fd, int cmd, ...)
 	return libc_fcntl(fd, cmd, param);
 }
 
+__attribute__ ((visibility ("default"))) int
+fcntl64(int fd, int cmd, ...)
+{
+	va_list args;
+	int param;
+
+	if (fd == drm_fd && cmd == F_DUPFD_CLOEXEC)
+		return drm_fd;
+
+	va_start(args, cmd);
+	param = va_arg(args, int);
+	va_end(args);
+
+	return libc_fcntl64(fd, cmd, param);
+}
+
 __attribute__ ((visibility ("default"))) void *
 mmap(void *addr, size_t len, int prot, int flags,
      int fildes, off_t off)
@@ -315,6 +332,7 @@  init(void)
 	libc_open64 = dlsym(RTLD_NEXT, "open64");
 	libc_close = dlsym(RTLD_NEXT, "close");
 	libc_fcntl = dlsym(RTLD_NEXT, "fcntl");
+	libc_fcntl64 = dlsym(RTLD_NEXT, "fcntl64");
 	libc_fstat = dlsym(RTLD_NEXT, "fstat");
 	libc_fstat64 = dlsym(RTLD_NEXT, "fstat64");
 	libc__fxstat = dlsym(RTLD_NEXT, "__fxstat");

Comments

On Fri, 7 Jun 2019 at 00:30, Ian Romanick <idr@freedesktop.org> wrote:
>
> From: Ian Romanick <ian.d.romanick@intel.com>
>
> This makes the wrapper work on glibc 2.29 on Fedora 30.
> ---
AFAICT this patch is for shader-db and looks spot on.
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

-Emil

On 6/25/19 10:23 AM, Jason Ekstrand wrote:
> I needed this patch today so I've pushed it.  FYI, we do have MRs for
> shader-db which are a bit easier to find than a needle in the hay-stack
> that is mesa-dev.

Ah... that's good to know.  After I sent this patch, I completely forgot
about it. :)

> --Jason
> 
> On Fri, Jun 7, 2019 at 11:27 AM Emil Velikov <emil.l.velikov@gmail.com
> <mailto:emil.l.velikov@gmail.com>> wrote:
> 
>     On Fri, 7 Jun 2019 at 00:30, Ian Romanick <idr@freedesktop.org
>     <mailto:idr@freedesktop.org>> wrote:
>     >
>     > From: Ian Romanick <ian.d.romanick@intel.com
>     <mailto:ian.d.romanick@intel.com>>
>     >
>     > This makes the wrapper work on glibc 2.29 on Fedora 30.
>     > ---
>     AFAICT this patch is for shader-db and looks spot on.
>     Reviewed-by: Emil Velikov <emil.velikov@collabora.com
>     <mailto:emil.velikov@collabora.com>>
> 
>     -Emil
>     _______________________________________________
>     mesa-dev mailing list
>     mesa-dev@lists.freedesktop.org <mailto:mesa-dev@lists.freedesktop.org>
>     https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>