{"id":13598,"url":"https://patchwork.libcamera.org/api/1.1/patches/13598/?format=json","web_url":"https://patchwork.libcamera.org/patch/13598/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210902042303.2254-3-laurent.pinchart@ideasonboard.com>","date":"2021-09-02T04:22:53","name":"[libcamera-devel,RFC,v1,02/12] libcamera: file_descriptor: Add a function to retrieve the inode","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"4c753df4ee7fd66aec46f6d1d89ad7e32b59f7eb","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13598/mbox/","series":[{"id":2435,"url":"https://patchwork.libcamera.org/api/1.1/series/2435/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2435","date":"2021-09-02T04:22:51","name":"libcamera: Handle fallout of FrameBuffer offset support","version":1,"mbox":"https://patchwork.libcamera.org/series/2435/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13598/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13598/checks/","tags":{},"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 96FE9C3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Sep 2021 04:23:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D4AC069178;\n\tThu,  2 Sep 2021 06:23:25 +0200 (CEST)","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 EE9B369165\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Sep 2021 06:23:23 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 836A01516; \n\tThu,  2 Sep 2021 06:23:23 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"slGFA+kL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630556603;\n\tbh=xlimUmJ5zsZKLiB/zii3QqC3WblIuvqwIrzvJQEqS8E=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=slGFA+kLNpOyfVRNgFC15eS1fQQcsqnxkOyUjKFduw2I/y5JXK5VkCCjcHz3hzfXk\n\tB/lhxUtW6/ApSYrVUUQCeiocRFwxmqYpmV5DoDoiIOXDix9hucoM2sGiglVSUmGEyV\n\t6s0LZ3ABLFCc1J4qCVZvBzwM+hQoZrOnSJ7N9R8I=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  2 Sep 2021 07:22:53 +0300","Message-Id":"<20210902042303.2254-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210902042303.2254-1-laurent.pinchart@ideasonboard.com>","References":"<20210902042303.2254-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH v1 02/12] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","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>"},"content":"The inode is useful to check if two file descriptors refer to the same\nfile. Add a function to retrieve it.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/file_descriptor.h |  3 +++\n src/libcamera/file_descriptor.cpp   | 22 ++++++++++++++++++++++\n 2 files changed, 25 insertions(+)","diff":"diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h\nindex d514aac7697b..988f9b7a3d25 100644\n--- a/include/libcamera/file_descriptor.h\n+++ b/include/libcamera/file_descriptor.h\n@@ -8,6 +8,7 @@\n #define __LIBCAMERA_FILE_DESCRIPTOR_H__\n \n #include <memory>\n+#include <sys/types.h>\n \n namespace libcamera {\n \n@@ -27,6 +28,8 @@ public:\n \tint fd() const { return fd_ ? fd_->fd() : -1; }\n \tFileDescriptor dup() const;\n \n+\tino_t inode() const;\n+\n private:\n \tclass Descriptor\n \t{\ndiff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp\nindex 9f9ebc81f738..d55e2b100b6d 100644\n--- a/src/libcamera/file_descriptor.cpp\n+++ b/src/libcamera/file_descriptor.cpp\n@@ -8,6 +8,8 @@\n #include <libcamera/file_descriptor.h>\n \n #include <string.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n #include <unistd.h>\n #include <utility>\n \n@@ -221,6 +223,26 @@ FileDescriptor FileDescriptor::dup() const\n \treturn FileDescriptor(fd());\n }\n \n+/**\n+ * \\brief Retrieve the file descriptor inode\n+ *\n+ * \\todo Should this move to the File class ?\n+ *\n+ * \\return The file descriptor inode on success, or 0 on error\n+ */\n+ino_t FileDescriptor::inode() const\n+{\n+\tif (!fd_ || fd_->fd() == -1)\n+\t\treturn 0;\n+\n+\tstruct stat st;\n+\tint ret = fstat(fd_->fd(), &st);\n+\tif (ret < 0)\n+\t\treturn 0;\n+\n+\treturn st.st_ino;\n+}\n+\n FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n {\n \tif (!duplicate) {\n","prefixes":["libcamera-devel","RFC","v1","02/12"]}