/include/linux/utsname.h

https://github.com/airy09/android_kernel_sony_apq8064 · C Header · 113 lines · 91 code · 22 blank · 0 comment · 1 complexity · 8dd5e67c92444dd0db58fb7131136dc6 MD5 · raw file

  1. #ifndef _LINUX_UTSNAME_H
  2. #define _LINUX_UTSNAME_H
  3. #define __OLD_UTS_LEN 8
  4. struct oldold_utsname {
  5. char sysname[9];
  6. char nodename[9];
  7. char release[9];
  8. char version[9];
  9. char machine[9];
  10. };
  11. #define __NEW_UTS_LEN 64
  12. struct old_utsname {
  13. char sysname[65];
  14. char nodename[65];
  15. char release[65];
  16. char version[65];
  17. char machine[65];
  18. };
  19. struct new_utsname {
  20. char sysname[__NEW_UTS_LEN + 1];
  21. char nodename[__NEW_UTS_LEN + 1];
  22. char release[__NEW_UTS_LEN + 1];
  23. char version[__NEW_UTS_LEN + 1];
  24. char machine[__NEW_UTS_LEN + 1];
  25. char domainname[__NEW_UTS_LEN + 1];
  26. };
  27. #ifdef __KERNEL__
  28. #include <linux/sched.h>
  29. #include <linux/kref.h>
  30. #include <linux/nsproxy.h>
  31. #include <linux/err.h>
  32. enum uts_proc {
  33. UTS_PROC_OSTYPE,
  34. UTS_PROC_OSRELEASE,
  35. UTS_PROC_VERSION,
  36. UTS_PROC_HOSTNAME,
  37. UTS_PROC_DOMAINNAME,
  38. };
  39. struct user_namespace;
  40. extern struct user_namespace init_user_ns;
  41. struct uts_namespace {
  42. struct kref kref;
  43. struct new_utsname name;
  44. struct user_namespace *user_ns;
  45. };
  46. extern struct uts_namespace init_uts_ns;
  47. #ifdef CONFIG_UTS_NS
  48. static inline void get_uts_ns(struct uts_namespace *ns)
  49. {
  50. kref_get(&ns->kref);
  51. }
  52. extern struct uts_namespace *copy_utsname(unsigned long flags,
  53. struct task_struct *tsk);
  54. extern void free_uts_ns(struct kref *kref);
  55. static inline void put_uts_ns(struct uts_namespace *ns)
  56. {
  57. kref_put(&ns->kref, free_uts_ns);
  58. }
  59. #else
  60. static inline void get_uts_ns(struct uts_namespace *ns)
  61. {
  62. }
  63. static inline void put_uts_ns(struct uts_namespace *ns)
  64. {
  65. }
  66. static inline struct uts_namespace *copy_utsname(unsigned long flags,
  67. struct task_struct *tsk)
  68. {
  69. if (flags & CLONE_NEWUTS)
  70. return ERR_PTR(-EINVAL);
  71. return tsk->nsproxy->uts_ns;
  72. }
  73. #endif
  74. #ifdef CONFIG_PROC_SYSCTL
  75. extern void uts_proc_notify(enum uts_proc proc);
  76. #else
  77. static inline void uts_proc_notify(enum uts_proc proc)
  78. {
  79. }
  80. #endif
  81. static inline struct new_utsname *utsname(void)
  82. {
  83. return &current->nsproxy->uts_ns->name;
  84. }
  85. static inline struct new_utsname *init_utsname(void)
  86. {
  87. return &init_uts_ns.name;
  88. }
  89. extern struct rw_semaphore uts_sem;
  90. #endif /* __KERNEL__ */
  91. #endif /* _LINUX_UTSNAME_H */