mirror of
https://github.com/torvalds/linux.git
synced 2025-12-01 07:26:02 +07:00
Merge tag 'for-linus-6.17-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux
Pull orangefs updates from Mike Marshall:
"Fixes for string handling in debugfs and sysfs:
- change scnprintf to sysfs_emit in sysfs code.
- change sprintf to scnprintf in debugfs code.
- refactor debugfs mask-to-string code for readability and slightly
improved functionality"
* tag 'for-linus-6.17-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
fs/orangefs: Allow 2 more characters in do_c_string()
fs: orangefs: replace scnprintf() with sysfs_emit()
fs/orangefs: use snprintf() instead of sprintf()
This commit is contained in:
@@ -396,7 +396,7 @@ static ssize_t orangefs_debug_read(struct file *file,
|
||||
goto out;
|
||||
|
||||
mutex_lock(&orangefs_debug_lock);
|
||||
sprintf_ret = sprintf(buf, "%s", (char *)file->private_data);
|
||||
sprintf_ret = scnprintf(buf, ORANGEFS_MAX_DEBUG_STRING_LEN, "%s", (char *)file->private_data);
|
||||
mutex_unlock(&orangefs_debug_lock);
|
||||
|
||||
read_ret = simple_read_from_buffer(ubuf, count, ppos, buf, sprintf_ret);
|
||||
@@ -769,8 +769,8 @@ static void do_k_string(void *k_mask, int index)
|
||||
|
||||
if (*mask & s_kmod_keyword_mask_map[index].mask_val) {
|
||||
if ((strlen(kernel_debug_string) +
|
||||
strlen(s_kmod_keyword_mask_map[index].keyword))
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN - 1) {
|
||||
strlen(s_kmod_keyword_mask_map[index].keyword) + 1)
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN) {
|
||||
strcat(kernel_debug_string,
|
||||
s_kmod_keyword_mask_map[index].keyword);
|
||||
strcat(kernel_debug_string, ",");
|
||||
@@ -797,7 +797,7 @@ static void do_c_string(void *c_mask, int index)
|
||||
(mask->mask2 & cdm_array[index].mask2)) {
|
||||
if ((strlen(client_debug_string) +
|
||||
strlen(cdm_array[index].keyword) + 1)
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN - 2) {
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN) {
|
||||
strcat(client_debug_string,
|
||||
cdm_array[index].keyword);
|
||||
strcat(client_debug_string, ",");
|
||||
|
||||
@@ -217,36 +217,31 @@ static ssize_t sysfs_int_show(struct kobject *kobj,
|
||||
|
||||
if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
|
||||
if (!strcmp(attr->attr.name, "op_timeout_secs")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%d\n",
|
||||
op_timeout_secs);
|
||||
goto out;
|
||||
} else if (!strcmp(attr->attr.name,
|
||||
"slot_timeout_secs")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%d\n",
|
||||
slot_timeout_secs);
|
||||
goto out;
|
||||
} else if (!strcmp(attr->attr.name,
|
||||
"cache_timeout_msecs")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%d\n",
|
||||
orangefs_cache_timeout_msecs);
|
||||
goto out;
|
||||
} else if (!strcmp(attr->attr.name,
|
||||
"dcache_timeout_msecs")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%d\n",
|
||||
orangefs_dcache_timeout_msecs);
|
||||
goto out;
|
||||
} else if (!strcmp(attr->attr.name,
|
||||
"getattr_timeout_msecs")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%d\n",
|
||||
orangefs_getattr_timeout_msecs);
|
||||
goto out;
|
||||
@@ -256,14 +251,12 @@ static ssize_t sysfs_int_show(struct kobject *kobj,
|
||||
|
||||
} else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
|
||||
if (!strcmp(attr->attr.name, "reads")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%lu\n",
|
||||
orangefs_stats.reads);
|
||||
goto out;
|
||||
} else if (!strcmp(attr->attr.name, "writes")) {
|
||||
rc = scnprintf(buf,
|
||||
PAGE_SIZE,
|
||||
rc = sysfs_emit(buf,
|
||||
"%lu\n",
|
||||
orangefs_stats.writes);
|
||||
goto out;
|
||||
@@ -497,19 +490,18 @@ out:
|
||||
if (strcmp(kobj->name, PC_KOBJ_ID)) {
|
||||
if (new_op->upcall.req.param.op ==
|
||||
ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
|
||||
rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
|
||||
rc = sysfs_emit(buf, "%d %d\n",
|
||||
(int)new_op->downcall.resp.param.u.
|
||||
value32[0],
|
||||
(int)new_op->downcall.resp.param.u.
|
||||
value32[1]);
|
||||
} else {
|
||||
rc = scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
rc = sysfs_emit(buf, "%d\n",
|
||||
(int)new_op->downcall.resp.param.u.value64);
|
||||
}
|
||||
} else {
|
||||
rc = scnprintf(
|
||||
rc = sysfs_emit(
|
||||
buf,
|
||||
PAGE_SIZE,
|
||||
"%s",
|
||||
new_op->downcall.resp.perf_count.buffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user