[{"id":3194,"web_url":"https://patchwork.libcamera.org/comment/3194/","msgid":"<20191206161554.tuhpnjsy2wfo6hyy@uno.localdomain>","date":"2019-12-06T16:15:54","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: v4l2_device,\n\tv4l2_videodevice: call open system call directly","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Paul,\n\nOn Fri, Dec 06, 2019 at 04:26:53AM -0500, 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 will a\n> direct syscall.\n>\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\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..f16931a3 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_open, 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 99213075..2dff3d3c 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> @@ -1427,7 +1428,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_open, deviceNode_.c_str(), O_RDWR | O_NONBLOCK);\n>  \tif (fd < 0) {\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2, Error)\n> --\n> 2.23.0\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E962860BBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2019 17:14:06 +0100 (CET)","from uno.localdomain (93-34-114-233.ip49.fastwebnet.it\n\t[93.34.114.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 3AAAD40005;\n\tFri,  6 Dec 2019 16:14:06 +0000 (UTC)"],"X-Originating-IP":"93.34.114.233","Date":"Fri, 6 Dec 2019 17:15:54 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191206161554.tuhpnjsy2wfo6hyy@uno.localdomain>","References":"<20191206092654.24340-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"7xtlogkd5tq6kayt\"","Content-Disposition":"inline","In-Reply-To":"<20191206092654.24340-1-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] 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, 06 Dec 2019 16:14:07 -0000"}}]