Skip to content

Commit ac46ff0

Browse files
committed
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()
2 parents 4522ae2 + 2138e89 commit ac46ff0

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

fs/orangefs/orangefs-debugfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static ssize_t orangefs_debug_read(struct file *file,
396396
goto out;
397397

398398
mutex_lock(&orangefs_debug_lock);
399-
sprintf_ret = sprintf(buf, "%s", (char *)file->private_data);
399+
sprintf_ret = scnprintf(buf, ORANGEFS_MAX_DEBUG_STRING_LEN, "%s", (char *)file->private_data);
400400
mutex_unlock(&orangefs_debug_lock);
401401

402402
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)
769769

770770
if (*mask & s_kmod_keyword_mask_map[index].mask_val) {
771771
if ((strlen(kernel_debug_string) +
772-
strlen(s_kmod_keyword_mask_map[index].keyword))
773-
< ORANGEFS_MAX_DEBUG_STRING_LEN - 1) {
772+
strlen(s_kmod_keyword_mask_map[index].keyword) + 1)
773+
< ORANGEFS_MAX_DEBUG_STRING_LEN) {
774774
strcat(kernel_debug_string,
775775
s_kmod_keyword_mask_map[index].keyword);
776776
strcat(kernel_debug_string, ",");
@@ -797,7 +797,7 @@ static void do_c_string(void *c_mask, int index)
797797
(mask->mask2 & cdm_array[index].mask2)) {
798798
if ((strlen(client_debug_string) +
799799
strlen(cdm_array[index].keyword) + 1)
800-
< ORANGEFS_MAX_DEBUG_STRING_LEN - 2) {
800+
< ORANGEFS_MAX_DEBUG_STRING_LEN) {
801801
strcat(client_debug_string,
802802
cdm_array[index].keyword);
803803
strcat(client_debug_string, ",");

fs/orangefs/orangefs-sysfs.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,36 +217,31 @@ static ssize_t sysfs_int_show(struct kobject *kobj,
217217

218218
if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
219219
if (!strcmp(attr->attr.name, "op_timeout_secs")) {
220-
rc = scnprintf(buf,
221-
PAGE_SIZE,
220+
rc = sysfs_emit(buf,
222221
"%d\n",
223222
op_timeout_secs);
224223
goto out;
225224
} else if (!strcmp(attr->attr.name,
226225
"slot_timeout_secs")) {
227-
rc = scnprintf(buf,
228-
PAGE_SIZE,
226+
rc = sysfs_emit(buf,
229227
"%d\n",
230228
slot_timeout_secs);
231229
goto out;
232230
} else if (!strcmp(attr->attr.name,
233231
"cache_timeout_msecs")) {
234-
rc = scnprintf(buf,
235-
PAGE_SIZE,
232+
rc = sysfs_emit(buf,
236233
"%d\n",
237234
orangefs_cache_timeout_msecs);
238235
goto out;
239236
} else if (!strcmp(attr->attr.name,
240237
"dcache_timeout_msecs")) {
241-
rc = scnprintf(buf,
242-
PAGE_SIZE,
238+
rc = sysfs_emit(buf,
243239
"%d\n",
244240
orangefs_dcache_timeout_msecs);
245241
goto out;
246242
} else if (!strcmp(attr->attr.name,
247243
"getattr_timeout_msecs")) {
248-
rc = scnprintf(buf,
249-
PAGE_SIZE,
244+
rc = sysfs_emit(buf,
250245
"%d\n",
251246
orangefs_getattr_timeout_msecs);
252247
goto out;
@@ -256,14 +251,12 @@ static ssize_t sysfs_int_show(struct kobject *kobj,
256251

257252
} else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
258253
if (!strcmp(attr->attr.name, "reads")) {
259-
rc = scnprintf(buf,
260-
PAGE_SIZE,
254+
rc = sysfs_emit(buf,
261255
"%lu\n",
262256
orangefs_stats.reads);
263257
goto out;
264258
} else if (!strcmp(attr->attr.name, "writes")) {
265-
rc = scnprintf(buf,
266-
PAGE_SIZE,
259+
rc = sysfs_emit(buf,
267260
"%lu\n",
268261
orangefs_stats.writes);
269262
goto out;
@@ -497,19 +490,18 @@ static ssize_t sysfs_service_op_show(struct kobject *kobj,
497490
if (strcmp(kobj->name, PC_KOBJ_ID)) {
498491
if (new_op->upcall.req.param.op ==
499492
ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
500-
rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
493+
rc = sysfs_emit(buf, "%d %d\n",
501494
(int)new_op->downcall.resp.param.u.
502495
value32[0],
503496
(int)new_op->downcall.resp.param.u.
504497
value32[1]);
505498
} else {
506-
rc = scnprintf(buf, PAGE_SIZE, "%d\n",
499+
rc = sysfs_emit(buf, "%d\n",
507500
(int)new_op->downcall.resp.param.u.value64);
508501
}
509502
} else {
510-
rc = scnprintf(
503+
rc = sysfs_emit(
511504
buf,
512-
PAGE_SIZE,
513505
"%s",
514506
new_op->downcall.resp.perf_count.buffer);
515507
}

0 commit comments

Comments
 (0)