1 // SPDX-License-Identifier: GPL-2.0-or-later 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* Error injection handling. 2 /* Error injection handling. 3 * 3 * 4 * Copyright (C) 2021 Red Hat, Inc. All Rights 4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.c 5 * Written by David Howells (dhowells@redhat.com) 6 */ 6 */ 7 7 8 #include <linux/sysctl.h> 8 #include <linux/sysctl.h> 9 #include "internal.h" 9 #include "internal.h" 10 10 11 unsigned int cachefiles_error_injection_state; 11 unsigned int cachefiles_error_injection_state; 12 12 13 static struct ctl_table_header *cachefiles_sys 13 static struct ctl_table_header *cachefiles_sysctl; 14 static struct ctl_table cachefiles_sysctls[] = 14 static struct ctl_table cachefiles_sysctls[] = { 15 { 15 { 16 .procname = "error_injec 16 .procname = "error_injection", 17 .data = &cachefiles_ 17 .data = &cachefiles_error_injection_state, 18 .maxlen = sizeof(unsig 18 .maxlen = sizeof(unsigned int), 19 .mode = 0644, 19 .mode = 0644, 20 .proc_handler = proc_douintv 20 .proc_handler = proc_douintvec, 21 }, 21 }, >> 22 {} >> 23 }; >> 24 >> 25 static struct ctl_table cachefiles_sysctls_root[] = { >> 26 { >> 27 .procname = "cachefiles", >> 28 .mode = 0555, >> 29 .child = cachefiles_sysctls, >> 30 }, >> 31 {} 22 }; 32 }; 23 33 24 int __init cachefiles_register_error_injection 34 int __init cachefiles_register_error_injection(void) 25 { 35 { 26 cachefiles_sysctl = register_sysctl("c !! 36 cachefiles_sysctl = register_sysctl_table(cachefiles_sysctls_root); 27 if (!cachefiles_sysctl) 37 if (!cachefiles_sysctl) 28 return -ENOMEM; 38 return -ENOMEM; 29 return 0; 39 return 0; 30 40 31 } 41 } 32 42 33 void cachefiles_unregister_error_injection(voi 43 void cachefiles_unregister_error_injection(void) 34 { 44 { 35 unregister_sysctl_table(cachefiles_sys 45 unregister_sysctl_table(cachefiles_sysctl); 36 } 46 } 37 47
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.