From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>,
Eric Paris <eparis@redhat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
linux-fsdevel@vger.kernel.org,
David Quigley <dpquigl@davequigley.com>,
"J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-security-module@vger.kernel.org, cluster-devel@redhat.com
Subject: [RFC 06/11] lib: Move strcmp_prefix into string.c
Date: Thu, 20 Aug 2015 20:19:53 +0200 [thread overview]
Message-ID: <1440094798-1411-7-git-send-email-agruenba@redhat.com> (raw)
In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com>
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(-)
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
next prev parent reply other threads:[~2015-08-20 18:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-20 18:19 [RFC 00/11] Inode security label invalidation Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 01/11] ubifs: Remove unused "security.*" xattr handler Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 02/11] hfsplus: Remove unused xattr handler list operations Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 03/11] 9p: Simplify the xattr handlers Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 04/11] xattr handlers: Pass handler to operations instead of flags Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 05/11] xattr handlers: Some simplifications Andreas Gruenbacher
2015-08-20 18:19 ` Andreas Gruenbacher [this message]
2015-08-20 18:19 ` [RFC 07/11] 9p: Stop using the generic xattr_handler infrastructure Andreas Gruenbacher
2015-08-21 6:46 ` Christoph Hellwig
2015-08-21 8:35 ` [Cluster-devel] " Steven Whitehouse
2015-08-20 18:19 ` [RFC 08/11] xattr: Pass inodes to xattr handlers instead of dentries Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 09/11] vfs: Add igetxattr inode operation Andreas Gruenbacher
2015-08-21 6:48 ` Christoph Hellwig
2015-08-20 18:19 ` [RFC 10/11] selinux: Allow to invalidate an inode's security label Andreas Gruenbacher
2015-08-20 18:19 ` [RFC 11/11] gfs2: Invalide security labels of inodes that go invalid Andreas Gruenbacher
2015-08-21 6:49 ` Christoph Hellwig
2015-08-21 9:25 ` [Cluster-devel] " Andreas Gruenbacher
2015-08-24 17:42 ` [RFC 00/11] Inode security label invalidation Stephen Smalley
2015-08-24 19:13 ` Andreas Grünbacher
2015-08-24 20:47 ` Eric Paris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440094798-1411-7-git-send-email-agruenba@redhat.com \
--to=andreas.gruenbacher@gmail.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=bfields@fieldses.org \
--cc=cluster-devel@redhat.com \
--cc=dpquigl@davequigley.com \
--cc=eparis@redhat.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).