Skip to content

Commit 0057475

Browse files
Wolfram SangJonathan Corbet
authored andcommitted
docs: fault-injection: fix non-working usage of negative values
Fault injection uses debugfs in a way that the provided values via sysfs are interpreted as u64. Providing negative numbers results in an error: /sys/kernel/debug/fail_function# echo -1 > times sh: write error: Invalid argument Update the docs and examples to use "printf %#x <val>" in these cases. For "retval", reword the paragraph a little and fix a typo. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/20210603125841.27436-1-wsa+renesas@sang-engineering.com Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 91a1265 commit 0057475

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

Documentation/fault-injection/fault-injection.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ configuration of fault-injection capabilities.
7878

7979
- /sys/kernel/debug/fail*/times:
8080

81-
specifies how many times failures may happen at most.
82-
A value of -1 means "no limit".
81+
specifies how many times failures may happen at most. A value of -1
82+
means "no limit". Note, though, that this file only accepts unsigned
83+
values. So, if you want to specify -1, you better use 'printf' instead
84+
of 'echo', e.g.: $ printf %#x -1 > times
8385

8486
- /sys/kernel/debug/fail*/space:
8587

@@ -167,11 +169,13 @@ configuration of fault-injection capabilities.
167169
- ERRNO: retval must be -1 to -MAX_ERRNO (-4096).
168170
- ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096).
169171

170-
- /sys/kernel/debug/fail_function/<functiuon-name>/retval:
172+
- /sys/kernel/debug/fail_function/<function-name>/retval:
171173

172-
specifies the "error" return value to inject to the given
173-
function for given function. This will be created when
174-
user specifies new injection entry.
174+
specifies the "error" return value to inject to the given function.
175+
This will be created when the user specifies a new injection entry.
176+
Note that this file only accepts unsigned values. So, if you want to
177+
use a negative errno, you better use 'printf' instead of 'echo', e.g.:
178+
$ printf %#x -12 > retval
175179

176180
Boot option
177181
^^^^^^^^^^^
@@ -255,7 +259,7 @@ Application Examples
255259
echo Y > /sys/kernel/debug/$FAILTYPE/task-filter
256260
echo 10 > /sys/kernel/debug/$FAILTYPE/probability
257261
echo 100 > /sys/kernel/debug/$FAILTYPE/interval
258-
echo -1 > /sys/kernel/debug/$FAILTYPE/times
262+
printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times
259263
echo 0 > /sys/kernel/debug/$FAILTYPE/space
260264
echo 2 > /sys/kernel/debug/$FAILTYPE/verbose
261265
echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -309,7 +313,7 @@ Application Examples
309313
echo N > /sys/kernel/debug/$FAILTYPE/task-filter
310314
echo 10 > /sys/kernel/debug/$FAILTYPE/probability
311315
echo 100 > /sys/kernel/debug/$FAILTYPE/interval
312-
echo -1 > /sys/kernel/debug/$FAILTYPE/times
316+
printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times
313317
echo 0 > /sys/kernel/debug/$FAILTYPE/space
314318
echo 2 > /sys/kernel/debug/$FAILTYPE/verbose
315319
echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -336,11 +340,11 @@ Application Examples
336340
FAILTYPE=fail_function
337341
FAILFUNC=open_ctree
338342
echo $FAILFUNC > /sys/kernel/debug/$FAILTYPE/inject
339-
echo -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval
343+
printf %#x -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval
340344
echo N > /sys/kernel/debug/$FAILTYPE/task-filter
341345
echo 100 > /sys/kernel/debug/$FAILTYPE/probability
342346
echo 0 > /sys/kernel/debug/$FAILTYPE/interval
343-
echo -1 > /sys/kernel/debug/$FAILTYPE/times
347+
printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times
344348
echo 0 > /sys/kernel/debug/$FAILTYPE/space
345349
echo 1 > /sys/kernel/debug/$FAILTYPE/verbose
346350

0 commit comments

Comments
 (0)