Show a patch.

GET /api/1.1/patches/2771/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2771,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2771/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2771/",
    "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": "<20200205130420.8736-2-kieran.bingham@ideasonboard.com>",
    "date": "2020-02-05T13:04:16",
    "name": "[libcamera-devel,1/5] libcamera: utils: Provide helper to get dynamic library runpath",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "ac4bb4cdcb66e5926a162ae5a7ad7d2a400a46aa",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2771/mbox/",
    "series": [
        {
            "id": 661,
            "url": "https://patchwork.libcamera.org/api/1.1/series/661/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=661",
            "date": "2020-02-05T13:04:15",
            "name": "Support loading IPAs from the build tree",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/661/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2771/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2771/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03C8760444\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Feb 2020 14:04:26 +0100 (CET)",
            "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9507352F;\n\tWed,  5 Feb 2020 14:04:25 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1580907865;\n\tbh=t9cqojs86Tp/WE1nUKpMnhO2V9ifQ5SLP+hE2LbOlfU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gy7dV5aPaxu6M6pwlewS4gAGaN4yy+mzKZb7KtnholQHqhoNWe4RdpaN5GBRqPXMj\n\tlJxgQBoLAUuLOSyXrLDLoUXw/JkJsK2gZMtbIGfwbInRJh4xHZUKaTco/B/+/7xqGC\n\tBpOUcq4guWm4mpmy/yntlMp3dI/R1qnVeiz31fFM=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Wed,  5 Feb 2020 13:04:16 +0000",
        "Message-Id": "<20200205130420.8736-2-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20200205130420.8736-1-kieran.bingham@ideasonboard.com>",
        "References": "<20200205130420.8736-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper to\n\tget dynamic library runpath",
        "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, 05 Feb 2020 13:04:26 -0000"
    },
    "content": "Provide a helper that will identify the DT_RUNPATH string from the\nELF dynamic library string table entries.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/utils.h |  1 +\n src/libcamera/utils.cpp       | 26 ++++++++++++++++++++++++++\n 2 files changed, 27 insertions(+)",
    "diff": "diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex e467eb21c518..069b327bb436 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -33,6 +33,7 @@ namespace utils {\n const char *basename(const char *path);\n \n char *secure_getenv(const char *name);\n+const char *get_runpath();\n \n template<class InputIt1, class InputIt2>\n unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 4beffdab5eb6..e48cf2b6a48e 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -7,7 +7,9 @@\n \n #include \"utils.h\"\n \n+#include <elf.h>\n #include <iomanip>\n+#include <link.h>\n #include <sstream>\n #include <stdlib.h>\n #include <string.h>\n@@ -70,6 +72,30 @@ char *secure_getenv(const char *name)\n #endif\n }\n \n+/**\n+ * \\brief Obtain the runpath string from the dynamic symbol table\n+ * \\returns a const char pointer to the runpath entry in the elf string table\n+ * or NULL if it is not found.\n+ */\n+const char *get_runpath()\n+{\n+\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n+\tconst ElfW(Dyn) *runpath = NULL;\n+\tconst char *strtab = NULL;\n+\n+\tfor (; dyn->d_tag != DT_NULL; ++dyn) {\n+\t\tif (dyn->d_tag == DT_STRTAB)\n+\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n+\t\telse if (dyn->d_tag == DT_RUNPATH)\n+\t\t\trunpath = dyn;\n+\t}\n+\n+\tif (strtab && runpath)\n+\t\treturn strtab + runpath->d_un.d_val;\n+\n+\treturn NULL;\n+}\n+\n /**\n  * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n  *\t\t\t\t     InputIt2 first2, InputIt2 last2)\n",
    "prefixes": [
        "libcamera-devel",
        "1/5"
    ]
}