[PATCH 3/5] libmultipath: always use glibc basename()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

Our code relies on the non-destructive behavior of glibc's basename().
Fortunately that function is very simple, and our unit test makes
it easy to verify its functionality.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/util.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libmultipath/util.c b/libmultipath/util.c
index 39ccace..1748eaf 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -34,6 +34,19 @@ strchop(char *str)
 	return i;
 }
 
+#ifndef __GLIBC__
+/*
+ * glibc's non-destructive version of basename()
+ * License: LGPL-2.1-or-later
+ */
+static const char *__basename(const char *filename)
+{
+	char *p = strrchr(filename, '/');
+	return p ? p + 1 : filename;
+}
+#define basename(x) __basename(x)
+#endif
+
 int
 basenamecpy (const char *src, char *dst, size_t size)
 {
-- 
2.29.0


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux