lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1447000500-29427-7-git-send-email-jsimmons@infradead.org>
Date:	Sun,  8 Nov 2015 11:35:00 -0500
From:	James Simmons <jsimmons@...radead.org>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	devel@...verdev.osuosl.org, Oleg Drokin <oleg.drokin@...el.com>,
	Andreas Dilger <andreas.dilger@...el.com>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	lustre-devel@...ts.lustre.org, Fan Yong <fan.yong@...el.com>
Subject: [PATCH] staging: lustre: add libcfs version of cfs_strrstr

From: Fan Yong <fan.yong@...el.com>

Create a kernel side function that does the same
thing as userland strrstr. This is from patch
http://review.whamcloud.com/7666.

Signed-off-by: Fan Yong <fan.yong@...el.com>
ntel-bug-id: https://jira.hpdd.intel.com/browse/LU-3951
Reviewed-on: http://review.whamcloud.com/7666
Reviewed-by: Andreas Dilger <andreas.dilger@...el.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@...el.com>
Reviewed-by: Oleg Drokin <oleg.drokin@...el.com>
---
 .../lustre/include/linux/libcfs/libcfs_string.h    |    1 +
 .../staging/lustre/lustre/libcfs/libcfs_string.c   |   27 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index d8d2e7d..052f684 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -44,6 +44,7 @@
 #define __LIBCFS_STRING_H__
 
 /* libcfs_string.c */
+char *cfs_strrstr(const char *haystack, const char *needle);
 /* string comparison ignoring case */
 int cfs_strncasecmp(const char *s1, const char *s2, size_t n);
 /* Convert a text string to a bitmask */
diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
index 05630f8..4e399ef 100644
--- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
+++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
@@ -42,6 +42,33 @@
 
 #include "../../include/linux/libcfs/libcfs.h"
 
+char *cfs_strrstr(const char *haystack, const char *needle)
+{
+	char *ptr;
+
+	if (unlikely(!haystack || !needle))
+		return NULL;
+
+	if (strlen(needle) == 1)
+		return strrchr(haystack, needle[0]);
+
+	ptr = strstr(haystack, needle);
+	if (ptr) {
+		while (1) {
+			char *tmp;
+
+			tmp = strstr(&ptr[1], needle);
+			if (!tmp)
+				return ptr;
+
+			ptr = tmp;
+		}
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(cfs_strrstr);
+
 /* Convert a text string to a bitmask */
 int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
 		 int *oldmask, int minmask, int allmask)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ