diff options
Diffstat (limited to 'shadows/framework/src/main/java/org/robolectric/shadows/ShadowLinux.java')
-rw-r--r-- | shadows/framework/src/main/java/org/robolectric/shadows/ShadowLinux.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLinux.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLinux.java index 41a109c7e..58405af44 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLinux.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLinux.java @@ -1,6 +1,7 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.N_MR1; +import static android.os.Build.VERSION_CODES.R; import android.os.Build; import android.system.ErrnoException; @@ -79,6 +80,18 @@ public class ShadowLinux { } } + @Implementation(minSdk = R) + protected FileDescriptor memfd_create(String name, int flags) throws ErrnoException { + try { + File tempFile = File.createTempFile(name, /* suffix= */ "robo_memfd"); + tempFile.deleteOnExit(); + RandomAccessFile randomAccessFile = new RandomAccessFile(tempFile, /* mode= */ "rw"); + return randomAccessFile.getFD(); + } catch (IOException e) { + throw new ErrnoException("memfd_create", OsConstants.EIO, e); + } + } + @Implementation protected int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { |