[{"id":5279,"web_url":"https://patchwork.libcamera.org/comment/5279/","msgid":"<249f3221-03f5-e3f1-b9bb-bf82f5e5bf8f@ideasonboard.com>","date":"2020-06-19T09:35:37","subject":"Re: [libcamera-devel] [PATCH v4] v4l2: v4l2_compat: Intercept\n\topen64, openat64, and mmap64","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Paul,\n\nOn 19/06/2020 06:31, Paul Elder wrote:\n> Some applications (eg. Firefox, Google Chrome, Skype) use open64,\n> openat64, and mmap64 instead of their non-64 versions that we currently\n> intercept. Intercept these calls as well. _LARGEFILE64_SOURCE needs to\n> be set so that the 64-bit symbols are available and not synonymous to\n> the non-64-bit versions on 64-bit systems.\n> \n> Also, since we set _FILE_OFFSET_BITS to 32 to force the various open and\n> mmap symbols that we export to not be the 64-bit versions, our dlsym to\n> get the original open and mmap calls will not automatically be converted\n> to their 64-bit versions. Since we intercept both 32-bit and 64-bit\n> versions of open and mmap, we should be using the 64-bit version to\n> service both. Fetch the 64-bit versions of openat and mmap directly.\n> \n> musl defines the 64-bit symbols as macros that are equivalent to the\n> non-64-bit symbols, so we put compile guards that check if the 64-bit\n> symbols are defined.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # Compile with musl\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nSounds good to me.\n\nDoes this now bring in functionality with those applications? or are\nthere still some issues pending to resolve?\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> ---\n> Changes in v4:\n> - fix compile guard for __open64_2 and __openat64_2 to be #ifndef open64\n>   and openat64, respectively\n> \n> Changes in v3:\n> - add __open64_2 and __openat64_2\n> \n> Changes in v2:\n> - squash intercept 64-bit calls and use 64-bit calls into\n>   this one patch\n> - use off64_t instead of __off64_t\n> - add compile guard to get musl to play nicely with the 64-bit calls\n>   coexisting with the non-64-bit calls\n> ---\n>  src/v4l2/meson.build             |  1 +\n>  src/v4l2/v4l2_camera_proxy.cpp   |  2 +-\n>  src/v4l2/v4l2_camera_proxy.h     |  3 ++-\n>  src/v4l2/v4l2_compat.cpp         | 43 ++++++++++++++++++++++++++++++++\n>  src/v4l2/v4l2_compat_manager.cpp |  6 ++---\n>  src/v4l2/v4l2_compat_manager.h   |  5 ++--\n>  6 files changed, 53 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> index 0fb941e..f2e4aaf 100644\n> --- a/src/v4l2/meson.build\n> +++ b/src/v4l2/meson.build\n> @@ -15,6 +15,7 @@ v4l2_compat_cpp_args = [\n>      # file operations, disable transparent large file support.\n>      '-U_FILE_OFFSET_BITS',\n>      '-D_FILE_OFFSET_BITS=32',\n> +    '-D_LARGEFILE64_SOURCE',\n>      '-fvisibility=hidden',\n>  ]\n>  \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 19b300f..bf47aa7 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -76,7 +76,7 @@ void V4L2CameraProxy::close()\n>  }\n>  \n>  void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags,\n> -\t\t\t    off_t offset)\n> +\t\t\t    off64_t offset)\n>  {\n>  \tLOG(V4L2Compat, Debug) << \"Servicing mmap\";\n>  \n> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> index 7c65c88..27d3e50 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -11,6 +11,7 @@\n>  #include <linux/videodev2.h>\n>  #include <map>\n>  #include <memory>\n> +#include <sys/mman.h>\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> @@ -28,7 +29,7 @@ public:\n>  \tint open(bool nonBlocking);\n>  \tvoid dup();\n>  \tvoid close();\n> -\tvoid *mmap(void *addr, size_t length, int prot, int flags, off_t offset);\n> +\tvoid *mmap(void *addr, size_t length, int prot, int flags, off64_t offset);\n>  \tint munmap(void *addr, size_t length);\n>  \n>  \tint ioctl(unsigned long request, void *arg);\n> diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> index 2a9a176..fd73381 100644\n> --- a/src/v4l2/v4l2_compat.cpp\n> +++ b/src/v4l2/v4l2_compat.cpp\n> @@ -44,6 +44,23 @@ LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)\n>  \treturn open(path, oflag);\n>  }\n>  \n> +#ifndef open64\n> +LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)\n> +{\n> +\tmode_t mode = 0;\n> +\tif (oflag & O_CREAT || oflag & O_TMPFILE)\n> +\t\textract_va_arg(mode_t, mode, oflag);\n> +\n> +\treturn V4L2CompatManager::instance()->openat(AT_FDCWD, path,\n> +\t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n> +}\n> +\n> +LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> +{\n> +\treturn open(path, oflag);\n> +}\n> +#endif\n> +\n>  LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)\n>  {\n>  \tmode_t mode = 0;\n> @@ -58,6 +75,23 @@ LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n>  \treturn openat(dirfd, path, oflag);\n>  }\n>  \n> +#ifndef openat64\n> +LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)\n> +{\n> +\tmode_t mode = 0;\n> +\tif (oflag & O_CREAT || oflag & O_TMPFILE)\n> +\t\textract_va_arg(mode_t, mode, oflag);\n> +\n> +\treturn V4L2CompatManager::instance()->openat(dirfd, path,\n> +\t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n> +}\n> +\n> +LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)\n> +{\n> +\treturn openat(dirfd, path, oflag);\n> +}\n> +#endif\n> +\n>  LIBCAMERA_PUBLIC int dup(int oldfd)\n>  {\n>  \treturn V4L2CompatManager::instance()->dup(oldfd);\n> @@ -75,6 +109,15 @@ LIBCAMERA_PUBLIC void *mmap(void *addr, size_t length, int prot, int flags,\n>  \t\t\t\t\t\t   fd, offset);\n>  }\n>  \n> +#ifndef mmap64\n> +LIBCAMERA_PUBLIC void *mmap64(void *addr, size_t length, int prot, int flags,\n> +\t\t\t      int fd, off64_t offset)\n> +{\n> +\treturn V4L2CompatManager::instance()->mmap(addr, length, prot, flags,\n> +\t\t\t\t\t\t   fd, offset);\n> +}\n> +#endif\n> +\n>  LIBCAMERA_PUBLIC int munmap(void *addr, size_t length)\n>  {\n>  \treturn V4L2CompatManager::instance()->munmap(addr, length);\n> diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> index 56533c4..8da3316 100644\n> --- a/src/v4l2/v4l2_compat_manager.cpp\n> +++ b/src/v4l2/v4l2_compat_manager.cpp\n> @@ -39,11 +39,11 @@ void get_symbol(T &func, const char *name)\n>  V4L2CompatManager::V4L2CompatManager()\n>  \t: cm_(nullptr)\n>  {\n> -\tget_symbol(fops_.openat, \"openat\");\n> +\tget_symbol(fops_.openat, \"openat64\");\n>  \tget_symbol(fops_.dup, \"dup\");\n>  \tget_symbol(fops_.close, \"close\");\n>  \tget_symbol(fops_.ioctl, \"ioctl\");\n> -\tget_symbol(fops_.mmap, \"mmap\");\n> +\tget_symbol(fops_.mmap, \"mmap64\");\n>  \tget_symbol(fops_.munmap, \"munmap\");\n>  }\n>  \n> @@ -200,7 +200,7 @@ int V4L2CompatManager::close(int fd)\n>  }\n>  \n>  void *V4L2CompatManager::mmap(void *addr, size_t length, int prot, int flags,\n> -\t\t\t      int fd, off_t offset)\n> +\t\t\t      int fd, off64_t offset)\n>  {\n>  \tV4L2CameraProxy *proxy = getProxy(fd);\n>  \tif (!proxy)\n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index 14338a5..3d4e512 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -11,6 +11,7 @@\n>  #include <fcntl.h>\n>  #include <map>\n>  #include <memory>\n> +#include <sys/mman.h>\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> @@ -30,7 +31,7 @@ public:\n>  \t\tusing close_func_t = int (*)(int fd);\n>  \t\tusing ioctl_func_t = int (*)(int fd, unsigned long request, ...);\n>  \t\tusing mmap_func_t = void *(*)(void *addr, size_t length, int prot,\n> -\t\t\t\t\t      int flags, int fd, off_t offset);\n> +\t\t\t\t\t      int flags, int fd, off64_t offset);\n>  \t\tusing munmap_func_t = int (*)(void *addr, size_t length);\n>  \n>  \t\topenat_func_t openat;\n> @@ -51,7 +52,7 @@ public:\n>  \tint dup(int oldfd);\n>  \tint close(int fd);\n>  \tvoid *mmap(void *addr, size_t length, int prot, int flags,\n> -\t\t   int fd, off_t offset);\n> +\t\t   int fd, off64_t offset);\n>  \tint munmap(void *addr, size_t length);\n>  \tint ioctl(int fd, unsigned long request, void *arg);\n>  \n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A760603BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 11:35:42 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BAFAA556;\n\tFri, 19 Jun 2020 11:35:41 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XC6vN0yR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592559341;\n\tbh=g6NxPfe6vW0c8nJhkhv1/NHKHcGTXxT8MVodGImA7G8=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=XC6vN0yRh+nK4GAf5dAFCJUA2E6Evv1JX+/iBoMkbUN49SRQaXgjhqT/M2+BVdKuO\n\t0iAWhDY1GXhFwtWa7ynMCEi31ebXoxk4T0h2BiGLFsUsT5cwWFmvTLELblFoV/GM3X\n\tqWqtgG+BjVZMslAjgyq9aY+/84iRGyA/O2+QC9no=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20200619053117.17865-1-paul.elder@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRy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zL65qkh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz\n\tPZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<249f3221-03f5-e3f1-b9bb-bf82f5e5bf8f@ideasonboard.com>","Date":"Fri, 19 Jun 2020 10:35:37 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.8.0","MIME-Version":"1.0","In-Reply-To":"<20200619053117.17865-1-paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v4] v4l2: v4l2_compat: Intercept\n\topen64, openat64, and mmap64","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 19 Jun 2020 09:35:42 -0000"}},{"id":5282,"web_url":"https://patchwork.libcamera.org/comment/5282/","msgid":"<20200619111942.GE2073@jade.amanokami.net>","date":"2020-06-19T11:19:42","subject":"Re: [libcamera-devel] [PATCH v4] v4l2: v4l2_compat: Intercept\n\topen64, openat64, and mmap64","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the review.\n\nOn Fri, Jun 19, 2020 at 10:35:37AM +0100, Kieran Bingham wrote:\n> Hi Paul,\n> \n> On 19/06/2020 06:31, Paul Elder wrote:\n> > Some applications (eg. Firefox, Google Chrome, Skype) use open64,\n> > openat64, and mmap64 instead of their non-64 versions that we currently\n> > intercept. Intercept these calls as well. _LARGEFILE64_SOURCE needs to\n> > be set so that the 64-bit symbols are available and not synonymous to\n> > the non-64-bit versions on 64-bit systems.\n> > \n> > Also, since we set _FILE_OFFSET_BITS to 32 to force the various open and\n> > mmap symbols that we export to not be the 64-bit versions, our dlsym to\n> > get the original open and mmap calls will not automatically be converted\n> > to their 64-bit versions. Since we intercept both 32-bit and 64-bit\n> > versions of open and mmap, we should be using the 64-bit version to\n> > service both. Fetch the 64-bit versions of openat and mmap directly.\n> > \n> > musl defines the 64-bit symbols as macros that are equivalent to the\n> > non-64-bit symbols, so we put compile guards that check if the 64-bit\n> > symbols are defined.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # Compile with musl\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> Sounds good to me.\n> \n> Does this now bring in functionality with those applications? or are\n> there still some issues pending to resolve?\n\nUnfortunately, not yet. The patches to support v4l2-compliance gets us\nmost of the way there, and I think there are still a few tweaks left\nneeded for Firefox at least. Chrome and Skype are different beasts :/\n\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n\n\nThanks,\n\nPaul\n\n> > ---\n> > Changes in v4:\n> > - fix compile guard for __open64_2 and __openat64_2 to be #ifndef open64\n> >   and openat64, respectively\n> > \n> > Changes in v3:\n> > - add __open64_2 and __openat64_2\n> > \n> > Changes in v2:\n> > - squash intercept 64-bit calls and use 64-bit calls into\n> >   this one patch\n> > - use off64_t instead of __off64_t\n> > - add compile guard to get musl to play nicely with the 64-bit calls\n> >   coexisting with the non-64-bit calls\n> > ---\n> >  src/v4l2/meson.build             |  1 +\n> >  src/v4l2/v4l2_camera_proxy.cpp   |  2 +-\n> >  src/v4l2/v4l2_camera_proxy.h     |  3 ++-\n> >  src/v4l2/v4l2_compat.cpp         | 43 ++++++++++++++++++++++++++++++++\n> >  src/v4l2/v4l2_compat_manager.cpp |  6 ++---\n> >  src/v4l2/v4l2_compat_manager.h   |  5 ++--\n> >  6 files changed, 53 insertions(+), 7 deletions(-)\n> > \n> > diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> > index 0fb941e..f2e4aaf 100644\n> > --- a/src/v4l2/meson.build\n> > +++ b/src/v4l2/meson.build\n> > @@ -15,6 +15,7 @@ v4l2_compat_cpp_args = [\n> >      # file operations, disable transparent large file support.\n> >      '-U_FILE_OFFSET_BITS',\n> >      '-D_FILE_OFFSET_BITS=32',\n> > +    '-D_LARGEFILE64_SOURCE',\n> >      '-fvisibility=hidden',\n> >  ]\n> >  \n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index 19b300f..bf47aa7 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -76,7 +76,7 @@ void V4L2CameraProxy::close()\n> >  }\n> >  \n> >  void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags,\n> > -\t\t\t    off_t offset)\n> > +\t\t\t    off64_t offset)\n> >  {\n> >  \tLOG(V4L2Compat, Debug) << \"Servicing mmap\";\n> >  \n> > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> > index 7c65c88..27d3e50 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.h\n> > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > @@ -11,6 +11,7 @@\n> >  #include <linux/videodev2.h>\n> >  #include <map>\n> >  #include <memory>\n> > +#include <sys/mman.h>\n> >  #include <sys/types.h>\n> >  #include <vector>\n> >  \n> > @@ -28,7 +29,7 @@ public:\n> >  \tint open(bool nonBlocking);\n> >  \tvoid dup();\n> >  \tvoid close();\n> > -\tvoid *mmap(void *addr, size_t length, int prot, int flags, off_t offset);\n> > +\tvoid *mmap(void *addr, size_t length, int prot, int flags, off64_t offset);\n> >  \tint munmap(void *addr, size_t length);\n> >  \n> >  \tint ioctl(unsigned long request, void *arg);\n> > diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> > index 2a9a176..fd73381 100644\n> > --- a/src/v4l2/v4l2_compat.cpp\n> > +++ b/src/v4l2/v4l2_compat.cpp\n> > @@ -44,6 +44,23 @@ LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)\n> >  \treturn open(path, oflag);\n> >  }\n> >  \n> > +#ifndef open64\n> > +LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)\n> > +{\n> > +\tmode_t mode = 0;\n> > +\tif (oflag & O_CREAT || oflag & O_TMPFILE)\n> > +\t\textract_va_arg(mode_t, mode, oflag);\n> > +\n> > +\treturn V4L2CompatManager::instance()->openat(AT_FDCWD, path,\n> > +\t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n> > +}\n> > +\n> > +LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> > +{\n> > +\treturn open(path, oflag);\n> > +}\n> > +#endif\n> > +\n> >  LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)\n> >  {\n> >  \tmode_t mode = 0;\n> > @@ -58,6 +75,23 @@ LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n> >  \treturn openat(dirfd, path, oflag);\n> >  }\n> >  \n> > +#ifndef openat64\n> > +LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)\n> > +{\n> > +\tmode_t mode = 0;\n> > +\tif (oflag & O_CREAT || oflag & O_TMPFILE)\n> > +\t\textract_va_arg(mode_t, mode, oflag);\n> > +\n> > +\treturn V4L2CompatManager::instance()->openat(dirfd, path,\n> > +\t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n> > +}\n> > +\n> > +LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)\n> > +{\n> > +\treturn openat(dirfd, path, oflag);\n> > +}\n> > +#endif\n> > +\n> >  LIBCAMERA_PUBLIC int dup(int oldfd)\n> >  {\n> >  \treturn V4L2CompatManager::instance()->dup(oldfd);\n> > @@ -75,6 +109,15 @@ LIBCAMERA_PUBLIC void *mmap(void *addr, size_t length, int prot, int flags,\n> >  \t\t\t\t\t\t   fd, offset);\n> >  }\n> >  \n> > +#ifndef mmap64\n> > +LIBCAMERA_PUBLIC void *mmap64(void *addr, size_t length, int prot, int flags,\n> > +\t\t\t      int fd, off64_t offset)\n> > +{\n> > +\treturn V4L2CompatManager::instance()->mmap(addr, length, prot, flags,\n> > +\t\t\t\t\t\t   fd, offset);\n> > +}\n> > +#endif\n> > +\n> >  LIBCAMERA_PUBLIC int munmap(void *addr, size_t length)\n> >  {\n> >  \treturn V4L2CompatManager::instance()->munmap(addr, length);\n> > diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> > index 56533c4..8da3316 100644\n> > --- a/src/v4l2/v4l2_compat_manager.cpp\n> > +++ b/src/v4l2/v4l2_compat_manager.cpp\n> > @@ -39,11 +39,11 @@ void get_symbol(T &func, const char *name)\n> >  V4L2CompatManager::V4L2CompatManager()\n> >  \t: cm_(nullptr)\n> >  {\n> > -\tget_symbol(fops_.openat, \"openat\");\n> > +\tget_symbol(fops_.openat, \"openat64\");\n> >  \tget_symbol(fops_.dup, \"dup\");\n> >  \tget_symbol(fops_.close, \"close\");\n> >  \tget_symbol(fops_.ioctl, \"ioctl\");\n> > -\tget_symbol(fops_.mmap, \"mmap\");\n> > +\tget_symbol(fops_.mmap, \"mmap64\");\n> >  \tget_symbol(fops_.munmap, \"munmap\");\n> >  }\n> >  \n> > @@ -200,7 +200,7 @@ int V4L2CompatManager::close(int fd)\n> >  }\n> >  \n> >  void *V4L2CompatManager::mmap(void *addr, size_t length, int prot, int flags,\n> > -\t\t\t      int fd, off_t offset)\n> > +\t\t\t      int fd, off64_t offset)\n> >  {\n> >  \tV4L2CameraProxy *proxy = getProxy(fd);\n> >  \tif (!proxy)\n> > diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> > index 14338a5..3d4e512 100644\n> > --- a/src/v4l2/v4l2_compat_manager.h\n> > +++ b/src/v4l2/v4l2_compat_manager.h\n> > @@ -11,6 +11,7 @@\n> >  #include <fcntl.h>\n> >  #include <map>\n> >  #include <memory>\n> > +#include <sys/mman.h>\n> >  #include <sys/types.h>\n> >  #include <vector>\n> >  \n> > @@ -30,7 +31,7 @@ public:\n> >  \t\tusing close_func_t = int (*)(int fd);\n> >  \t\tusing ioctl_func_t = int (*)(int fd, unsigned long request, ...);\n> >  \t\tusing mmap_func_t = void *(*)(void *addr, size_t length, int prot,\n> > -\t\t\t\t\t      int flags, int fd, off_t offset);\n> > +\t\t\t\t\t      int flags, int fd, off64_t offset);\n> >  \t\tusing munmap_func_t = int (*)(void *addr, size_t length);\n> >  \n> >  \t\topenat_func_t openat;\n> > @@ -51,7 +52,7 @@ public:\n> >  \tint dup(int oldfd);\n> >  \tint close(int fd);\n> >  \tvoid *mmap(void *addr, size_t length, int prot, int flags,\n> > -\t\t   int fd, off_t offset);\n> > +\t\t   int fd, off64_t offset);\n> >  \tint munmap(void *addr, size_t length);\n> >  \tint ioctl(int fd, unsigned long request, void *arg);\n> >  \n> > \n> \n> -- \n> Regards\n> --\n> Kieran","headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6BEAF60103\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 13:19:50 +0200 (CEST)","from jade.amanokami.net (unknown\n\t[IPv6:2400:4051:61:600:e972:d773:e99a:4f79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EDE72552;\n\tFri, 19 Jun 2020 13:19:48 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"oSYbTd/z\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592565590;\n\tbh=v9GPNhoyiIChwbf4809KRI/+uA2MD9AsnnHyDe2+qiA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=oSYbTd/z6QDxRwouMzzWu38csb7U9uY/sCJrRtioNEYtHQGOcbhexc/OxAN0BNYwY\n\tvUHMdKPp5FNv+a/omexc7AAekDhHpngPM/pyH7AAg1oyoK0uZgBUzhpajJxQmPgmCC\n\t45kM96G83NAxxMvo78ALVJOpc0xHFm+ulS1uoU6M=","Date":"Fri, 19 Jun 2020 20:19:42 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200619111942.GE2073@jade.amanokami.net>","References":"<20200619053117.17865-1-paul.elder@ideasonboard.com>\n\t<249f3221-03f5-e3f1-b9bb-bf82f5e5bf8f@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<249f3221-03f5-e3f1-b9bb-bf82f5e5bf8f@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4] v4l2: v4l2_compat: Intercept\n\topen64, openat64, and mmap64","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 19 Jun 2020 11:19:50 -0000"}},{"id":5322,"web_url":"https://patchwork.libcamera.org/comment/5322/","msgid":"<775cac68-9e72-55ad-d9b6-fe638977e151@ideasonboard.com>","date":"2020-06-22T09:14:02","subject":"Re: [libcamera-devel] [PATCH v4] v4l2: v4l2_compat: Intercept\n\topen64, openat64, and mmap64","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Paul,\n\nOn 19/06/2020 06:31, Paul Elder wrote:\n> Some applications (eg. Firefox, Google Chrome, Skype) use open64,\n> openat64, and mmap64 instead of their non-64 versions that we currently\n> intercept. Intercept these calls as well. _LARGEFILE64_SOURCE needs to\n> be set so that the 64-bit symbols are available and not synonymous to\n> the non-64-bit versions on 64-bit systems.\n> \n> Also, since we set _FILE_OFFSET_BITS to 32 to force the various open and\n> mmap symbols that we export to not be the 64-bit versions, our dlsym to\n> get the original open and mmap calls will not automatically be converted\n> to their 64-bit versions. Since we intercept both 32-bit and 64-bit\n> versions of open and mmap, we should be using the 64-bit version to\n> service both. Fetch the 64-bit versions of openat and mmap directly.\n> \n> musl defines the 64-bit symbols as macros that are equivalent to the\n> non-64-bit symbols, so we put compile guards that check if the 64-bit\n> symbols are defined.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # Compile with musl\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> ---\n> Changes in v4:\n> - fix compile guard for __open64_2 and __openat64_2 to be #ifndef open64\n>   and openat64, respectively\n> \n> Changes in v3:\n> - add __open64_2 and __openat64_2\n> \n> Changes in v2:\n> - squash intercept 64-bit calls and use 64-bit calls into\n>   this one patch\n> - use off64_t instead of __off64_t\n> - add compile guard to get musl to play nicely with the 64-bit calls\n>   coexisting with the non-64-bit calls\n> ---\n>  src/v4l2/meson.build             |  1 +\n>  src/v4l2/v4l2_camera_proxy.cpp   |  2 +-\n>  src/v4l2/v4l2_camera_proxy.h     |  3 ++-\n>  src/v4l2/v4l2_compat.cpp         | 43 ++++++++++++++++++++++++++++++++\n>  src/v4l2/v4l2_compat_manager.cpp |  6 ++---\n>  src/v4l2/v4l2_compat_manager.h   |  5 ++--\n>  6 files changed, 53 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> index 0fb941e..f2e4aaf 100644\n> --- a/src/v4l2/meson.build\n> +++ b/src/v4l2/meson.build\n> @@ -15,6 +15,7 @@ v4l2_compat_cpp_args = [\n>      # file operations, disable transparent large file support.\n>      '-U_FILE_OFFSET_BITS',\n>      '-D_FILE_OFFSET_BITS=32',\n> +    '-D_LARGEFILE64_SOURCE',\n>      '-fvisibility=hidden',\n>  ]\n>  \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 19b300f..bf47aa7 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -76,7 +76,7 @@ void V4L2CameraProxy::close()\n>  }\n>  \n>  void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags,\n> -\t\t\t    off_t offset)\n> +\t\t\t    off64_t offset)\n>  {\n>  \tLOG(V4L2Compat, Debug) << \"Servicing mmap\";\n\n\nThis change has introduced the following coverity warning.\n\nPlease use the tag \"Reported-by: Coverity CID=292401\" if you fix this issue.\n\n--\nKieran\n\n> \n> New defect(s) Reported-by: Coverity Scan\n> Showing 1 of 1 defect(s)\n> \n> \n> ** CID 292401:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)\n> /home/linuxembedded/iob/libcamera/libcamera-daily/src/v4l2/v4l2_camera_proxy.cpp: 90 in V4L2CameraProxy::mmap(void *, unsigned long, int, int, long)()\n> \n> \n> ________________________________________________________________________________________________________\n> *** CID 292401:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)\n> /home/linuxembedded/iob/libcamera/libcamera-daily/src/v4l2/v4l2_camera_proxy.cpp: 90 in V4L2CameraProxy::mmap(void *, unsigned long, int, int, long)()\n> 84     \tif (prot != (PROT_READ | PROT_WRITE)) {\n> 85     \t\terrno = EINVAL;\n> 86     \t\treturn MAP_FAILED;\n> 87     \t}\n> 88     \n> 89     \tunsigned int index = offset / sizeimage_;\n>>>>     CID 292401:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)\n>>>>     Potentially overflowing expression \"index * this->sizeimage_\" with type \"unsigned int\" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type \"off64_t\" (64 bits, signed).\n> 90     \tif (static_cast<off_t>(index * sizeimage_) != offset ||\n> 91     \t    length != sizeimage_) {\n> 92     \t\terrno = EINVAL;\n> 93     \t\treturn MAP_FAILED;\n> 94     \t}\n> 95     \n\n--\nKieran\n\n\n\n>  \n> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> index 7c65c88..27d3e50 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -11,6 +11,7 @@\n>  #include <linux/videodev2.h>\n>  #include <map>\n>  #include <memory>\n> +#include <sys/mman.h>\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> @@ -28,7 +29,7 @@ public:\n>  \tint open(bool nonBlocking);\n>  \tvoid dup();\n>  \tvoid close();\n> -\tvoid *mmap(void *addr, size_t length, int prot, int flags, off_t offset);\n> +\tvoid *mmap(void *addr, size_t length, int prot, int flags, off64_t offset);\n>  \tint munmap(void *addr, size_t length);\n>  \n>  \tint ioctl(unsigned long request, void *arg);\n> diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> index 2a9a176..fd73381 100644\n> --- a/src/v4l2/v4l2_compat.cpp\n> +++ b/src/v4l2/v4l2_compat.cpp\n> @@ -44,6 +44,23 @@ LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)\n>  \treturn open(path, oflag);\n>  }\n>  \n> +#ifndef open64\n> +LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)\n> +{\n> +\tmode_t mode = 0;\n> +\tif (oflag & O_CREAT || oflag & O_TMPFILE)\n> +\t\textract_va_arg(mode_t, mode, oflag);\n> +\n> +\treturn V4L2CompatManager::instance()->openat(AT_FDCWD, path,\n> +\t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n> +}\n> +\n> +LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> +{\n> +\treturn open(path, oflag);\n> +}\n> +#endif\n> +\n>  LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)\n>  {\n>  \tmode_t mode = 0;\n> @@ -58,6 +75,23 @@ LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n>  \treturn openat(dirfd, path, oflag);\n>  }\n>  \n> +#ifndef openat64\n> +LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)\n> +{\n> +\tmode_t mode = 0;\n> +\tif (oflag & O_CREAT || oflag & O_TMPFILE)\n> +\t\textract_va_arg(mode_t, mode, oflag);\n> +\n> +\treturn V4L2CompatManager::instance()->openat(dirfd, path,\n> +\t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n> +}\n> +\n> +LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)\n> +{\n> +\treturn openat(dirfd, path, oflag);\n> +}\n> +#endif\n> +\n>  LIBCAMERA_PUBLIC int dup(int oldfd)\n>  {\n>  \treturn V4L2CompatManager::instance()->dup(oldfd);\n> @@ -75,6 +109,15 @@ LIBCAMERA_PUBLIC void *mmap(void *addr, size_t length, int prot, int flags,\n>  \t\t\t\t\t\t   fd, offset);\n>  }\n>  \n> +#ifndef mmap64\n> +LIBCAMERA_PUBLIC void *mmap64(void *addr, size_t length, int prot, int flags,\n> +\t\t\t      int fd, off64_t offset)\n> +{\n> +\treturn V4L2CompatManager::instance()->mmap(addr, length, prot, flags,\n> +\t\t\t\t\t\t   fd, offset);\n> +}\n> +#endif\n> +\n>  LIBCAMERA_PUBLIC int munmap(void *addr, size_t length)\n>  {\n>  \treturn V4L2CompatManager::instance()->munmap(addr, length);\n> diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> index 56533c4..8da3316 100644\n> --- a/src/v4l2/v4l2_compat_manager.cpp\n> +++ b/src/v4l2/v4l2_compat_manager.cpp\n> @@ -39,11 +39,11 @@ void get_symbol(T &func, const char *name)\n>  V4L2CompatManager::V4L2CompatManager()\n>  \t: cm_(nullptr)\n>  {\n> -\tget_symbol(fops_.openat, \"openat\");\n> +\tget_symbol(fops_.openat, \"openat64\");\n>  \tget_symbol(fops_.dup, \"dup\");\n>  \tget_symbol(fops_.close, \"close\");\n>  \tget_symbol(fops_.ioctl, \"ioctl\");\n> -\tget_symbol(fops_.mmap, \"mmap\");\n> +\tget_symbol(fops_.mmap, \"mmap64\");\n>  \tget_symbol(fops_.munmap, \"munmap\");\n>  }\n>  \n> @@ -200,7 +200,7 @@ int V4L2CompatManager::close(int fd)\n>  }\n>  \n>  void *V4L2CompatManager::mmap(void *addr, size_t length, int prot, int flags,\n> -\t\t\t      int fd, off_t offset)\n> +\t\t\t      int fd, off64_t offset)\n>  {\n>  \tV4L2CameraProxy *proxy = getProxy(fd);\n>  \tif (!proxy)\n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index 14338a5..3d4e512 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -11,6 +11,7 @@\n>  #include <fcntl.h>\n>  #include <map>\n>  #include <memory>\n> +#include <sys/mman.h>\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> @@ -30,7 +31,7 @@ public:\n>  \t\tusing close_func_t = int (*)(int fd);\n>  \t\tusing ioctl_func_t = int (*)(int fd, unsigned long request, ...);\n>  \t\tusing mmap_func_t = void *(*)(void *addr, size_t length, int prot,\n> -\t\t\t\t\t      int flags, int fd, off_t offset);\n> +\t\t\t\t\t      int flags, int fd, off64_t offset);\n>  \t\tusing munmap_func_t = int (*)(void *addr, size_t length);\n>  \n>  \t\topenat_func_t openat;\n> @@ -51,7 +52,7 @@ public:\n>  \tint dup(int oldfd);\n>  \tint close(int fd);\n>  \tvoid *mmap(void *addr, size_t length, int prot, int flags,\n> -\t\t   int fd, off_t offset);\n> +\t\t   int fd, off64_t offset);\n>  \tint munmap(void *addr, size_t length);\n>  \tint ioctl(int fd, unsigned long request, void *arg);\n>  \n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ACA56603BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 11:14:06 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 575D830D;\n\tMon, 22 Jun 2020 11:14:05 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AGeUrHXK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592817245;\n\tbh=lCjraccZqEt/iS+LSF/UxrybkwLJpVFHQpb0zRZ/hcU=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=AGeUrHXKjygX/ybReoX8y/SKFpy7dECufkaELe3fT8eR9mJcedYu1YFLXLq9FXeL3\n\tf0HdrfELpL4XdzzKAv54kjnsrOD4xiJvFFMz4r6LkfTnKDSfX+wWGKIwh0Brgc3K1x\n\t/IIVZ/M8Ce1Jc0+0bnB4mm0sNCWL788ST9N9XzDM=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20200619053117.17865-1-paul.elder@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tm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"<775cac68-9e72-55ad-d9b6-fe638977e151@ideasonboard.com>","Date":"Mon, 22 Jun 2020 10:14:02 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.8.0","MIME-Version":"1.0","In-Reply-To":"<20200619053117.17865-1-paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v4] v4l2: v4l2_compat: Intercept\n\topen64, openat64, and mmap64","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 22 Jun 2020 09:14:06 -0000"}}]