@@ -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
@@ -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
@@ -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
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@redhat.com> --- fs/xattr.c | 11 ----------- include/linux/string.h | 1 + lib/string.c | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-)