From patchwork Fri Jan 3 05:41:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 2486 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8E5B605E3 for ; Fri, 3 Jan 2020 06:41:28 +0100 (CET) Received: from neptunite.amanokami.net (unknown [96.44.9.94]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA92EA3C; Fri, 3 Jan 2020 06:41:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1578030088; bh=7k/LtAKn5SvZJZZrPQPHmdjYI4nRdibYZevxzLT6R5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tDQTzVBwcLD2fEgvzvOwZcLPr6r0BP0c0giA/1asj6vwZWZ3lytbwvgnjTLP6drGy d9+9SaXnhLIjyVcGspTwYrhxU67o+CFRHoUxIKOP2VjLJI9DQX4ne8zFgs7rl1jL3p lGVXgK9/999nwdQaqY3iEB9SOxVNeeokyk/pzrq4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Jan 2020 00:41:17 -0500 Message-Id: <20200103054120.30979-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200103054120.30979-1-paul.elder@ideasonboard.com> References: <20200103054120.30979-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/4] libcamera: v4l2_device, v4l2_videodevice: call open system call directly 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: , X-List-Received-Date: Fri, 03 Jan 2020 05:41:28 -0000 We are preparing to integrate the V4L2 adaptation layer, which will intercept open() calls (among others) via LD_PRELOAD. To prevent libcamera's own open() calls from being intercepted, replace them with a direct syscall. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- No change in v5 Changes in v4: - one cosmetic change Changes in v3: - change SYS_open to SYS_openat No change in v2 --- src/libcamera/v4l2_device.cpp | 3 ++- src/libcamera/v4l2_videodevice.cpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 0452f801..c13eddc8 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "log.h" @@ -75,7 +76,7 @@ int V4L2Device::open(unsigned int flags) return -EBUSY; } - int ret = ::open(deviceNode_.c_str(), flags); + int ret = syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), flags); if (ret < 0) { ret = -errno; LOG(V4L2, Error) << "Failed to open V4L2 device: " diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 13e02323..033f7cc0 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1426,7 +1427,8 @@ int V4L2M2MDevice::open() * as the V4L2VideoDevice::open() retains a handle by duplicating the * fd passed in. */ - fd = ::open(deviceNode_.c_str(), O_RDWR | O_NONBLOCK); + fd = syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), + O_RDWR | O_NONBLOCK); if (fd < 0) { ret = -errno; LOG(V4L2, Error)