*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* String manipulation functions.
*
#include <libcfs/libcfs.h>
#include <libcfs/libcfs_string.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);
-
/* Convert a text string to a bitmask */
int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
int *oldmask, int minmask, int allmask)
int newmask = minmask, i, len, found = 0;
ENTRY;
- /* <str> must be a list of tokens separated by whitespace
+ /* <str> must be a list of tokens separated by whitespace or comma,
* and optionally an operator ('+' or '-'). If an operator
* appears first in <str>, '*oldmask' is used as the starting point
* (relative), otherwise minmask is used (absolute). An operator
* applies to all following tokens up to the next operator.
*/
while (*str != 0) {
- while (isspace(*str))
+ while (isspace(*str) || *str == ',')
str++;
if (*str == 0)
break;
/* find token length */
for (len = 0; str[len] != 0 && !isspace(str[len]) &&
- str[len] != '+' && str[len] != '-'; len++);
+ str[len] != '+' && str[len] != '-' && str[len] != ',';
+ len++);
/* match token */
found = 0;