summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-09-18 02:08:11 -0700
committerShentubot <shentubot@google.com>2018-09-18 02:09:28 -0700
commitda20559137ccbf7f27e6008472f4d9159306df4a (patch)
tree72e7a905daa9de1c61e3754cf2ef2c233fd01443 /pkg
parent5d9816be41a967fa1fa9bbbe0c638dd322c7c0b1 (diff)
Provide better message when memfd_create fails with ENOSYS
Updates #100 PiperOrigin-RevId: 213414821 Change-Id: I90c2e6c18c54a6afcd7ad6f409f670aa31577d37
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/platform/filemem/filemem.go3
-rw-r--r--pkg/sentry/usage/memory.go3
2 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/platform/filemem/filemem.go b/pkg/sentry/platform/filemem/filemem.go
index feb020ef8..f278c8d63 100644
--- a/pkg/sentry/platform/filemem/filemem.go
+++ b/pkg/sentry/platform/filemem/filemem.go
@@ -233,6 +233,9 @@ func newFromFile(file *os.File) (*FileMem, error) {
func New(name string) (*FileMem, error) {
fd, err := memutil.CreateMemFD(name, 0)
if err != nil {
+ if e, ok := err.(syscall.Errno); ok && e == syscall.ENOSYS {
+ return nil, fmt.Errorf("memfd_create(2) is not implemented. Check that you have Linux 3.17 or higher")
+ }
return nil, err
}
return newFromFile(os.NewFile(uintptr(fd), name))
diff --git a/pkg/sentry/usage/memory.go b/pkg/sentry/usage/memory.go
index f13a77779..92a478d85 100644
--- a/pkg/sentry/usage/memory.go
+++ b/pkg/sentry/usage/memory.go
@@ -122,6 +122,9 @@ func Init() error {
const name = "memory-usage"
fd, err := memutil.CreateMemFD(name, 0)
if err != nil {
+ if e, ok := err.(syscall.Errno); ok && e == syscall.ENOSYS {
+ return fmt.Errorf("memfd_create(2) is not implemented. Check that you have Linux 3.17 or higher")
+ }
return fmt.Errorf("error creating usage file: %v", err)
}
file := os.NewFile(uintptr(fd), name)