kmod.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef __LINUX_KMOD_H__
  2. #define __LINUX_KMOD_H__
  3. /*
  4. * include/linux/kmod.h
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <linux/stddef.h>
  21. #include <linux/errno.h>
  22. #include <linux/compiler.h>
  23. #define KMOD_PATH_LEN 256
  24. #ifdef CONFIG_KMOD
  25. /* modprobe exit status on success, -ve on error. Return value
  26. * usually useless though. */
  27. extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2)));
  28. #else
  29. static inline int request_module(const char * name, ...) { return -ENOSYS; }
  30. #endif
  31. #define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
  32. struct key;
  33. struct file;
  34. struct subprocess_info;
  35. /* Allocate a subprocess_info structure */
  36. struct subprocess_info *call_usermodehelper_setup(char *path,
  37. char **argv, char **envp);
  38. /* Set various pieces of state into the subprocess_info structure */
  39. void call_usermodehelper_setkeys(struct subprocess_info *info,
  40. struct key *session_keyring);
  41. int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info,
  42. struct file **filp);
  43. void call_usermodehelper_setcleanup(struct subprocess_info *info,
  44. void (*cleanup)(char **argv, char **envp));
  45. /* Actually execute the sub-process */
  46. int call_usermodehelper_exec(struct subprocess_info *info, int wait);
  47. /* Free the subprocess_info. This is only needed if you're not going
  48. to call call_usermodehelper_exec */
  49. void call_usermodehelper_freeinfo(struct subprocess_info *info);
  50. static inline int
  51. call_usermodehelper(char *path, char **argv, char **envp, int wait)
  52. {
  53. struct subprocess_info *info;
  54. info = call_usermodehelper_setup(path, argv, envp);
  55. if (info == NULL)
  56. return -ENOMEM;
  57. return call_usermodehelper_exec(info, wait);
  58. }
  59. static inline int
  60. call_usermodehelper_keys(char *path, char **argv, char **envp,
  61. struct key *session_keyring, int wait)
  62. {
  63. struct subprocess_info *info;
  64. info = call_usermodehelper_setup(path, argv, envp);
  65. if (info == NULL)
  66. return -ENOMEM;
  67. call_usermodehelper_setkeys(info, session_keyring);
  68. return call_usermodehelper_exec(info, wait);
  69. }
  70. extern void usermodehelper_init(void);
  71. struct file;
  72. extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
  73. struct file **filp);
  74. #endif /* __LINUX_KMOD_H__ */