personality.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _LINUX_PERSONALITY_H
  2. #define _LINUX_PERSONALITY_H
  3. /*
  4.  * Handling of different ABIs (personalities).
  5.  */
  6. struct exec_domain;
  7. struct pt_regs;
  8. extern int register_exec_domain(struct exec_domain *);
  9. extern int unregister_exec_domain(struct exec_domain *);
  10. extern int __set_personality(unsigned long);
  11. /*
  12.  * Sysctl variables related to binary emulation.
  13.  */
  14. extern unsigned long abi_defhandler_coff;
  15. extern unsigned long abi_defhandler_elf;
  16. extern unsigned long abi_defhandler_lcall7;
  17. extern unsigned long abi_defhandler_libcso;
  18. extern int abi_fake_utsname;
  19. /*
  20.  * Flags for bug emulation.
  21.  *
  22.  * These occupy the top three bytes.
  23.  */
  24. enum {
  25. MMAP_PAGE_ZERO = 0x0100000,
  26. ADDR_LIMIT_32BIT = 0x0800000,
  27. SHORT_INODE = 0x1000000,
  28. WHOLE_SECONDS = 0x2000000,
  29. STICKY_TIMEOUTS = 0x4000000,
  30. };
  31. /*
  32.  * Personality types.
  33.  *
  34.  * These go in the low byte.  Avoid using the top bit, it will
  35.  * conflict with error returns.
  36.  */
  37. enum {
  38. PER_LINUX = 0x0000,
  39. PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT,
  40. PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
  41. PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
  42. PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS |
  43.  WHOLE_SECONDS | SHORT_INODE,
  44. PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
  45. PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
  46. PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS,
  47. PER_BSD = 0x0006,
  48. PER_SUNOS = 0x0006 | STICKY_TIMEOUTS,
  49. PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
  50. PER_LINUX32 = 0x0008,
  51. PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
  52. PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
  53. PER_IRIX64 = 0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
  54. PER_RISCOS = 0x000c,
  55. PER_SOLARIS = 0x000d | STICKY_TIMEOUTS,
  56. PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
  57. PER_HPUX = 0x000f,
  58. PER_OSF4 = 0x0010,  /* OSF/1 v4 */
  59. PER_MASK = 0x00ff,
  60. };
  61. /*
  62.  * Description of an execution domain.
  63.  * 
  64.  * The first two members are refernced from assembly source
  65.  * and should stay where they are unless explicitly needed.
  66.  */
  67. typedef void (*handler_t)(int, struct pt_regs *);
  68. struct exec_domain {
  69. const char *name; /* name of the execdomain */
  70. handler_t handler; /* handler for syscalls */
  71. unsigned char pers_low; /* lowest personality */
  72. unsigned char pers_high; /* highest personality */
  73. unsigned long *signal_map; /* signal mapping */
  74. unsigned long *signal_invmap; /* reverse signal mapping */
  75. struct map_segment *err_map; /* error mapping */
  76. struct map_segment *socktype_map; /* socket type mapping */
  77. struct map_segment *sockopt_map; /* socket option mapping */
  78. struct map_segment *af_map; /* address family mapping */
  79. struct module *module; /* module context of the ed. */
  80. struct exec_domain *next; /* linked list (internal) */
  81. };
  82. /*
  83.  * Return the base personality without flags.
  84.  */
  85. #define personality(pers) (pers & PER_MASK)
  86. /*
  87.  * Personality of the currently running process.
  88.  */
  89. #define get_personality (current->personality)
  90. /*
  91.  * Change personality of the currently running process.
  92.  */
  93. #define set_personality(pers) 
  94. ((current->personality == pers) ? 0 : __set_personality(pers))
  95. /*
  96.  * Load an execution domain.
  97.  */
  98. #define get_exec_domain(ep)
  99. do {
  100. if (ep != NULL && ep->module != NULL)
  101. __MOD_INC_USE_COUNT(ep->module);
  102. } while (0)
  103. /*
  104.  * Unload an execution domain.
  105.  */
  106. #define put_exec_domain(ep)
  107. do {
  108. if (ep != NULL && ep->module != NULL)
  109. __MOD_DEC_USE_COUNT(ep->module);
  110. } while (0)
  111. #endif /* _LINUX_PERSONALITY_H */