[{"id":3276,"web_url":"https://patchwork.libcamera.org/comment/3276/","msgid":"<20191227114217.GB4769@pendragon.ideasonboard.com>","date":"2019-12-27T11:42:17","subject":"Re: [libcamera-devel] [PATCH v3 1/6] libcamera: v4l2_device,\n\tv4l2_videodevice: call open system call directly","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Mon, Dec 23, 2019 at 01:26:15AM -0600, Paul Elder wrote:\n> We are preparing to integrate the V4L2 adaptation layer, which will\n> intercept open() calls (among others) via LD_PRELOAD. To prevent\n> libcamera's own open() calls from being intercepted, replace them with a\n> direct syscall.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - change SYS_open to SYS_openat\n> \n> No change in v2\n> ---\n>  src/libcamera/v4l2_device.cpp      | 3 ++-\n>  src/libcamera/v4l2_videodevice.cpp | 3 ++-\n>  2 files changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 0452f801..c13eddc8 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -11,6 +11,7 @@\n>  #include <iomanip>\n>  #include <string.h>\n>  #include <sys/ioctl.h>\n> +#include <sys/syscall.h>\n>  #include <unistd.h>\n>  \n>  #include \"log.h\"\n> @@ -75,7 +76,7 @@ int V4L2Device::open(unsigned int flags)\n>  \t\treturn -EBUSY;\n>  \t}\n>  \n> -\tint ret = ::open(deviceNode_.c_str(), flags);\n> +\tint ret = syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), flags);\n>  \tif (ret < 0) {\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2, Error) << \"Failed to open V4L2 device: \"\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 13e02323..50e3bc11 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -13,6 +13,7 @@\n>  #include <string.h>\n>  #include <sys/ioctl.h>\n>  #include <sys/mman.h>\n> +#include <sys/syscall.h>\n>  #include <sys/time.h>\n>  #include <unistd.h>\n>  #include <vector>\n> @@ -1426,7 +1427,7 @@ int V4L2M2MDevice::open()\n>  \t * as the V4L2VideoDevice::open() retains a handle by duplicating the\n>  \t * fd passed in.\n>  \t */\n> -\tfd = ::open(deviceNode_.c_str(), O_RDWR | O_NONBLOCK);\n> +\tfd = syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), O_RDWR | O_NONBLOCK);\n\nNitpicking, you can wrap this line.\n\n>  \tif (fd < 0) {\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2, Error)","headers":{"Return-Path":"<laurent.pinchart@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 DA82F6046D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Dec 2019 12:42:29 +0100 (CET)","from pendragon.ideasonboard.com (unknown [91.179.177.25])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 42834DD;\n\tFri, 27 Dec 2019 12:42:29 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1577446949;\n\tbh=IaTOlVk5PxCuef/pUVF1x3znH2Uw7XEIFIZN3a6I8lg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lZUxaBCcPq7vfahuHT10gEYmIosWt/K8j37YR4XIsh4+wO/ZNUktPfr3nfsw63jhu\n\tCXtITABZ5cL917iiMRAkLDn+sAVFiFD5EPrmvLIg5IfOCGAnh6dWQCc/S+9B18sZq4\n\tX2cuB2MVBvQ9BMi/23SzHzs+L0TQQk0m2GJE9CK4=","Date":"Fri, 27 Dec 2019 13:42:17 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20191227114217.GB4769@pendragon.ideasonboard.com>","References":"<20191223072620.13022-1-paul.elder@ideasonboard.com>\n\t<20191223072620.13022-2-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191223072620.13022-2-paul.elder@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 1/6] libcamera: v4l2_device,\n\tv4l2_videodevice: call open system call directly","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, 27 Dec 2019 11:42:30 -0000"}}]