get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 122513,
    "url": "http://patches.dpdk.org/api/patches/122513/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230125103311.1249988-2-tduszynski@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230125103311.1249988-2-tduszynski@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230125103311.1249988-2-tduszynski@marvell.com",
    "date": "2023-01-25T10:33:10",
    "name": "[1/2] lib: add helper to read strings from sysfs files",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2377bc7e03f0fa28f4d52ff4894a623fe32d5262",
    "submitter": {
        "id": 2215,
        "url": "http://patches.dpdk.org/api/people/2215/?format=api",
        "name": "Tomasz Duszynski",
        "email": "tduszynski@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230125103311.1249988-2-tduszynski@marvell.com/mbox/",
    "series": [
        {
            "id": 26649,
            "url": "http://patches.dpdk.org/api/series/26649/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=26649",
            "date": "2023-01-25T10:33:09",
            "name": "add platform bus",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/26649/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/122513/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/122513/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 5D8EA42483;\n\tWed, 25 Jan 2023 11:33:32 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id B4E6442D6E;\n\tWed, 25 Jan 2023 11:33:26 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id 746C742D63\n for <dev@dpdk.org>; Wed, 25 Jan 2023 11:33:24 +0100 (CET)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 30P7tN3S023159; Wed, 25 Jan 2023 02:33:23 -0800",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nb0f68muc-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Wed, 25 Jan 2023 02:33:23 -0800",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42;\n Wed, 25 Jan 2023 02:33:21 -0800",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend\n Transport; Wed, 25 Jan 2023 02:33:21 -0800",
            "from cavium-DT10.. (unknown [10.28.34.39])\n by maili.marvell.com (Postfix) with ESMTP id DB11F3F70BC;\n Wed, 25 Jan 2023 02:33:16 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=nbq/oGpvCJMGRkR+1Icm51EWAR1ZUhaWXzsWPZ5MiPY=;\n b=AByZyYzrW88rPzx6+VrXsEVirKN0b+BnM18MzB33MHVYEXeLc7DM566sfzYidZWfxSuV\n bSOrSNLW6qYCjDtwVmm+8ErAArsDL5mdQYLuxmv6kkfsTxbsA0HCfMC0+ZxcGtOoPLKV\n xbL/E/mAgKwFrfo2cVlu6g1O+jTzWPzG5yjxrTCbFEXOUCbSok9OmfwexGKy7cUjlFz7\n TalWy8368+VXs1OHP+VJ0AOuCA2USy297uDnUhU0nUyy4guQvqvH64OFC67FaO7J1JlI\n ySKnmNVhU0oRFbbDYj5yiFaB63QYO+nSWWvzmllJ2aaSy7KdqY3TDh8+qSK7PrefJ2Me MQ==",
        "From": "Tomasz Duszynski <tduszynski@marvell.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<thomas@monjalon.net>, <jerinj@marvell.com>, <stephen@networkplumber.org>,\n <chenbo.xia@intel.com>, Tomasz Duszynski <tduszynski@marvell.com>",
        "Subject": "[PATCH 1/2] lib: add helper to read strings from sysfs files",
        "Date": "Wed, 25 Jan 2023 11:33:10 +0100",
        "Message-ID": "<20230125103311.1249988-2-tduszynski@marvell.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230125103311.1249988-1-tduszynski@marvell.com>",
        "References": "<20230110234642.1188550-1-tduszynski@marvell.com>\n <20230125103311.1249988-1-tduszynski@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "Vv9VUUTGei2swfuy09ivkgCtIngWG9P6",
        "X-Proofpoint-ORIG-GUID": "Vv9VUUTGei2swfuy09ivkgCtIngWG9P6",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1\n definitions=2023-01-25_05,2023-01-25_01,2022-06-22_01",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Reading strings from sysfs files is a re-occurring pattern\nhence add helper for doing that.\n\nSigned-off-by: Tomasz Duszynski <tduszynski@marvell.com>\n---\n app/test/test_eal_fs.c          | 108 ++++++++++++++++++++++++++++----\n lib/eal/common/eal_filesystem.h |   6 ++\n lib/eal/unix/eal_filesystem.c   |  24 ++++---\n lib/eal/version.map             |   1 +\n 4 files changed, 121 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/app/test/test_eal_fs.c b/app/test/test_eal_fs.c\nindex b3686edcb4..6c373fc7f1 100644\n--- a/app/test/test_eal_fs.c\n+++ b/app/test/test_eal_fs.c\n@@ -20,12 +20,33 @@ test_eal_fs(void)\n \n #else\n \n+static int\n+temp_create(char *filename, size_t len)\n+{\n+\tchar file_template[] = \"/tmp/eal_test_XXXXXX\";\n+\tchar proc_path[PATH_MAX];\n+\tint fd;\n+\n+\tfd = mkstemp(file_template);\n+\tif (fd == -1) {\n+\t\tperror(\"mkstemp() failure\");\n+\t\treturn -1;\n+\t}\n+\n+\tsnprintf(proc_path, sizeof(proc_path), \"/proc/self/fd/%d\", fd);\n+\tif (readlink(proc_path, filename, len) < 0) {\n+\t\tperror(\"readlink() failure\");\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\treturn fd;\n+}\n+\n static int\n test_parse_sysfs_value(void)\n {\n \tchar filename[PATH_MAX] = \"\";\n-\tchar proc_path[PATH_MAX];\n-\tchar file_template[] = \"/tmp/eal_test_XXXXXX\";\n \tint tmp_file_handle = -1;\n \tFILE *fd = NULL;\n \tunsigned valid_number;\n@@ -40,16 +61,10 @@ test_parse_sysfs_value(void)\n \n \t/* get a temporary filename to use for all tests - create temp file handle and then\n \t * use /proc to get the actual file that we can open */\n-\ttmp_file_handle = mkstemp(file_template);\n-\tif (tmp_file_handle == -1) {\n-\t\tperror(\"mkstemp() failure\");\n+\ttmp_file_handle = temp_create(filename, sizeof(filename));\n+\tif (tmp_file_handle < 0)\n \t\tgoto error;\n-\t}\n-\tsnprintf(proc_path, sizeof(proc_path), \"/proc/self/fd/%d\", tmp_file_handle);\n-\tif (readlink(proc_path, filename, sizeof(filename)) < 0) {\n-\t\tperror(\"readlink() failure\");\n-\t\tgoto error;\n-\t}\n+\n \tprintf(\"Temporary file is: %s\\n\", filename);\n \n \t/* test we get an error value if we use file before it's created */\n@@ -175,11 +190,82 @@ test_parse_sysfs_value(void)\n \treturn -1;\n }\n \n+static int\n+test_parse_sysfs_string(void)\n+{\n+\tconst char *teststr = \"the quick brown dog jumps over the lazy fox\\n\";\n+\tchar filename[PATH_MAX] = \"\";\n+\tchar buf[BUFSIZ] = { };\n+\tint tmp_file_handle;\n+\tFILE *fd = NULL;\n+\n+#ifdef RTE_EXEC_ENV_FREEBSD\n+\t/* BSD doesn't have /proc/pid/fd */\n+\treturn 0;\n+#endif\n+\tprintf(\"Testing function eal_parse_sysfs_string()\\n\");\n+\n+\t/* get a temporary filename to use for all tests - create temp file handle and then\n+\t * use /proc to get the actual file that we can open\n+\t */\n+\ttmp_file_handle = temp_create(filename, sizeof(filename));\n+\tif (tmp_file_handle < 0)\n+\t\tgoto error;\n+\n+\tprintf(\"Temporary file is: %s\\n\", filename);\n+\n+\t/* test we get an error value if we use file before it's created */\n+\tprintf(\"Test reading a missing file ...\\n\");\n+\tif (eal_parse_sysfs_string(\"/dev/not-quite-null\", buf, sizeof(buf)) == 0) {\n+\t\tprintf(\"Error with eal_parse_sysfs_string() - returned success on reading empty file\\n\");\n+\t\tgoto error;\n+\t}\n+\tprintf(\"Confirmed return error when reading empty file\\n\");\n+\n+\t/* test reading a string from file */\n+\tprintf(\"Test reading string ...\\n\");\n+\tfd = fopen(filename, \"w\");\n+\tif (fd == NULL) {\n+\t\tprintf(\"line %d, Error opening %s: %s\\n\", __LINE__, filename, strerror(errno));\n+\t\tgoto error;\n+\t}\n+\tfprintf(fd, \"%s\", teststr);\n+\tfclose(fd);\n+\tfd = NULL;\n+\tif (eal_parse_sysfs_string(filename, buf, sizeof(buf) - 1) < 0) {\n+\t\tprintf(\"eal_parse_sysfs_string() returned error - test failed\\n\");\n+\t\tgoto error;\n+\t}\n+\tif (strcmp(teststr, buf)) {\n+\t\tprintf(\"Invalid string read by eal_parse_sysfs_string() - test failed\\n\");\n+\t\tgoto error;\n+\t}\n+\t/* don't print newline */\n+\tbuf[strlen(buf) - 1] = '\\0';\n+\tprintf(\"Read '%s\\\\n' ok\\n\", buf);\n+\n+\tclose(tmp_file_handle);\n+\tunlink(filename);\n+\tprintf(\"eal_parse_sysfs_string() - OK\\n\");\n+\treturn 0;\n+\n+error:\n+\tif (fd)\n+\t\tfclose(fd);\n+\tif (tmp_file_handle > 0)\n+\t\tclose(tmp_file_handle);\n+\tif (filename[0] != '\\0')\n+\t\tunlink(filename);\n+\treturn -1;\n+}\n+\n static int\n test_eal_fs(void)\n {\n \tif (test_parse_sysfs_value() < 0)\n \t\treturn -1;\n+\tif (test_parse_sysfs_string() < 0)\n+\t\treturn -1;\n \treturn 0;\n }\n \ndiff --git a/lib/eal/common/eal_filesystem.h b/lib/eal/common/eal_filesystem.h\nindex 5d21f07c20..ac6449f529 100644\n--- a/lib/eal/common/eal_filesystem.h\n+++ b/lib/eal/common/eal_filesystem.h\n@@ -104,4 +104,10 @@ eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id\n  * Used to read information from files on /sys */\n int eal_parse_sysfs_value(const char *filename, unsigned long *val);\n \n+/** Function to read a string from a file on the filesystem.\n+ * Used to read information for files in /sys\n+ */\n+__rte_internal\n+int eal_parse_sysfs_string(const char *filename, char *str, size_t size);\n+\n #endif /* EAL_FILESYSTEM_H */\ndiff --git a/lib/eal/unix/eal_filesystem.c b/lib/eal/unix/eal_filesystem.c\nindex afbab9368a..8ed10094be 100644\n--- a/lib/eal/unix/eal_filesystem.c\n+++ b/lib/eal/unix/eal_filesystem.c\n@@ -76,12 +76,9 @@ int eal_create_runtime_dir(void)\n \treturn 0;\n }\n \n-/* parse a sysfs (or other) file containing one integer value */\n-int eal_parse_sysfs_value(const char *filename, unsigned long *val)\n+int eal_parse_sysfs_string(const char *filename, char *str, size_t size)\n {\n \tFILE *f;\n-\tchar buf[BUFSIZ];\n-\tchar *end = NULL;\n \n \tif ((f = fopen(filename, \"r\")) == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): cannot open sysfs value %s\\n\",\n@@ -89,19 +86,32 @@ int eal_parse_sysfs_value(const char *filename, unsigned long *val)\n \t\treturn -1;\n \t}\n \n-\tif (fgets(buf, sizeof(buf), f) == NULL) {\n+\tif (fgets(str, size, f) == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): cannot read sysfs value %s\\n\",\n \t\t\t__func__, filename);\n \t\tfclose(f);\n \t\treturn -1;\n \t}\n+\tfclose(f);\n+\treturn 0;\n+}\n+\n+/* parse a sysfs (or other) file containing one integer value */\n+int eal_parse_sysfs_value(const char *filename, unsigned long *val)\n+{\n+\tchar buf[BUFSIZ];\n+\tchar *end = NULL;\n+\tint ret;\n+\n+\tret = eal_parse_sysfs_string(filename, buf, sizeof(buf));\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n \t*val = strtoul(buf, &end, 0);\n \tif ((buf[0] == '\\0') || (end == NULL) || (*end != '\\n')) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): cannot parse sysfs value %s\\n\",\n \t\t\t\t__func__, filename);\n-\t\tfclose(f);\n \t\treturn -1;\n \t}\n-\tfclose(f);\n \treturn 0;\n }\ndiff --git a/lib/eal/version.map b/lib/eal/version.map\nindex 7ad12a7dc9..9118bb6228 100644\n--- a/lib/eal/version.map\n+++ b/lib/eal/version.map\n@@ -445,6 +445,7 @@ EXPERIMENTAL {\n INTERNAL {\n \tglobal:\n \n+\teal_parse_sysfs_string; # WINDOWS_NO_EXPORT\n \trte_bus_register;\n \trte_bus_unregister;\n \trte_eal_get_baseaddr;\n",
    "prefixes": [
        "1/2"
    ]
}