mirror of
https://github.com/torvalds/linux.git
synced 2025-08-15 14:11:42 +02:00
orangefs: 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. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEWLOQAZkv9m2xtUCf/Vh1C1u0YnAFAmiJMgUACgkQ/Vh1C1u0 YnB27xAAgnJMTPfbrRF2El/WwpceZQzMtXyuzlBNgr5r3P04afEl38ztBMrwGKr1 mZlPciTQiCZElAhUHUOCG/pswMnALjBobS0rUGITKwWAv+Ttzr6InhwHc9w7aYm/ RBfVGaRMObAIiKpH5YSMwqVhkXsMk+G9Ekx/snx31LgBN6JiCgPHBAAAo5fhKixa ifyLuxsRJZAfgMzhMxuPVkjuNWrE8ee0e9bSkrNY+hMMKNtaLuhIAyuo7XZcAwCx 1qysJiTaxrHhn5A2Fc/s6GzhWMlXoNu76OniBpKDbHUGNKhFRXgb9yrb5k1ezgwv CMsVuPPi3p7gyUFPKGtUGZARqeKSoq2pvg5WR50DvgRFx4PyyPC5o/98sBo+ASJS Tvh5Kcuze1RqoyZIvj1/1eLYxxwywRVYjlurE1C8qEPTa+v6RkkCRk7V6vN++U2u cO4/2MtDLphsuGDJdC8/bzfhaBlUGQ2FuK6nVvLhNAvSeAA8qEPOxgQQZqDMc710 9KdbeL2kuisUZggplB7vmlmJfT/Qd6tTK1vvIkHNIgczLQTwIjVYtCblJvdbidBl 5GbLWFLq2rifR3U9s3exny9dpuFEF1Xm6YgVdCf0nSCg60F9UM2Og4Jt0enPzOTz Js+GCMOQsGDa2E/eZf0yr782KxTdP4uuhECP+Z/Yk1VSEdzEBow= =GCSM -----END PGP SIGNATURE----- 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:
commit
ac46ff0f77
2 changed files with 14 additions and 22 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue