From patchwork Mon Nov 16 00:50:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 28911 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 41264C3304 for ; Mon, 16 Nov 2026 00:50:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5462B6A83B; Mon, 16 Nov 2026 01:50:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tTi3ySct"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 650BF691CB for ; Mon, 16 Nov 2026 01:50:46 +0100 (CET) Received: from killaraus.ideasonboard.com (81-175-209-152.bb.dnainternet.fi [81.175.209.152]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DB71163C; Mon, 16 Nov 2026 01:48:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794790100; bh=irhZeLaypvUByLJPurF3IwWjjXZgSH+WPme8aw4V8d4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tTi3ySctnnWu/6phiB9Wlhw3sBiZYv1Db4rSgA6ppjxX9Fo2rBZ2ab7hUwKfk2/wp FDlIOJQJ1kqgSfslo7ruIeX+LvCN1XjLdcTITGJk+VunupPzPwJZ9AVDmaAvn/Tnc4 3iztqppHFecNAexRMC9lvKkCfIkxE5CtfBTwk+sE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Prasanth R Subject: [PATCH v3 1/2] v4l2: v4l2_compat: Handle __ioctl_time64 Date: Mon, 16 Nov 2026 02:50:42 +0200 Message-ID: <20261116005043.1651041-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261116005043.1651041-1-laurent.pinchart@ideasonboard.com> References: <20261116005043.1651041-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Paul Elder On 32-bit systems with 64-bit time_t (except x32), ioctl is redirected to __ioctl_time64. The v4l2-compat layer only intercepts the former, we need to intercept and handle the latter as well. In order to correctly support those systems, translation between 32-bit and 64-bit ioctl structures also need to be implemented. This will be done in a subsequent patch. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Tested-by: Prasanth R Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/v4l2/v4l2_compat.cpp | 21 +++++++++++++++++++++ src/v4l2/v4l2_compat_manager.cpp | 10 ++++++++++ src/v4l2/v4l2_compat_manager.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp index ff833f571bde..cc4ea33d949d 100644 --- a/src/v4l2/v4l2_compat.cpp +++ b/src/v4l2/v4l2_compat.cpp @@ -165,4 +165,25 @@ LIBCAMERA_PUBLIC int ioctl(int fd, unsigned long request, ...) return V4L2CompatManager::instance()->ioctl(fd, request, arg); } +/* + * __USE_TIME64_REDIRECTS redirects ioctl to __ioctl_time64. Disable the + * -Wmissing-declarations warnings, as the functions won't be declared if + * __USE_TIME64_REDIRECTS is not in use. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-declarations" + +#if HAVE_POSIX_IOCTL +LIBCAMERA_PUBLIC int __ioctl_time64(int fd, int request, ...) +#else +LIBCAMERA_PUBLIC int __ioctl_time64(int fd, unsigned long request, ...) +#endif +{ + void *arg; + extract_va_arg(void *, arg, request); + + return V4L2CompatManager::instance()->ioctl_time64(fd, request, arg); +} + +#pragma GCC diagnostic pop } diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp index b07f865fb2da..65cce7e13c01 100644 --- a/src/v4l2/v4l2_compat_manager.cpp +++ b/src/v4l2/v4l2_compat_manager.cpp @@ -46,6 +46,7 @@ V4L2CompatManager::V4L2CompatManager() get_symbol(fops_.dup, "dup"); get_symbol(fops_.close, "close"); get_symbol(fops_.ioctl, "ioctl"); + get_symbol(fops_.ioctl_time64, "__ioctl_time64"); get_symbol(fops_.mmap, "mmap64"); get_symbol(fops_.munmap, "munmap"); } @@ -243,3 +244,12 @@ int V4L2CompatManager::ioctl(int fd, unsigned long request, void *arg) return file->proxy()->ioctl(file.get(), request, arg); } + +int V4L2CompatManager::ioctl_time64(int fd, unsigned long request, void *arg) +{ + std::shared_ptr file = cameraFile(fd); + if (!file) + return fops_.ioctl_time64(fd, request, arg); + + return file->proxy()->ioctl(file.get(), request, arg); +} diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h index 13673d604a63..1093505a090d 100644 --- a/src/v4l2/v4l2_compat_manager.h +++ b/src/v4l2/v4l2_compat_manager.h @@ -34,6 +34,7 @@ public: dup_func_t dup; close_func_t close; ioctl_func_t ioctl; + ioctl_func_t ioctl_time64; mmap_func_t mmap; munmap_func_t munmap; }; @@ -50,6 +51,7 @@ public: int fd, off64_t offset); int munmap(void *addr, size_t length); int ioctl(int fd, unsigned long request, void *arg); + int ioctl_time64(int fd, unsigned long request, void *arg); private: V4L2CompatManager();