Patch Detail
Show a patch.
GET /api/1.1/patches/3165/?format=api
{ "id": 3165, "url": "https://patchwork.libcamera.org/api/1.1/patches/3165/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3165/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200318115846.7975-4-kgupta@es.iitr.ac.in>", "date": "2020-03-18T11:58:43", "name": "[libcamera-devel,v3,3/6] libcamera: utils: add Libcamera installed & path", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "1771a929655e80ce0c80c83393bb0030a9667cc6", "submitter": { "id": 39, "url": "https://patchwork.libcamera.org/api/1.1/people/39/?format=api", "name": "Kaaira Gupta", "email": "kgupta@es.iitr.ac.in" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3165/mbox/", "series": [ { "id": 731, "url": "https://patchwork.libcamera.org/api/1.1/series/731/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=731", "date": "2020-03-18T11:58:40", "name": "libcamera: determine IPA_PROXY_PATH at runtime", "version": 3, "mbox": "https://patchwork.libcamera.org/series/731/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3165/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3165/checks/", "tags": {}, "headers": { "Return-Path": "<kgupta@es.iitr.ac.in>", "Received": [ "from mail-pf1-x435.google.com (mail-pf1-x435.google.com\n\t[IPv6:2607:f8b0:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E3A860419\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Mar 2020 12:59:24 +0100 (CET)", "by mail-pf1-x435.google.com with SMTP id 2so13766006pfg.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Mar 2020 04:59:24 -0700 (PDT)", "from kaaira-HP-Pavilion-Notebook ([103.113.213.153])\n\tby smtp.gmail.com with ESMTPSA id\n\ti11sm2378818pje.30.2020.03.18.04.59.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 18 Mar 2020 04:59:22 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=mKogFjsmRN3byaPv0b/6ZZyVMnNZ8tddAXwdndhLKH0=;\n\tb=u14CwDODjdreSOhe+S5/2Iw7Bmqq2rKc5MIYmg9FelM4Fu9ILp6bjecor/qEKS8vAR\n\tOb1KJA9vQcYf1np6Wx/SJldcGqfW4isTpKQSX/p+whyHmW7Gc73xzbY0UGSx1w9gcljo\n\tWBGNhyIWjbHE5+nuntatv8o7gzETDZ+P0rgY2xumuXiwn0oA9LdMlaTHDM1SrSFASDVs\n\tXFxalksr4KpORQCG84/6S+pJnNyRKHnbMS67hpirVmUxacVLdOH9ZEmAinFUBja3fdsm\n\t2COrutuQyUI5MWEodUCB7A8aYKEXdMQF5KnfzgiCoTX0UAIrEZ/IqLL7T5nlQt5vsNgE\n\tCFQQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=mKogFjsmRN3byaPv0b/6ZZyVMnNZ8tddAXwdndhLKH0=;\n\tb=jqDOiJbhfQ8sPnIOoWKG1hkIzNmxIg8QQ3BIUVlvtc4W9h9zeNPbQOC3bmyvStIFHc\n\t263hmGt2t5jgDTHlf542CHWDF8xb/GbQPek7NPJJuhqZrcYd++JMR8PdNbXAcuLbG2xd\n\tEJ4mH4RCojR0UZ13YmGeZMsEZqBgLWhrzIaqOKsRV8QLlY1P0ctzsZvijuUHwqaMswEd\n\tSDpAdJAhB/bukwjNqApDmV0bRulrsVKFv8Aa8JQHsJcFyCXKcoj9QlXtYkbyEPPgcYLt\n\t+9fPS1drFPZUY7WV0qqQasJI7Jd1SbHRz5iAehJ7cC1qH7L0XvtjSx1CzRBgMARmWww5\n\t50fw==", "X-Gm-Message-State": "ANhLgQ0Nx0wK9CpS2paDA6M3WAgujfrC6SCt0fop3NUd2TC68z41I94a\n\tOpPMZu1aYAM6GXS0QP5Or+EHuQ==", "X-Google-Smtp-Source": "ADFU+vuC/5vEGkQqxzRm7VlMppCyPeDQR+8AmrOh7WcL3kRqbA/0+VtT6yHbgX+wa/f62TvAczpcxQ==", "X-Received": "by 2002:a62:1cf:: with SMTP id 198mr4062245pfb.246.1584532762859;\n\tWed, 18 Mar 2020 04:59:22 -0700 (PDT)", "From": "Kaaira Gupta <kgupta@es.iitr.ac.in>", "To": "Helen Koike <helen.koike@collabora.com>,\n\tVaishali Thakkar <vthakkar@vaishalithakkar.in>,\n\tkieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org", "Cc": "Kaaira Gupta <kgupta@es.iitr.ac.in>", "Date": "Wed, 18 Mar 2020 17:28:43 +0530", "Message-Id": "<20200318115846.7975-4-kgupta@es.iitr.ac.in>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20200318115846.7975-1-kgupta@es.iitr.ac.in>", "References": "<20200318115846.7975-1-kgupta@es.iitr.ac.in>", "Subject": "[libcamera-devel] [PATCH LIBCAMERA v3 3/6] libcamera: utils: add\n\tLibcamera installed & path", "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": "Wed, 18 Mar 2020 11:59:24 -0000" }, "content": "Add a global functions 'isLibcameraInstalled' to check if libcamera is\ninstalled or not, and another global function 'libcameraPath' to return\nthe path of libcamera.so in utils.\n\nSigned-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\n---\n src/libcamera/include/utils.h | 4 +++\n src/libcamera/utils.cpp | 48 +++++++++++++++++++++++++++++++++++\n 2 files changed, 52 insertions(+)", "diff": "diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex 9405977..bc96e79 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -143,6 +143,10 @@ private:\n \n details::StringSplitter split(const std::string &str, const std::string &delim);\n \n+bool isLibcameraInstalled();\n+\n+std::string libcameraPath();\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex f566e88..aeaf163 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -12,12 +12,18 @@\n #include <stdlib.h>\n #include <string.h>\n #include <unistd.h>\n+#include <dlfcn.h>\n+#include <elf.h>\n+#include <link.h>\n \n /**\n * \\file utils.h\n * \\brief Miscellaneous utility functions\n */\n \n+/* musl doesn't declare _DYNAMIC in link.h, declare it manually. */\n+extern ElfW(Dyn) _DYNAMIC[];\n+\n namespace libcamera {\n \n namespace utils {\n@@ -310,6 +316,48 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n \treturn details::StringSplitter(str, delim);\n }\n \n+/**\n+ * \\brief Checks if Libcamera is installed or not\n+ *\n+ * Utilises the build_rpath dynamic tag which is stripped out by meson at\n+ * install time to determine at runtime if the library currently executing\n+ * has been installed or not.\n+ *\n+ * \\return A bool stating if libcamera is installed or not\n+ */\n+bool isLibcameraInstalled()\n+{\n+\t/*\n+\t * DT_RUNPATH (DT_RPATH when the linker uses old dtags) is removed on\n+\t * install.\n+\t */\n+\tfor (const ElfW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n+\t\tif (dyn->d_tag == DT_RUNPATH || dyn->d_tag == DT_RPATH)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/**\n+ * \\brief Identifies libcamera path\n+ *\n+ * Identifies the location by finding the path of the active libcamera.so itself.\n+ *\n+ * \\return A string stating the path.\n+ */\n+std::string libcameraPath()\n+{\n+\tDl_info info;\n+\n+\t/* Look up our own symbol. */\n+\tint ret = dladdr(reinterpret_cast<void *>(libcameraPath), &info);\n+\tif (ret == 0)\n+\t\treturn nullptr;\n+\n+\treturn info.dli_fname;\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v3", "3/6" ] }