{"id":14858,"url":"https://patchwork.libcamera.org/api/1.1/patches/14858/?format=json","web_url":"https://patchwork.libcamera.org/patch/14858/","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":"<20211130033820.18235-4-laurent.pinchart@ideasonboard.com>","date":"2021-11-30T03:38:01","name":"[libcamera-devel,v4,03/22] libcamera: base: file_descriptor: Move inode() function to frame_buffer.cpp","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"846a4975aa25694f19bd870be9cea2e854c8085c","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/14858/mbox/","series":[{"id":2776,"url":"https://patchwork.libcamera.org/api/1.1/series/2776/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2776","date":"2021-11-30T03:37:58","name":"libcamera: Introduce UniqueFD","version":4,"mbox":"https://patchwork.libcamera.org/series/2776/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14858/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14858/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 7990EC324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 03:38:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAFAC605B8;\n\tTue, 30 Nov 2021 04:38:54 +0100 (CET)","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 8D9916059E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 04:38:49 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A95911C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 04:38:49 +0100 (CET)"],"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=\"U747GOlU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638243529;\n\tbh=Bnq1Q2GUIRzEiJVRrp3q18meNV3XOjCJJKsNgmZN26M=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=U747GOlUHelxVYnPe55cvkYNGB550EnM5dubi9aDQz4Mn1QVJyxPnvV4FjMZQQ7I1\n\tH5BsSKDwkS60So7/SndizCvGA+zCjPKurx5JXlrr9ZE8SfylZWfGSTdUXB0+joU5X3\n\tk2qAjaEJoBGqixyWywEz86NbAYIC4eI0PjF5wlAY=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 05:38:01 +0200","Message-Id":"<20211130033820.18235-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211130033820.18235-1-laurent.pinchart@ideasonboard.com>","References":"<20211130033820.18235-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 03/22] libcamera: base:\n\tfile_descriptor: Move inode() function to frame_buffer.cpp","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() function has always been a bit of an outcast in the\nFileDescriptor class, as it's not related to the core feature provided\nby FileDescriptor, a shared ownership wrapper around file descriptors.\nAs it's only used in the FrameBuffer implementation, move it to\nframe_buffer.cpp as a static function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v3:\n\n- Move the inode function to frame_buffer.cpp\n---\n include/libcamera/base/file.h            |  2 ++\n include/libcamera/base/file_descriptor.h |  3 ---\n src/libcamera/base/file.cpp              |  1 +\n src/libcamera/base/file_descriptor.cpp   | 25 ---------------------\n src/libcamera/framebuffer.cpp            | 28 ++++++++++++++++++++++--\n 5 files changed, 29 insertions(+), 30 deletions(-)","diff":"diff --git a/include/libcamera/base/file.h b/include/libcamera/base/file.h\nindex 55e8edd934d4..9b62871b8230 100644\n--- a/include/libcamera/base/file.h\n+++ b/include/libcamera/base/file.h\n@@ -20,6 +20,8 @@\n \n namespace libcamera {\n \n+class FileDescriptor;\n+\n class File\n {\n public:\ndiff --git a/include/libcamera/base/file_descriptor.h b/include/libcamera/base/file_descriptor.h\nindex 8d764f8b4a26..5d1594e80801 100644\n--- a/include/libcamera/base/file_descriptor.h\n+++ b/include/libcamera/base/file_descriptor.h\n@@ -8,7 +8,6 @@\n #pragma once\n \n #include <memory>\n-#include <sys/types.h>\n \n namespace libcamera {\n \n@@ -28,8 +27,6 @@ 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/base/file.cpp b/src/libcamera/base/file.cpp\nindex ae4be1f95fa6..a04dfacdc102 100644\n--- a/src/libcamera/base/file.cpp\n+++ b/src/libcamera/base/file.cpp\n@@ -14,6 +14,7 @@\n #include <sys/types.h>\n #include <unistd.h>\n \n+#include <libcamera/base/file_descriptor.h>\n #include <libcamera/base/log.h>\n \n /**\ndiff --git a/src/libcamera/base/file_descriptor.cpp b/src/libcamera/base/file_descriptor.cpp\nindex f5f87c56eee8..98d4b4bfd24f 100644\n--- a/src/libcamera/base/file_descriptor.cpp\n+++ b/src/libcamera/base/file_descriptor.cpp\n@@ -8,7 +8,6 @@\n #include <libcamera/base/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@@ -223,30 +222,6 @@ 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 (!isValid())\n-\t\treturn 0;\n-\n-\tstruct stat st;\n-\tint ret = fstat(fd_->fd(), &st);\n-\tif (ret < 0) {\n-\t\tret = -errno;\n-\t\tLOG(FileDescriptor, Fatal)\n-\t\t\t<< \"Failed to fstat() fd: \" << strerror(-ret);\n-\t\treturn 0;\n-\t}\n-\n-\treturn st.st_ino;\n-}\n-\n FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n {\n \tif (!duplicate) {\ndiff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex 337ea1155a38..b1635f49b68a 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -8,6 +8,9 @@\n #include <libcamera/framebuffer.h>\n #include \"libcamera/internal/framebuffer.h\"\n \n+#include <sys/stat.h>\n+\n+#include <libcamera/base/file.h>\n #include <libcamera/base/log.h>\n \n /**\n@@ -207,6 +210,27 @@ FrameBuffer::Private::Private()\n  * \\brief The plane length in bytes\n  */\n \n+namespace {\n+\n+ino_t fileDescriptorInode(const FileDescriptor &fd)\n+{\n+\tif (!fd.isValid())\n+\t\treturn 0;\n+\n+\tstruct stat st;\n+\tint ret = fstat(fd.fd(), &st);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(Buffer, Fatal)\n+\t\t\t<< \"Failed to fstat() fd: \" << strerror(-ret);\n+\t\treturn 0;\n+\t}\n+\n+\treturn st.st_ino;\n+}\n+\n+} /* namespace */\n+\n /**\n  * \\brief Construct a FrameBuffer with an array of planes\n  * \\param[in] planes The frame memory planes\n@@ -236,8 +260,8 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n \t\t */\n \t\tif (plane.fd.fd() != planes_[0].fd.fd()) {\n \t\t\tif (!inode)\n-\t\t\t\tinode = planes_[0].fd.inode();\n-\t\t\tif (plane.fd.inode() != inode) {\n+\t\t\t\tinode = fileDescriptorInode(planes_[0].fd);\n+\t\t\tif (fileDescriptorInode(plane.fd) != inode) {\n \t\t\t\tisContiguous = false;\n \t\t\t\tbreak;\n \t\t\t}\n","prefixes":["libcamera-devel","v4","03/22"]}