This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / vs_cvirt.h
1 #ifndef _VX_VS_CVIRT_H
2 #define _VX_VS_CVIRT_H
3
4
5 // #define VX_DEBUG
6
7 #include "vserver/cvirt.h"
8 #include "vs_base.h"
9
10 #if defined(VX_DEBUG)
11 #define vxdprintk(x...) printk("vxd: " x)
12 #else
13 #define vxdprintk(x...)
14 #endif
15
16
17 /* utsname virtualization */
18
19 static inline struct new_utsname *vx_new_utsname(void)
20 {
21         if (current->vx_info)
22                 return &current->vx_info->cvirt.utsname;
23         return &system_utsname;
24 }
25
26 #define vx_new_uts(x)           ((vx_new_utsname())->x)
27
28
29 /* pid faking stuff */
30
31
32 #define vx_map_tgid(v,p) \
33         __vx_map_tgid((v), (p), __FILE__, __LINE__)
34
35 static inline int __vx_map_tgid(struct vx_info *vxi, int pid,
36         char *file, int line)
37 {
38         if (vxi && __vx_flags(vxi->vx_flags, VXF_INFO_INIT, 0)) {
39                 vxdprintk("vx_map_tgid: %p/%llx: %d -> %d in %s:%d\n",
40                         vxi, vxi->vx_flags, pid,
41                         (pid == vxi->vx_initpid)?1:pid,
42                         file, line);
43                 if (pid == vxi->vx_initpid)
44                         return 1;
45         }
46         return pid;
47 }
48
49 #define vx_rmap_tgid(v,p) \
50         __vx_rmap_tgid((v), (p), __FILE__, __LINE__)
51
52 static inline int __vx_rmap_tgid(struct vx_info *vxi, int pid,
53         char *file, int line)
54 {
55         if (vxi && __vx_flags(vxi->vx_flags, VXF_INFO_INIT, 0)) {
56                 vxdprintk("vx_rmap_tgid: %p/%llx: %d -> %d in %s:%d\n",
57                         vxi, vxi->vx_flags, pid,
58                         (pid == 1)?vxi->vx_initpid:pid,
59                         file, line);
60                 if ((pid == 1) && vxi->vx_initpid)
61                         return vxi->vx_initpid;
62         }
63         return pid;
64 }
65
66 #undef  vxdprintk
67 #define vxdprintk(x...)
68
69 #else
70 #warning duplicate inclusion
71 #endif