static ssize_t mdd_changelog_mask_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct mdd_device *mdd = m->private; char *kernbuf; int rc; ENTRY; if (count >= PAGE_SIZE) RETURN(-EINVAL); OBD_ALLOC(kernbuf, PAGE_SIZE); if (kernbuf == NULL) RETURN(-ENOMEM); if (copy_from_user(kernbuf, buffer, count)) GOTO(out, rc = -EFAULT); kernbuf[count] = 0; rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask, CHANGELOG_MINMASK, CHANGELOG_ALLMASK); if (rc == 0) rc = count; out: OBD_FREE(kernbuf, PAGE_SIZE); return rc; }
int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) { const char *(*fn)(int bit) = is_subsys ? libcfs_debug_subsys2str : libcfs_debug_dbg2str; int m = 0; int matched; int n; int t; /* Allow a number for backwards compatibility */ for (n = strlen(str); n > 0; n--) if (!isspace(str[n-1])) break; matched = n; t = sscanf(str, "%i%n", &m, &matched); if (t >= 1 && matched == n) { /* don't print warning for lctl set_param debug=0 or -1 */ if (m != 0 && m != -1) CWARN("You are trying to use a numerical value for the mask - this will be deprecated in a future release.\n"); *mask = m; return 0; } return cfs_str2mask(str, fn, mask, is_subsys ? 0 : D_CANTMASK, 0xffffffff); }
static int lprocfs_wr_changelog_mask(struct file *file, const char *buffer, unsigned long count, void *data) { struct mdd_device *mdd = data; char *kernbuf; int rc; ENTRY; if (count >= PAGE_CACHE_SIZE) RETURN(-EINVAL); OBD_ALLOC(kernbuf, PAGE_CACHE_SIZE); if (kernbuf == NULL) RETURN(-ENOMEM); if (copy_from_user(kernbuf, buffer, count)) GOTO(out, rc = -EFAULT); kernbuf[count] = 0; rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask, CHANGELOG_MINMASK, CHANGELOG_ALLMASK); if (rc == 0) rc = count; out: OBD_FREE(kernbuf, PAGE_CACHE_SIZE); return rc; }