[{"id":37871,"web_url":"https://patchwork.libcamera.org/comment/37871/","msgid":"<176908671396.1693075.13734760391598396533@ping.linuxembedded.co.uk>","date":"2026-01-22T12:58:33","subject":"Re: [PATCH] v4l2: v4l2_compat: Handle __ioctl_time64","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2026-01-22 12:10:15)\n> On 32-bit systems, ioctl is redirected to __ioctl_time64, so the latter\n> needs to be intercepted and handled as well. Add support for this.\n> \n> Bug: https://gitlab.freedesktop.org/camera/libcamera/-/issues/290\n\nI think we've switched to Closes: now ?\n\nBut best I can tell this all looks reasonable and fixes and issue so:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/v4l2/v4l2_compat.cpp         | 21 +++++++++++++++++++++\n>  src/v4l2/v4l2_compat_manager.cpp | 10 ++++++++++\n>  src/v4l2/v4l2_compat_manager.h   |  2 ++\n>  3 files changed, 33 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> index ff833f571bde..10421cef76f4 100644\n> --- a/src/v4l2/v4l2_compat.cpp\n> +++ b/src/v4l2/v4l2_compat.cpp\n> @@ -165,4 +165,25 @@ LIBCAMERA_PUBLIC int ioctl(int fd, unsigned long request, ...)\n>         return V4L2CompatManager::instance()->ioctl(fd, request, arg);\n>  }\n>  \n> +/*\n> + * __USE_TIME64_REDIRECTS redirects ioctl to __ioctl_time64. Disable the\n> + * -Wmissing-declarations warnings, as the functions won't be declared if\n> + *  __USE_TIME64_REDIRECTS is not in use.\n> + */\n> +#pragma GCC diagnostic push\n> +#pragma GCC diagnostic ignored \"-Wmissing-declarations\"\n> +\n> +#if HAVE_POSIX_IOCTL\n> +LIBCAMERA_PUBLIC int __ioctl_time64(int fd, int request, ...)\n> +#else\n> +LIBCAMERA_PUBLIC int __ioctl_time64(int fd, unsigned long request, ...)\n> +#endif\n> +{\n> +       void *arg;\n> +       extract_va_arg(void *, arg, request);\n> +\n> +       return V4L2CompatManager::instance()->ioctl_time64(fd, request, arg);\n> +}\n> +\n> +#pragma GCC diagnostic pop\n>  }\n> diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> index f53fb300dde8..4303883712d6 100644\n> --- a/src/v4l2/v4l2_compat_manager.cpp\n> +++ b/src/v4l2/v4l2_compat_manager.cpp\n> @@ -46,6 +46,7 @@ V4L2CompatManager::V4L2CompatManager()\n>         get_symbol(fops_.dup, \"dup\");\n>         get_symbol(fops_.close, \"close\");\n>         get_symbol(fops_.ioctl, \"ioctl\");\n> +       get_symbol(fops_.ioctl_time64, \"__ioctl_time64\");\n>         get_symbol(fops_.mmap, \"mmap64\");\n>         get_symbol(fops_.munmap, \"munmap\");\n>  }\n> @@ -249,3 +250,12 @@ int V4L2CompatManager::ioctl(int fd, unsigned long request, void *arg)\n>  \n>         return file->proxy()->ioctl(file.get(), request, arg);\n>  }\n> +\n> +int V4L2CompatManager::ioctl_time64(int fd, unsigned long request, void *arg)\n> +{\n> +       std::shared_ptr<V4L2CameraFile> file = cameraFile(fd);\n> +       if (!file)\n> +               return fops_.ioctl_time64(fd, request, arg);\n> +\n> +       return file->proxy()->ioctl(file.get(), request, arg);\n> +}\n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index f7c6f1228282..f713f2333500 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -34,6 +34,7 @@ public:\n>                 dup_func_t dup;\n>                 close_func_t close;\n>                 ioctl_func_t ioctl;\n> +               ioctl_func_t ioctl_time64;\n>                 mmap_func_t mmap;\n>                 munmap_func_t munmap;\n>         };\n> @@ -50,6 +51,7 @@ public:\n>                    int fd, off64_t offset);\n>         int munmap(void *addr, size_t length);\n>         int ioctl(int fd, unsigned long request, void *arg);\n> +       int ioctl_time64(int fd, unsigned long request, void *arg);\n>  \n>  private:\n>         V4L2CompatManager();\n> -- \n> 2.47.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A5AD3BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jan 2026 12:58:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 027B961FBB;\n\tThu, 22 Jan 2026 13:58:39 +0100 (CET)","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 182FD61F84\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jan 2026 13:58:37 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4127C324;\n\tThu, 22 Jan 2026 13:58:04 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XLu4a7R+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769086684;\n\tbh=fEGifwHoyZljZ473zlQEeFZLqBVbvgZD97A8DnmMEHs=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=XLu4a7R+Cv+u6arJGSBfByeT5qINzD1iqvvzKM8sKp3sajjXQQ2kVMhhU2pbsxWLw\n\tvnm41ZZVXIl9UXa4rz8EsWQJSMofx9rHb1FUBskB7PQ/BA3OfqozPYu8XiRzrR4jB2\n\twrowHHGpQ2nYZKUGYQbtWE0YE6pxIoJDVC6qDl24=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260122121015.3842322-1-paul.elder@ideasonboard.com>","References":"<20260122121015.3842322-1-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH] v4l2: v4l2_compat: Handle __ioctl_time64","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 22 Jan 2026 12:58:33 +0000","Message-ID":"<176908671396.1693075.13734760391598396533@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37890,"web_url":"https://patchwork.libcamera.org/comment/37890/","msgid":"<88aa1b20-f1ab-4fd5-9abe-e0a9e741aa08@ideasonboard.com>","date":"2026-01-22T17:43:53","subject":"Re: [PATCH] v4l2: v4l2_compat: Handle __ioctl_time64","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 22. 13:10 keltezéssel, Paul Elder írta:\n> On 32-bit systems, ioctl is redirected to __ioctl_time64, so the latter\n> needs to be intercepted and handled as well. Add support for this.\n> \n> Bug: https://gitlab.freedesktop.org/camera/libcamera/-/issues/290\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n\nI am afraid I was too optimistic in my comment in the issue tracker. :(\nAt least `v4l2_buffer::timestamp` does depends on the size of time.\n(As well as `v4l2_event::timestamp`, but that is not relevant here.)\n\nWhich means that even with this change `VIDIOC_{QUERY,Q,DQ}BUF` do not work\nvia __ioctl_time64.\n\n\n>   src/v4l2/v4l2_compat.cpp         | 21 +++++++++++++++++++++\n>   src/v4l2/v4l2_compat_manager.cpp | 10 ++++++++++\n>   src/v4l2/v4l2_compat_manager.h   |  2 ++\n>   3 files changed, 33 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> index ff833f571bde..10421cef76f4 100644\n> --- a/src/v4l2/v4l2_compat.cpp\n> +++ b/src/v4l2/v4l2_compat.cpp\n> @@ -165,4 +165,25 @@ LIBCAMERA_PUBLIC int ioctl(int fd, unsigned long request, ...)\n>   \treturn V4L2CompatManager::instance()->ioctl(fd, request, arg);\n>   }\n>   \n> +/*\n> + * __USE_TIME64_REDIRECTS redirects ioctl to __ioctl_time64. Disable the\n> + * -Wmissing-declarations warnings, as the functions won't be declared if\n> + *  __USE_TIME64_REDIRECTS is not in use.\n> + */\n> +#pragma GCC diagnostic push\n> +#pragma GCC diagnostic ignored \"-Wmissing-declarations\"\n> +\n> +#if HAVE_POSIX_IOCTL\n> +LIBCAMERA_PUBLIC int __ioctl_time64(int fd, int request, ...)\n> +#else\n> +LIBCAMERA_PUBLIC int __ioctl_time64(int fd, unsigned long request, ...)\n> +#endif\n> +{\n> +\tvoid *arg;\n> +\textract_va_arg(void *, arg, request);\n> +\n> +\treturn V4L2CompatManager::instance()->ioctl_time64(fd, request, arg);\n> +}\n> +\n> +#pragma GCC diagnostic pop\n>   }\n> diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> index f53fb300dde8..4303883712d6 100644\n> --- a/src/v4l2/v4l2_compat_manager.cpp\n> +++ b/src/v4l2/v4l2_compat_manager.cpp\n> @@ -46,6 +46,7 @@ V4L2CompatManager::V4L2CompatManager()\n>   \tget_symbol(fops_.dup, \"dup\");\n>   \tget_symbol(fops_.close, \"close\");\n>   \tget_symbol(fops_.ioctl, \"ioctl\");\n> +\tget_symbol(fops_.ioctl_time64, \"__ioctl_time64\");\n>   \tget_symbol(fops_.mmap, \"mmap64\");\n>   \tget_symbol(fops_.munmap, \"munmap\");\n>   }\n> @@ -249,3 +250,12 @@ int V4L2CompatManager::ioctl(int fd, unsigned long request, void *arg)\n>   \n>   \treturn file->proxy()->ioctl(file.get(), request, arg);\n>   }\n> +\n> +int V4L2CompatManager::ioctl_time64(int fd, unsigned long request, void *arg)\n> +{\n> +\tstd::shared_ptr<V4L2CameraFile> file = cameraFile(fd);\n> +\tif (!file)\n> +\t\treturn fops_.ioctl_time64(fd, request, arg);\n> +\n> +\treturn file->proxy()->ioctl(file.get(), request, arg);\n> +}\n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index f7c6f1228282..f713f2333500 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -34,6 +34,7 @@ public:\n>   \t\tdup_func_t dup;\n>   \t\tclose_func_t close;\n>   \t\tioctl_func_t ioctl;\n> +\t\tioctl_func_t ioctl_time64;\n>   \t\tmmap_func_t mmap;\n>   \t\tmunmap_func_t munmap;\n>   \t};\n> @@ -50,6 +51,7 @@ public:\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> +\tint ioctl_time64(int fd, unsigned long request, void *arg);\n>   \n>   private:\n>   \tV4L2CompatManager();","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E4173C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jan 2026 17:43:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A6EBC61FC5;\n\tThu, 22 Jan 2026 18:43:58 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA1A561FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jan 2026 18:43:56 +0100 (CET)","from [192.168.33.25] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 05485460;\n\tThu, 22 Jan 2026 18:43:23 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Kwe/5EHa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769103804;\n\tbh=o2mNE71BpRgTcQ7wuamO4UEoaWO689zbQ8whnfzpW5E=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=Kwe/5EHazEGph5ZGiXJuFCQ9auR63gqco5IUMaM9KP+SkAV0v04IBBxM32gHGBwbp\n\tmwtRroRl6HWtT+V8WvPcBdw9WvDjXgm7gZicpVN1p7nijP3rXySid5K09pa61maFSJ\n\tgU0/bGH4o1ek3CIkQxOcKwhXDH/wZl+MXQtwwmQ8=","Message-ID":"<88aa1b20-f1ab-4fd5-9abe-e0a9e741aa08@ideasonboard.com>","Date":"Thu, 22 Jan 2026 18:43:53 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] v4l2: v4l2_compat: Handle __ioctl_time64","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260122121015.3842322-1-paul.elder@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260122121015.3842322-1-paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]