VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / linux / vs_cvirt.h
1 #ifndef _VX_VS_CVIRT_H
2 #define _VX_VS_CVIRT_H
3
4 #include "vserver/cvirt.h"
5 #include "vserver/debug.h"
6 #include "vs_base.h"
7
8
9 /* utsname virtualization */
10
11 static inline struct new_utsname *vx_new_utsname(void)
12 {
13         if (current->vx_info)
14                 return &current->vx_info->cvirt.utsname;
15         return &system_utsname;
16 }
17
18 #define vx_new_uts(x)           ((vx_new_utsname())->x)
19
20
21 /* pid faking stuff */
22
23
24 #define vx_map_tgid(v,p) \
25         __vx_map_tgid((v), (p), __FILE__, __LINE__)
26
27 static inline int __vx_map_tgid(struct vx_info *vxi, int pid,
28         char *file, int line)
29 {
30         if (vxi && __vx_flags(vxi->vx_flags, VXF_INFO_INIT, 0)) {
31                 vxlprintk(VXD_CBIT(cvirt, 2),
32                         "vx_map_tgid: %p/%llx: %d -> %d",
33                         vxi, vxi->vx_flags, pid,
34                         (pid == vxi->vx_initpid)?1:pid,
35                         file, line);
36                 if (pid == vxi->vx_initpid)
37                         return 1;
38         }
39         return pid;
40 }
41
42 #define vx_rmap_tgid(v,p) \
43         __vx_rmap_tgid((v), (p), __FILE__, __LINE__)
44
45 static inline int __vx_rmap_tgid(struct vx_info *vxi, int pid,
46         char *file, int line)
47 {
48         if (vxi && __vx_flags(vxi->vx_flags, VXF_INFO_INIT, 0)) {
49                 vxlprintk(VXD_CBIT(cvirt, 2),
50                         "vx_rmap_tgid: %p/%llx: %d -> %d",
51                         vxi, vxi->vx_flags, pid,
52                         (pid == 1)?vxi->vx_initpid:pid,
53                         file, line);
54                 if ((pid == 1) && vxi->vx_initpid)
55                         return vxi->vx_initpid;
56         }
57         return pid;
58 }
59
60
61 #else
62 #warning duplicate inclusion
63 #endif