[RFC 06/11] lib: Move strcmp_prefix into string.c

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

 



Move strcmp_prefix from fs/xattr.c into lib/string.h to make it available
elsewhere; export it to modules.

Signed-off-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx>
---
 fs/xattr.c             | 11 -----------
 include/linux/string.h |  1 +
 lib/string.c           | 16 ++++++++++++++++
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index efa16ce..9584808 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -663,17 +663,6 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
 	return error;
 }
 
-
-static const char *
-strcmp_prefix(const char *a, const char *a_prefix)
-{
-	while (*a_prefix && *a == *a_prefix) {
-		a++;
-		a_prefix++;
-	}
-	return *a_prefix ? NULL : a;
-}
-
 /*
  * In order to implement different sets of xattr operations for each xattr
  * prefix with the generic xattr API, a filesystem should create a
diff --git a/include/linux/string.h b/include/linux/string.h
index a8d90db..edc155d 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -37,6 +37,7 @@ extern size_t strlcat(char *, const char *, __kernel_size_t);
 #ifndef __HAVE_ARCH_STRCMP
 extern int strcmp(const char *,const char *);
 #endif
+extern const char *strcmp_prefix(const char *, const char *);
 #ifndef __HAVE_ARCH_STRNCMP
 extern int strncmp(const char *,const char *,__kernel_size_t);
 #endif
diff --git a/lib/string.c b/lib/string.c
index 13d1e84..697572d 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -246,6 +246,22 @@ int strcmp(const char *cs, const char *ct)
 EXPORT_SYMBOL(strcmp);
 #endif
 
+/**
+ * strcmp_prefix  -  check string for given prefix
+ *
+ * Returns @str + strlen(@prefix) if @str has the given @prefix, and NULL
+ * otherwise.
+ */
+const char *strcmp_prefix(const char *str, const char *prefix)
+{
+	while (*prefix && *str == *prefix) {
+		str++;
+		prefix++;
+	}
+	return *prefix ? NULL : str;
+}
+EXPORT_SYMBOL(strcmp_prefix);
+
 #ifndef __HAVE_ARCH_STRNCMP
 /**
  * strncmp - Compare two length-limited strings
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux