summaryrefslogtreecommitdiff
path: root/pkg/spec/spec_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-11 21:35:37 +0200
committerGitHub <noreply@github.com>2019-07-11 21:35:37 +0200
commit2b64f8844655b7188332a404ec85d32c33feb9e9 (patch)
treeafcbaa55ba396ac68ebdc87ad15f1554e6ee1e5d /pkg/spec/spec_linux.go
parent24409daa36137406a403ae8e22cf71afa590c746 (diff)
parentfb88074e68db25474290535e8a778e39434cc2a2 (diff)
downloadpodman-2b64f8844655b7188332a404ec85d32c33feb9e9.tar.gz
podman-2b64f8844655b7188332a404ec85d32c33feb9e9.tar.bz2
podman-2b64f8844655b7188332a404ec85d32c33feb9e9.zip
Merge pull request #3491 from giuseppe/rlimit-host
podman: add --ulimit host
Diffstat (limited to 'pkg/spec/spec_linux.go')
-rw-r--r--pkg/spec/spec_linux.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkg/spec/spec_linux.go b/pkg/spec/spec_linux.go
new file mode 100644
index 000000000..fcdfc5c4e
--- /dev/null
+++ b/pkg/spec/spec_linux.go
@@ -0,0 +1,42 @@
+//+build linux
+
+package createconfig
+
+import (
+ "syscall"
+
+ "github.com/pkg/errors"
+)
+
+type systemRlimit struct {
+ name string
+ value int
+}
+
+var systemLimits = []systemRlimit{
+ {"RLIMIT_AS", syscall.RLIMIT_AS},
+ {"RLIMIT_CORE", syscall.RLIMIT_CORE},
+ {"RLIMIT_CPU", syscall.RLIMIT_CPU},
+ {"RLIMIT_DATA", syscall.RLIMIT_DATA},
+ {"RLIMIT_FSIZE", syscall.RLIMIT_FSIZE},
+ {"RLIMIT_NOFILE", syscall.RLIMIT_NOFILE},
+ {"RLIMIT_STACK", syscall.RLIMIT_STACK},
+}
+
+func getHostRlimits() ([]systemUlimit, error) {
+ ret := []systemUlimit{}
+ for _, i := range systemLimits {
+ var l syscall.Rlimit
+ if err := syscall.Getrlimit(i.value, &l); err != nil {
+ return nil, errors.Wrapf(err, "cannot read limits for %s", i.name)
+ }
+ s := systemUlimit{
+ name: i.name,
+ max: l.Max,
+ cur: l.Cur,
+ }
+ ret = append(ret, s)
+ }
+ return ret, nil
+
+}