utsname.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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[65];
  21. char nodename[65];
  22. char release[65];
  23. char version[65];
  24. char machine[65];
  25. char domainname[65];
  26. };
  27. #ifdef __KERNEL__
  28. #include <linux/sched.h>
  29. #include <linux/kref.h>
  30. #include <linux/nsproxy.h>
  31. #include <asm/atomic.h>
  32. struct uts_namespace {
  33. struct kref kref;
  34. struct new_utsname name;
  35. };
  36. extern struct uts_namespace init_uts_ns;
  37. static inline void get_uts_ns(struct uts_namespace *ns)
  38. {
  39. kref_get(&ns->kref);
  40. }
  41. #ifdef CONFIG_UTS_NS
  42. extern int unshare_utsname(unsigned long unshare_flags,
  43. struct uts_namespace **new_uts);
  44. extern int copy_utsname(int flags, struct task_struct *tsk);
  45. extern void free_uts_ns(struct kref *kref);
  46. static inline void put_uts_ns(struct uts_namespace *ns)
  47. {
  48. kref_put(&ns->kref, free_uts_ns);
  49. }
  50. #else
  51. static inline int unshare_utsname(unsigned long unshare_flags,
  52. struct uts_namespace **new_uts)
  53. {
  54. if (unshare_flags & CLONE_NEWUTS)
  55. return -EINVAL;
  56. return 0;
  57. }
  58. static inline int copy_utsname(int flags, struct task_struct *tsk)
  59. {
  60. return 0;
  61. }
  62. static inline void put_uts_ns(struct uts_namespace *ns)
  63. {
  64. }
  65. #endif
  66. static inline struct new_utsname *utsname(void)
  67. {
  68. return &current->nsproxy->uts_ns->name;
  69. }
  70. static inline struct new_utsname *init_utsname(void)
  71. {
  72. return &init_uts_ns.name;
  73. }
  74. extern struct rw_semaphore uts_sem;
  75. #endif /* __KERNEL__ */
  76. #endif /* _LINUX_UTSNAME_H */