error_inject.c 851 B

123456789101112131415161718192021222324252627282930313233343536
  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 (dhowells@redhat.com)
  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 const 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. int __init cachefiles_register_error_injection(void)
  21. {
  22. cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls);
  23. if (!cachefiles_sysctl)
  24. return -ENOMEM;
  25. return 0;
  26. }
  27. void cachefiles_unregister_error_injection(void)
  28. {
  29. unregister_sysctl_table(cachefiles_sysctl);
  30. }