.sysfs_ops = &ceph_sysfs_ops,
};
-/*
- * simple int attrs (debug levels)
- */
-static ssize_t int_attr_show(struct ceph_attr *a, char *buf)
-{
- return sprintf(buf, "%d\n", *a->val);
-}
-
-static ssize_t int_attr_store(struct ceph_attr *a, const char *buf, size_t len)
-{
- if (sscanf(buf, "%d", a->val) < 1)
- return 0;
- return len;
-}
-
-#define DECLARE_DEBUG_ATTR(_name) \
- static struct ceph_attr ceph_attr_##_name = { \
- .attr = { .name = __stringify(_name), .mode = 0600 }, \
- .show = int_attr_show, \
- .store = int_attr_store, \
- .val = &ceph_##_name, \
- };
-
-DECLARE_DEBUG_ATTR(debug);
-DECLARE_DEBUG_ATTR(debug_msgr);
-DECLARE_DEBUG_ATTR(debug_console);
-
-/*
- * ceph_debug_mask
- */
-struct _debug_mask_name {
- int mask;
- char *name;
-};
-
-static struct _debug_mask_name _debug_mask_names[] = {
- {DOUT_MASK_ADDR, "addr"},
- {DOUT_MASK_CAPS, "caps"},
- {DOUT_MASK_DIR, "dir"},
- {DOUT_MASK_EXPORT, "export"},
- {DOUT_MASK_FILE, "file"},
- {DOUT_MASK_INODE, "inode"},
- {DOUT_MASK_IOCTL, "ioctl"},
- {DOUT_MASK_MDSC, "mdsc"},
- {DOUT_MASK_MDSMAP, "mdsmap"},
- {DOUT_MASK_MSGR, "msgr"},
- {DOUT_MASK_MON, "mon"},
- {DOUT_MASK_OSDC, "osdc"},
- {DOUT_MASK_OSDMAP, "osdmap"},
- {DOUT_MASK_SNAP, "snap"},
- {DOUT_MASK_SUPER, "super"},
- {DOUT_MASK_PROTOCOL, "protocol"},
- {DOUT_MASK_PROC, "proc"},
- {DOUT_MASK_TOOLS, "tools"},
- {0, NULL}
-};
-
-static ssize_t debug_mask_show(struct ceph_attr *a, char *buf)
-{
- int i = 0, pos;
-
- pos = sprintf(buf, "0x%x", ceph_debug_mask);
-
- while (_debug_mask_names[i].mask) {
- if (ceph_debug_mask & _debug_mask_names[i].mask)
- pos += sprintf(buf+pos, " %s",
- _debug_mask_names[i].name);
- i++;
- }
- pos += sprintf(buf+pos, "\n");
- return pos;
-}
-
-static int get_debug_mask(const char *name, int len)
-{
- int i = 0;
-
- while (_debug_mask_names[i].name) {
- if (strncmp(_debug_mask_names[i].name, name, len) == 0)
- return _debug_mask_names[i].mask;
- i++;
- }
- return 0;
-}
-
-static ssize_t debug_mask_store(struct ceph_attr *a, const char *buf,
- size_t len)
-{
- const char *next = buf, *tok;
-
- while (1) {
- tok = next;
- next = strpbrk(tok, " \t\r\n");
- if (!next)
- break;
- if (isdigit(*tok)) {
- ceph_debug_mask = simple_strtol(tok, NULL, 0);
- } else {
- int remove = 0;
- int mask;
-
- if (*tok == '-') {
- remove = 1;
- tok++;
- } else if (*tok == '+')
- tok++;
- mask = get_debug_mask(tok, next-tok);
- if (mask) {
- if (remove)
- ceph_debug_mask &= ~mask;
- else
- ceph_debug_mask |= mask;
- }
- }
- next++;
- }
-
- return len;
-}
-
-static struct ceph_attr ceph_attr_debug_mask = {
- .attr = { .name = "debug_mask", .mode = 0600 },
- .show = debug_mask_show,
- .store = debug_mask_store,
-};
-
int ceph_sysfs_init(void)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
int ret;
ret = kobject_init_and_add(&ceph_kobj, &ceph_type, fs_kobj, "ceph");
- if (ret)
- goto out;
- ret = sysfs_create_file(&ceph_kobj, &ceph_attr_debug.attr);
- if (ret)
- goto out_del;
- ret = sysfs_create_file(&ceph_kobj, &ceph_attr_debug_msgr.attr);
- if (ret)
- goto out_del;
- ret = sysfs_create_file(&ceph_kobj, &ceph_attr_debug_console.attr);
- if (ret)
- goto out_del;
- ret = sysfs_create_file(&ceph_kobj, &ceph_attr_debug_mask.attr);
- if (ret)
- goto out_del;
- return 0;
-out_del:
- kobject_del(&ceph_kobj);
-out:
return ret;
#else
return 0;