aboutsummaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2017-05-31 09:17:39 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2017-06-01 08:44:51 +1000
commit33f16ba0f7e3879861c4d166d08aff9cca57bfac (patch)
tree32ae733d9ea362d7c4ec4e9790353ad50fee6563 /Documentation
parent63243c1e81be299a9387d5651a9c57d18a639d86 (diff)
fault-inject: make fail-nth read/write interface symmetric
The read interface for fail-nth looks a bit odd. Read from this file returns "NYYYY..." or "YYYYY..." (this makes me surprise when cat this file). Because there is no EOF condition. The first character indicates current->fail_nth is zero or not, and then current->fail_nth is reset to zero. Just returning task->fail_nth value is more natural to understand. Link: http://lkml.kernel.org/r/1491490561-10485-4-git-send-email-akinobu.mita@gmail.com Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/fault-injection/fault-injection.txt13
1 files changed, 7 insertions, 6 deletions
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt
index a32190508751..370ddcbc2b44 100644
--- a/Documentation/fault-injection/fault-injection.txt
+++ b/Documentation/fault-injection/fault-injection.txt
@@ -139,9 +139,9 @@ o proc entries
- /proc/self/task/<current-tid>/fail-nth:
Write to this file of integer N makes N-th call in the task fail.
- Read from this file returns a single char 'Y' or 'N'
- that says if the fault setup with a previous write to this file was
- injected or not, and disables the fault if it wasn't yet injected.
+ Read from this file returns a integer value. A value of '0' indicates
+ that the fault setup with a previous write to this file was injected.
+ A positive integer N indicates that the fault wasn't yet injected.
Note that this file enables all types of faults (slab, futex, etc).
This setting takes precedence over all other generic debugfs settings
like probability, interval, times, etc. But per-capability settings
@@ -325,13 +325,14 @@ int main()
write(fail_nth, buf, strlen(buf));
res = socketpair(AF_LOCAL, SOCK_STREAM, 0, fds);
err = errno;
- read(fail_nth, buf, 1);
+ pread(fail_nth, buf, sizeof(buf), 0);
if (res == 0) {
close(fds[0]);
close(fds[1]);
}
- printf("%d-th fault %c: res=%d/%d\n", i, buf[0], res, err);
- if (buf[0] != 'Y')
+ printf("%d-th fault %c: res=%d/%d\n", i, atoi(buf) ? 'N' : 'Y',
+ res, err);
+ if (atoi(buf))
break;
}
return 0;