xref: /openbmc/linux/fs/cachefiles/error_inject.c (revision 3d379b8d)
1a70f6526SDavid Howells // SPDX-License-Identifier: GPL-2.0-or-later
2a70f6526SDavid Howells /* Error injection handling.
3a70f6526SDavid Howells  *
4a70f6526SDavid Howells  * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
5a70f6526SDavid Howells  * Written by David Howells (dhowells@redhat.com)
6a70f6526SDavid Howells  */
7a70f6526SDavid Howells 
8a70f6526SDavid Howells #include <linux/sysctl.h>
9a70f6526SDavid Howells #include "internal.h"
10a70f6526SDavid Howells 
11a70f6526SDavid Howells unsigned int cachefiles_error_injection_state;
12a70f6526SDavid Howells 
13a70f6526SDavid Howells static struct ctl_table_header *cachefiles_sysctl;
14a70f6526SDavid Howells static struct ctl_table cachefiles_sysctls[] = {
15a70f6526SDavid Howells 	{
16a70f6526SDavid Howells 		.procname	= "error_injection",
17a70f6526SDavid Howells 		.data		= &cachefiles_error_injection_state,
18a70f6526SDavid Howells 		.maxlen		= sizeof(unsigned int),
19a70f6526SDavid Howells 		.mode		= 0644,
20a70f6526SDavid Howells 		.proc_handler	= proc_douintvec,
21a70f6526SDavid Howells 	},
22a70f6526SDavid Howells 	{}
23a70f6526SDavid Howells };
24a70f6526SDavid Howells 
cachefiles_register_error_injection(void)25a70f6526SDavid Howells int __init cachefiles_register_error_injection(void)
26a70f6526SDavid Howells {
27*3d379b8dSLuis Chamberlain 	cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls);
28a70f6526SDavid Howells 	if (!cachefiles_sysctl)
29a70f6526SDavid Howells 		return -ENOMEM;
30a70f6526SDavid Howells 	return 0;
31a70f6526SDavid Howells 
32a70f6526SDavid Howells }
33a70f6526SDavid Howells 
cachefiles_unregister_error_injection(void)34a70f6526SDavid Howells void cachefiles_unregister_error_injection(void)
35a70f6526SDavid Howells {
36a70f6526SDavid Howells 	unregister_sysctl_table(cachefiles_sysctl);
37a70f6526SDavid Howells }
38