error_inject.c 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // 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 ([email protected])
  6. */
  7. #include <linux/sysctl.h>
  8. #include "internal.h"
  9. unsigned int cachefiles_error_injection_state;
  10. static struct ctl_table_header *cachefiles_sysctl;
  11. static struct ctl_table cachefiles_sysctls[] = {
  12. {
  13. .procname = "error_injection",
  14. .data = &cachefiles_error_injection_state,
  15. .maxlen = sizeof(unsigned int),
  16. .mode = 0644,
  17. .proc_handler = proc_douintvec,
  18. },
  19. {}
  20. };
  21. static struct ctl_table cachefiles_sysctls_root[] = {
  22. {
  23. .procname = "cachefiles",
  24. .mode = 0555,
  25. .child = cachefiles_sysctls,
  26. },
  27. {}
  28. };
  29. int __init cachefiles_register_error_injection(void)
  30. {
  31. cachefiles_sysctl = register_sysctl_table(cachefiles_sysctls_root);
  32. if (!cachefiles_sysctl)
  33. return -ENOMEM;
  34. return 0;
  35. }
  36. void cachefiles_unregister_error_injection(void)
  37. {
  38. unregister_sysctl_table(cachefiles_sysctl);
  39. }