sysctl.c 862 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <linux/errno.h>
  2. #include <linux/printk.h>
  3. #include <linux/init.h>
  4. #include <linux/sysctl.h>
  5. #include <linux/usb.h>
  6. static int zero = 0;
  7. static int one = 1;
  8. static struct ctl_table usb_table[] = {
  9. {
  10. .procname = "deny_new_usb",
  11. .data = &deny_new_usb,
  12. .maxlen = sizeof(int),
  13. .mode = 0644,
  14. .proc_handler = proc_dointvec_minmax_sysadmin,
  15. .extra1 = &zero,
  16. .extra2 = &one,
  17. },
  18. { }
  19. };
  20. static struct ctl_table usb_root_table[] = {
  21. { .procname = "kernel",
  22. .mode = 0555,
  23. .child = usb_table },
  24. { }
  25. };
  26. static struct ctl_table_header *usb_table_header;
  27. int __init usb_init_sysctl(void)
  28. {
  29. usb_table_header = register_sysctl_table(usb_root_table);
  30. if (!usb_table_header) {
  31. pr_warn("usb: sysctl registration failed\n");
  32. return -ENOMEM;
  33. }
  34. return 0;
  35. }
  36. void usb_exit_sysctl(void)
  37. {
  38. unregister_sysctl_table(usb_table_header);
  39. }