libcfs_debug.h \
libcfs_fail.h \
libcfs_hash.h \
- libcfs_private.h \
- libcfs_string.h
+ libcfs_private.h
#include <uapi/linux/lnet/libcfs_ioctl.h>
#include <libcfs/libcfs_debug.h>
#include <libcfs/libcfs_private.h>
-#include <libcfs/libcfs_string.h>
#include <libcfs/libcfs_hash.h>
#include <libcfs/libcfs_fail.h>
struct task_struct;
+/* Convert a text string to a bitmask */
+int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
+ u64 *oldmask, u64 minmask, u64 allmask, u64 defmask);
+int cfs_mask2str(char *str, int size, u64 mask, const char *(*bit2str)(int),
+ char sep);
+
int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys);
int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys);
void libcfs_debug_dumpstack(struct task_struct *tsk);
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0 */
-
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, 2017, Intel Corporation.
- */
-
-/*
- * This file is part of Lustre, http://www.lustre.org/
- *
- * Generic string manipulation functions.
- *
- * Author: Nathan Rutman <nathan.rutman@sun.com>
- */
-
-#ifndef __LIBCFS_STRING_H__
-#define __LIBCFS_STRING_H__
-
-/* libcfs_string.c */
-/* Convert a text string to a bitmask */
-int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
- u64 *oldmask, u64 minmask, u64 allmask, u64 defmask);
-int cfs_mask2str(char *str, int size, u64 mask, const char *(*bit2str)(int),
- char sep);
-
-/*
- * Structure to represent \<range_expr\> token of the syntax.
- */
-struct cfs_range_expr {
- /*
- * Link to cfs_expr_list::el_exprs.
- */
- struct list_head re_link;
- u32 re_lo;
- u32 re_hi;
- u32 re_stride;
-};
-
-struct cfs_expr_list {
- struct list_head el_link;
- struct list_head el_exprs;
-};
-
-int cfs_expr_list_match(u32 value, struct cfs_expr_list *expr_list);
-int cfs_expr_list_values(struct cfs_expr_list *expr_list,
- int max, u32 **values);
-void cfs_expr_list_free(struct cfs_expr_list *expr_list);
-int cfs_expr_list_parse(char *str, int len, unsigned int min, unsigned int max,
- struct cfs_expr_list **elpp);
-void cfs_expr_list_free_list(struct list_head *list);
-#define cfs_expr_list_values_free(values, num) CFS_FREE_PTR_ARRAY(values, num)
-
-#endif
libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
libcfs-crypto-objs := $(addprefix crypto/,$(libcfs-crypto-objs))
-libcfs-all-objs := debug.o fail.o module.o tracefile.o \
- libcfs_string.o hash.o
+libcfs-all-objs := debug.o fail.o module.o tracefile.o hash.o
libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
@LLCRYPT_TRUE@libcfs-objs += $(libcfs-crypto-objs)
#include <linux/module.h>
#include <linux/ctype.h>
-#include <libcfs/libcfs_string.h>
#include <linux/kthread.h>
#include <linux/stacktrace.h>
#include <linux/utsname.h>
return libcfs_debug_masks[debug];
}
+/* convert a binary mask to a string of bit names */
+int cfs_mask2str(char *str, int size, u64 mask, const char *(*bit2str)(int bit),
+ char sep)
+{
+ const char *token;
+ int len = 0;
+ int i;
+
+ if (mask == 0) { /* "0" */
+ if (size > 0)
+ str[0] = '0';
+ len = 1;
+ } else { /* space-separated tokens */
+ for (i = 0; i < 64; i++) {
+ if ((mask & BIT(i)) == 0)
+ continue;
+
+ token = bit2str(i);
+ if (!token) /* unused bit */
+ continue;
+
+ if (len > 0) { /* separator? */
+ if (len < size)
+ str[len] = sep;
+ len++;
+ }
+
+ while (*token != 0) {
+ if (len < size)
+ str[len] = *token;
+ token++;
+ len++;
+ }
+ }
+ }
+
+ /* terminate 'str' */
+ if (len < size)
+ str[len++] = '\n';
+ if (len < size)
+ str[len] = '\0';
+ else
+ str[size - 1] = '\0';
+
+ return len;
+}
+EXPORT_SYMBOL(cfs_mask2str);
+
+/* Convert a text string to a bitmask */
+int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
+ u64 *oldmask, u64 minmask, u64 allmask, u64 defmask)
+{
+ const char *debugstr;
+ u64 newmask = *oldmask, found = 0;
+
+ ENTRY;
+ /* <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) {
+ int i, len;
+ char op = 0;
+
+ while (isspace(*str) || *str == ',')
+ str++;
+ if (*str == 0)
+ break;
+ if (*str == '+' || *str == '-') {
+ op = *str++;
+ while (isspace(*str))
+ str++;
+ if (*str == 0) /* trailing op */
+ return -EINVAL;
+ } else if (!found)
+ newmask = minmask;
+
+
+ /* find token length */
+ for (len = 0; str[len] != 0 && !isspace(str[len]) &&
+ str[len] != '+' && str[len] != '-' && str[len] != ',';
+ len++);
+
+ /* match token */
+ found = 0;
+ for (i = 0; i < 32; i++) {
+ debugstr = bit2str(i);
+ if (debugstr != NULL &&
+ strlen(debugstr) == len &&
+ strncasecmp(str, debugstr, len) == 0) {
+ if (op == '-')
+ newmask &= ~BIT(i);
+ else
+ newmask |= BIT(i);
+ found = 1;
+ break;
+ }
+ }
+ if (!found && len == 3 &&
+ (strncasecmp(str, "ALL", len) == 0)) {
+ if (op == '-')
+ newmask = minmask;
+ else
+ newmask = allmask;
+ found = 1;
+ }
+ if (!found && strcasecmp(str, "DEFAULT") == 0) {
+ if (op == '-')
+ newmask = (newmask & ~defmask) | minmask;
+ else if (op == '+')
+ newmask |= defmask;
+ else
+ newmask = defmask;
+ found = 1;
+ }
+ if (!found) {
+ CWARN("unknown mask '%.*s'.\n"
+ "mask usage: [+|-]<all|type> ...\n", len, str);
+ return -EINVAL;
+ }
+ str += len;
+ }
+
+ *oldmask = newmask;
+ return 0;
+}
+EXPORT_SYMBOL(cfs_str2mask);
+
int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys)
{
const char *(*bit2str)(int bit) = is_subsys ? libcfs_debug_subsys2str :
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0
-
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, 2017, Intel Corporation.
- */
-
-/*
- * This file is part of Lustre, http://www.lustre.org/
- *
- * String manipulation functions.
- *
- * Author: Nathan Rutman <nathan.rutman@sun.com>
- */
-
-#include <linux/ctype.h>
-#include <libcfs/libcfs.h>
-#include <libcfs/libcfs_string.h>
-
-
-/* convert a binary mask to a string of bit names */
-int cfs_mask2str(char *str, int size, u64 mask, const char *(*bit2str)(int bit),
- char sep)
-{
- int len = 0;
- const char *token;
- int i;
-
- if (mask == 0) { /* "0" */
- if (size > 0)
- str[0] = '0';
- len = 1;
- } else { /* space-separated tokens */
- for (i = 0; i < 64; i++) {
- if ((mask & BIT(i)) == 0)
- continue;
-
- token = bit2str(i);
- if (!token) /* unused bit */
- continue;
-
- if (len > 0) { /* separator? */
- if (len < size)
- str[len] = sep;
- len++;
- }
-
- while (*token != 0) {
- if (len < size)
- str[len] = *token;
- token++;
- len++;
- }
- }
- }
-
- /* terminate 'str' */
- if (len < size)
- str[len++] = '\n';
- if (len < size)
- str[len] = '\0';
- else
- str[size - 1] = '\0';
-
- return len;
-}
-EXPORT_SYMBOL(cfs_mask2str);
-
-/* Convert a text string to a bitmask */
-int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
- u64 *oldmask, u64 minmask, u64 allmask, u64 defmask)
-{
- const char *debugstr;
- u64 newmask = *oldmask, found = 0;
-
- ENTRY;
- /* <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) {
- int i, len;
- char op = 0;
-
- while (isspace(*str) || *str == ',')
- str++;
- if (*str == 0)
- break;
- if (*str == '+' || *str == '-') {
- op = *str++;
- while (isspace(*str))
- str++;
- if (*str == 0) /* trailing op */
- return -EINVAL;
- } else if (!found)
- newmask = minmask;
-
-
- /* find token length */
- for (len = 0; str[len] != 0 && !isspace(str[len]) &&
- str[len] != '+' && str[len] != '-' && str[len] != ',';
- len++);
-
- /* match token */
- found = 0;
- for (i = 0; i < 32; i++) {
- debugstr = bit2str(i);
- if (debugstr != NULL &&
- strlen(debugstr) == len &&
- strncasecmp(str, debugstr, len) == 0) {
- if (op == '-')
- newmask &= ~BIT(i);
- else
- newmask |= BIT(i);
- found = 1;
- break;
- }
- }
- if (!found && len == 3 &&
- (strncasecmp(str, "ALL", len) == 0)) {
- if (op == '-')
- newmask = minmask;
- else
- newmask = allmask;
- found = 1;
- }
- if (!found && strcasecmp(str, "DEFAULT") == 0) {
- if (op == '-')
- newmask = (newmask & ~defmask) | minmask;
- else if (op == '+')
- newmask |= defmask;
- else
- newmask = defmask;
- found = 1;
- }
- if (!found) {
- CWARN("unknown mask '%.*s'.\n"
- "mask usage: [+|-]<all|type> ...\n", len, str);
- return -EINVAL;
- }
- str += len;
- }
-
- *oldmask = newmask;
- return 0;
-}
-EXPORT_SYMBOL(cfs_str2mask);
struct list_head *net_num_list,
struct list_head *addr);
+/* Structure to represent \<range_expr\> token of the syntax. */
+struct cfs_range_expr {
+ /* Link to cfs_expr_list::el_exprs. */
+ struct list_head re_link;
+ u32 re_lo;
+ u32 re_hi;
+ u32 re_stride;
+};
+
+struct cfs_expr_list {
+ struct list_head el_link;
+ struct list_head el_exprs;
+};
+
+int cfs_expr_list_match(u32 value, struct cfs_expr_list *expr_list);
+int cfs_expr_list_values(struct cfs_expr_list *expr_list,
+ int max, u32 **values);
+void cfs_expr_list_free(struct cfs_expr_list *expr_list);
+int cfs_expr_list_parse(char *str, int len, unsigned int min, unsigned int max,
+ struct cfs_expr_list **elpp);
+void cfs_expr_list_free_list(struct list_head *list);
+#define cfs_expr_list_values_free(values, num) CFS_FREE_PTR_ARRAY(values, num)
+
/* Max payload size */
#define LNET_MAX_PAYLOAD LNET_MTU
#include <linux/module.h>
#include <linux/slab.h>
-#include <libcfs/libcfs_string.h>
#include <libcfs/libcfs.h>
+#include <lnet/lib-types.h>
#include <lnet/lib-cpt.h>
/** virtual processing unit */
#include <obd_class.h>
#include <obd_support.h>
#include <lprocfs_status.h>
-#include <libcfs/libcfs_string.h>
#include "mdd_internal.h"
static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,