/
rlimits.go
116 lines (113 loc) · 2.52 KB
/
rlimits.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package processes
import (
"code.cloudfoundry.org/garden"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
func toRlimits(rlimits garden.ResourceLimits) (results []specs.POSIXRlimit) {
if rlimits.As != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_AS",
Soft: *rlimits.As,
Hard: *rlimits.As,
})
}
if rlimits.Core != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_CORE",
Soft: *rlimits.Core,
Hard: *rlimits.Core,
})
}
if rlimits.Cpu != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_CPU",
Soft: *rlimits.Cpu,
Hard: *rlimits.Cpu,
})
}
if rlimits.Data != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_DATA",
Soft: *rlimits.Data,
Hard: *rlimits.Data,
})
}
if rlimits.Fsize != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_FSIZE",
Soft: *rlimits.Fsize,
Hard: *rlimits.Fsize,
})
}
if rlimits.Locks != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_LOCKS",
Soft: *rlimits.Locks,
Hard: *rlimits.Locks,
})
}
if rlimits.Memlock != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_MEMLOCK",
Soft: *rlimits.Memlock,
Hard: *rlimits.Memlock,
})
}
if rlimits.Msgqueue != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_MSGQUEUE",
Soft: *rlimits.Msgqueue,
Hard: *rlimits.Msgqueue,
})
}
if rlimits.Nice != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_NICE",
Soft: *rlimits.Nice,
Hard: *rlimits.Nice,
})
}
if rlimits.Nofile != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_NOFILE",
Soft: *rlimits.Nofile,
Hard: *rlimits.Nofile,
})
}
if rlimits.Nproc != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_NPROC",
Soft: *rlimits.Nproc,
Hard: *rlimits.Nproc,
})
}
if rlimits.Rss != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_RSS",
Soft: *rlimits.Rss,
Hard: *rlimits.Rss,
})
}
if rlimits.Rtprio != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_RTPRIO",
Soft: *rlimits.Rtprio,
Hard: *rlimits.Rtprio,
})
}
if rlimits.Sigpending != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_SIGPENDING",
Soft: *rlimits.Sigpending,
Hard: *rlimits.Sigpending,
})
}
if rlimits.Stack != nil {
results = append(results, specs.POSIXRlimit{
Type: "RLIMIT_STACK",
Soft: *rlimits.Stack,
Hard: *rlimits.Stack,
})
}
return results
}