blob: 58f8aec964e4670ec8cd7175a7436ee8dc24bc70 [file] [log] [blame]
David Howellsa70f6522021-10-21 08:15:26 +01001// SPDX-License-Identifier: GPL-2.0-or-later
2/* Error injection handling.
3 *
4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#include <linux/sysctl.h>
9#include "internal.h"
10
11unsigned int cachefiles_error_injection_state;
12
13static struct ctl_table_header *cachefiles_sysctl;
14static struct ctl_table cachefiles_sysctls[] = {
15 {
16 .procname = "error_injection",
17 .data = &cachefiles_error_injection_state,
18 .maxlen = sizeof(unsigned int),
19 .mode = 0644,
20 .proc_handler = proc_douintvec,
21 },
22 {}
23};
24
25static struct ctl_table cachefiles_sysctls_root[] = {
26 {
27 .procname = "cachefiles",
28 .mode = 0555,
29 .child = cachefiles_sysctls,
30 },
31 {}
32};
33
34int __init cachefiles_register_error_injection(void)
35{
36 cachefiles_sysctl = register_sysctl_table(cachefiles_sysctls_root);
37 if (!cachefiles_sysctl)
38 return -ENOMEM;
39 return 0;
40
41}
42
43void cachefiles_unregister_error_injection(void)
44{
45 unregister_sysctl_table(cachefiles_sysctl);
46}