Whamcloud - gitweb
LU-3951 lfsck: LWP connection from OST-x to MDT-y
[fs/lustre-release.git] / libcfs / libcfs / libcfs_string.c
index be26f93..1d7a941 100644 (file)
 
 #include <libcfs/libcfs.h>
 
+char *cfs_strrstr(const char *haystack, const char *needle)
+{
+       char *ptr;
+
+       if (unlikely(haystack == NULL || needle == NULL))
+               return NULL;
+
+       if (strlen(needle) == 1)
+               return strrchr(haystack, needle[0]);
+
+       ptr = strstr(haystack, needle);
+       if (ptr != NULL) {
+               while (1) {
+                       char *tmp;
+
+                       tmp = strstr(&ptr[1], needle);
+                       if (tmp == NULL)
+                               return ptr;
+
+                       ptr = tmp;
+               }
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL(cfs_strrstr);
+
 /* non-0 = don't match */
 int cfs_strncasecmp(const char *s1, const char *s2, size_t n)
 {