Update to the head of the upstream staging branch Rename redhat patches * Previous patches 0001-0012 are now patches 0041-0052 Add 0053-RH-Add-mpathcleanup.patch * add mpathcleanup program
95 lines
2.6 KiB
Diff
95 lines
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martin Wilck <mwilck@suse.com>
|
|
Date: Thu, 24 Aug 2023 21:17:25 +0200
|
|
Subject: [PATCH] libmultipath: alias.c: factor out read_binding()
|
|
|
|
This way we can test the parsing of input lines from the bindings
|
|
file more easily.
|
|
|
|
Signed-off-by: Martin Wilck <mwilck@suse.com>
|
|
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
---
|
|
libmultipath/alias.c | 58 ++++++++++++++++++++++++++++++--------------
|
|
1 file changed, 40 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/libmultipath/alias.c b/libmultipath/alias.c
|
|
index afa5879e..ecf4a2ac 100644
|
|
--- a/libmultipath/alias.c
|
|
+++ b/libmultipath/alias.c
|
|
@@ -636,6 +636,43 @@ void cleanup_bindings(void)
|
|
free_bindings(&global_bindings);
|
|
}
|
|
|
|
+enum {
|
|
+ READ_BINDING_OK,
|
|
+ READ_BINDING_SKIP,
|
|
+};
|
|
+
|
|
+static int read_binding(char *line, unsigned int linenr, char **alias,
|
|
+ char **wwid) {
|
|
+ char *c, *saveptr;
|
|
+
|
|
+ c = strpbrk(line, "#\n\r");
|
|
+ if (c)
|
|
+ *c = '\0';
|
|
+
|
|
+ *alias = strtok_r(line, " \t", &saveptr);
|
|
+ if (!*alias) /* blank line */
|
|
+ return READ_BINDING_SKIP;
|
|
+
|
|
+ *wwid = strtok_r(NULL, " \t", &saveptr);
|
|
+ if (!*wwid) {
|
|
+ condlog(1, "invalid line %u in bindings file, missing WWID",
|
|
+ linenr);
|
|
+ return READ_BINDING_SKIP;
|
|
+ }
|
|
+ if (strlen(*wwid) > WWID_SIZE - 1) {
|
|
+ condlog(3,
|
|
+ "Ignoring too large wwid at %u in bindings file",
|
|
+ linenr);
|
|
+ return READ_BINDING_SKIP;
|
|
+ }
|
|
+ c = strtok_r(NULL, " \t", &saveptr);
|
|
+ if (c)
|
|
+ /* This is non-fatal */
|
|
+ condlog(1, "invalid line %d in bindings file, extra args \"%s\"",
|
|
+ linenr, c);
|
|
+ return READ_BINDING_OK;
|
|
+}
|
|
+
|
|
static int _check_bindings_file(const struct config *conf, FILE *file,
|
|
Bindings *bindings)
|
|
{
|
|
@@ -647,27 +684,12 @@ static int _check_bindings_file(const struct config *conf, FILE *file,
|
|
|
|
pthread_cleanup_push(cleanup_free_ptr, &line);
|
|
while ((n = getline(&line, &line_len, file)) >= 0) {
|
|
- char *c, *alias, *wwid, *saveptr;
|
|
+ char *alias, *wwid;
|
|
const char *mpe_wwid;
|
|
|
|
- linenr++;
|
|
- c = strpbrk(line, "#\n\r");
|
|
- if (c)
|
|
- *c = '\0';
|
|
- alias = strtok_r(line, " \t", &saveptr);
|
|
- if (!alias) /* blank line */
|
|
- continue;
|
|
- wwid = strtok_r(NULL, " \t", &saveptr);
|
|
- if (!wwid) {
|
|
- condlog(1, "invalid line %d in bindings file, missing WWID",
|
|
- linenr);
|
|
+ if (read_binding(line, ++linenr, &alias, &wwid)
|
|
+ == READ_BINDING_SKIP)
|
|
continue;
|
|
- }
|
|
- c = strtok_r(NULL, " \t", &saveptr);
|
|
- if (c)
|
|
- /* This is non-fatal */
|
|
- condlog(1, "invalid line %d in bindings file, extra args \"%s\"",
|
|
- linenr, c);
|
|
|
|
mpe_wwid = get_mpe_wwid(conf->mptable, alias);
|
|
if (mpe_wwid && strcmp(mpe_wwid, wwid)) {
|