e5eddaae1a
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
76 lines
2.1 KiB
Diff
76 lines
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martin Wilck <mwilck@suse.com>
|
|
Date: Tue, 22 Aug 2023 21:36:11 +0200
|
|
Subject: [PATCH] libmultipath: add alias_already_taken()
|
|
|
|
Factor out a trivial helper function.
|
|
|
|
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 | 32 +++++++++++++++++++-------------
|
|
1 file changed, 19 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/libmultipath/alias.c b/libmultipath/alias.c
|
|
index c0139a2e..83ded886 100644
|
|
--- a/libmultipath/alias.c
|
|
+++ b/libmultipath/alias.c
|
|
@@ -8,6 +8,7 @@
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
#include <stdio.h>
|
|
+#include <stdbool.h>
|
|
|
|
#include "debug.h"
|
|
#include "util.h"
|
|
@@ -109,30 +110,35 @@ scan_devname(const char *alias, const char *prefix)
|
|
return n;
|
|
}
|
|
|
|
-static int
|
|
-id_already_taken(int id, const char *prefix, const char *map_wwid)
|
|
+static bool alias_already_taken(const char *alias, const char *map_wwid)
|
|
{
|
|
- STRBUF_ON_STACK(buf);
|
|
- const char *alias;
|
|
-
|
|
- if (append_strbuf_str(&buf, prefix) < 0 ||
|
|
- format_devname(&buf, id) < 0)
|
|
- return 0;
|
|
|
|
- alias = get_strbuf_str(&buf);
|
|
if (dm_map_present(alias)) {
|
|
char wwid[WWID_SIZE];
|
|
|
|
/* If both the name and the wwid match, then it's fine.*/
|
|
if (dm_get_uuid(alias, wwid, sizeof(wwid)) == 0 &&
|
|
strncmp(map_wwid, wwid, sizeof(wwid)) == 0)
|
|
- return 0;
|
|
- condlog(3, "%s: alias '%s' already taken, but not in bindings file. reselecting alias", map_wwid, alias);
|
|
- return 1;
|
|
+ return false;
|
|
+ condlog(3, "%s: alias '%s' already taken, but not in bindings file. reselecting alias",
|
|
+ map_wwid, alias);
|
|
+ return true;
|
|
}
|
|
- return 0;
|
|
+ return false;
|
|
}
|
|
|
|
+static bool id_already_taken(int id, const char *prefix, const char *map_wwid)
|
|
+{
|
|
+ STRBUF_ON_STACK(buf);
|
|
+ const char *alias;
|
|
+
|
|
+ if (append_strbuf_str(&buf, prefix) < 0 ||
|
|
+ format_devname(&buf, id) < 0)
|
|
+ return false;
|
|
+
|
|
+ alias = get_strbuf_str(&buf);
|
|
+ return alias_already_taken(alias, map_wwid);
|
|
+}
|
|
|
|
/*
|
|
* Returns: 0 if matching entry in WWIDs file found
|