sys_util: SharedMemory: Add into_file

This will be very useful in tests that need a file as it removes the
need for a temporary file to be created.

Change-Id: I7fb08209174c870279e34ee07aad7a3b05baaad9
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/864625
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Dylan Reid 2018-01-11 19:26:24 -08:00 committed by chrome-bot
parent c2051921b5
commit 61046bfe82

View file

@ -184,6 +184,12 @@ impl AsRawFd for SharedMemory {
}
}
impl Into<File> for SharedMemory {
fn into(self) -> File {
self.fd
}
}
/// Checks if the kernel we are running on has memfd_create. It was introduced in 3.17.
/// Only to be used from tests to prevent running on ancient kernels that won't
/// support the functionality anyways.