sys_util: implement FromRawFd for EventFd

This is used to make EventFd passed over unix domain socket, such as by
the plugin API.

TEST=./build_test
BUG=chromium:800626

Change-Id: Ifd6c81c51b31a376d57a007bf413a836f3af870a
Reviewed-on: https://chromium-review.googlesource.com/857906
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
Zach Reizner 2018-01-09 15:01:36 -08:00 committed by chrome-bot
parent 3b1d8a5773
commit 20bb597636

View file

@ -83,6 +83,14 @@ impl AsRawFd for EventFd {
} }
} }
impl FromRawFd for EventFd {
unsafe fn from_raw_fd(fd: RawFd) -> Self {
EventFd {
eventfd: File::from_raw_fd(fd)
}
}
}
unsafe impl ::Pollable for EventFd { unsafe impl ::Pollable for EventFd {
fn pollable_fd(&self) -> RawFd { fn pollable_fd(&self) -> RawFd {
self.eventfd.as_raw_fd() self.eventfd.as_raw_fd()