Patch Detail
Show a patch.
GET /api/patches/14818/?format=api
{ "id": 14818, "url": "https://patchwork.libcamera.org/api/patches/14818/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14818/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20211128235752.10836-4-laurent.pinchart@ideasonboard.com>", "date": "2021-11-28T23:57:38", "name": "[libcamera-devel,v3,03/17] libcamera: base: file_descriptor: Move inode() function to File class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "10c9f872fd3304c58eaa8f28726c2bf1e1f663d9", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14818/mbox/", "series": [ { "id": 2768, "url": "https://patchwork.libcamera.org/api/series/2768/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2768", "date": "2021-11-28T23:57:35", "name": "libcamera: Introduce UniqueFD", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2768/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14818/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14818/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 03C78C324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 23:58:28 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4EDE060596;\n\tMon, 29 Nov 2021 00:58:28 +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 B312060591\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 00:58:22 +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 33965730;\n\tMon, 29 Nov 2021 00:58:22 +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=\"hTso7Poh\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638143902;\n\tbh=vouL4op4AAtLX9vNiPG1Fp1rivj6Kz38JJ/WSGtPvWE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=hTso7PohVggGe+nGoOZoLQwUiWOSCPVZdFDNvLqwcKccDwVEne9Z1j7c6EOA1Erli\n\tuFcCrQnSnY3YYGcgZWGmSgipIJh+lHtWCyQyZ96fzP8S1eSTFQ8vCaXjU7NimB3YLr\n\teNOVK4tlUnkUkDBw/MUhOp0fkfEKf3MmYnKPtDG4=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 29 Nov 2021 01:57:38 +0200", "Message-Id": "<20211128235752.10836-4-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20211128235752.10836-1-laurent.pinchart@ideasonboard.com>", "References": "<20211128235752.10836-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 03/17] libcamera: base:\n\tfile_descriptor: Move inode() function to File class", "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.\nMove it to the File class instead. It may not be a perfect fit there\neither, but File is a private class, so the inode() function is at least\nnot part of the public API anymore.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/file.h | 3 +++\n include/libcamera/base/file_descriptor.h | 3 ---\n src/libcamera/base/file.cpp | 23 ++++++++++++++++++++++\n src/libcamera/base/file_descriptor.cpp | 25 ------------------------\n src/libcamera/framebuffer.cpp | 5 +++--\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..996751a7ab72 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:\n@@ -66,6 +68,7 @@ public:\n \tbool unmap(uint8_t *addr);\n \n \tstatic bool exists(const std::string &name);\n+\tstatic ino_t inode(const FileDescriptor &fd);\n \n private:\n \tLIBCAMERA_DISABLE_COPY(File)\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..7043f9461cf7 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 /**\n@@ -472,4 +473,26 @@ bool File::exists(const std::string &name)\n \treturn !S_ISDIR(st.st_mode);\n }\n \n+/**\n+ * \\brief Retrieve the inode of a FileDescriptor\n+ *\n+ * \\return The file descriptor inode on success, or 0 on error\n+ */\n+ino_t File::inode(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(File, 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 libcamera */\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..f5bcf107d7aa 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -8,6 +8,7 @@\n #include <libcamera/framebuffer.h>\n #include \"libcamera/internal/framebuffer.h\"\n \n+#include <libcamera/base/file.h>\n #include <libcamera/base/log.h>\n \n /**\n@@ -236,8 +237,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 = File::inode(planes_[0].fd);\n+\t\t\tif (File::inode(plane.fd) != inode) {\n \t\t\t\tisContiguous = false;\n \t\t\t\tbreak;\n \t\t\t}\n", "prefixes": [ "libcamera-devel", "v3", "03/17" ] }