diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2020-01-07 17:51:04 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-13 21:16:29 +0000 |
commit | d5aa9954237f9eb9c7ec468362fb8262f0975429 (patch) | |
tree | b003550c00fa349cf0eed758b6a5ce02508f5290 /sys_util | |
parent | 54305cd5e2d52d274c20dd294c9c869a0115e96d (diff) | |
download | crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.tar crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.tar.gz crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.tar.bz2 crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.tar.lz crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.tar.xz crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.tar.zst crosvm-d5aa9954237f9eb9c7ec468362fb8262f0975429.zip |
disk: use seek to determine file length
Add a new disk-specific DiskGetLen trait which uses io::Seek instead of File::metadata() to determine the length so that it works on raw block devices (e.g. /dev/sda) as well as regular files. BUG=b:146811529 TEST=`crosvm run --disk /dev/sda` and verify block device length Change-Id: I6936863490efaa479a3c8745c75c373748c800a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1990855 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Trent Begin <tbegin@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'sys_util')
-rw-r--r-- | sys_util/src/file_traits.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys_util/src/file_traits.rs b/sys_util/src/file_traits.rs index 7e615d6..c4b1082 100644 --- a/sys_util/src/file_traits.rs +++ b/sys_util/src/file_traits.rs @@ -3,7 +3,7 @@ // found in the LICENSE file. use std::fs::File; -use std::io::{Error, ErrorKind, Result}; +use std::io::{Error, ErrorKind, Result, Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, RawFd}; use data_model::VolatileSlice; |