mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
base: windows: pass &File to set_sparse_file()
This is only ever called with a File, so replace the AsRawDescriptor parameter to simplify it and prevent accidentally calling it with the wrong type (as mentioned by the comment, it must be a File anyway). BUG=None TEST=tools/dev_container tools/presubmit Change-Id: I08a87211f74983caeabe812448be4984e6f68cea Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5666315 Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
8b6a43e589
commit
43ff80a026
1 changed files with 2 additions and 4 deletions
|
@ -31,14 +31,12 @@ pub fn open_file_or_duplicate<P: AsRef<Path>>(path: P, options: &OpenOptions) ->
|
|||
|
||||
/// Marks the given file as sparse. Required if we want hole punching to be performant.
|
||||
/// (If a file is not marked as sparse, a hole punch will just write zeros.)
|
||||
/// # Safety
|
||||
/// handle *must* be File. We accept all AsRawDescriptors for convenience.
|
||||
pub fn set_sparse_file<T: AsRawDescriptor>(handle: &T) -> io::Result<()> {
|
||||
pub fn set_sparse_file(file: &File) -> io::Result<()> {
|
||||
// SAFETY:
|
||||
// Safe because we check the return value and handle is guaranteed to be a
|
||||
// valid file handle by the caller.
|
||||
let result = unsafe {
|
||||
super::ioctl::ioctl_with_ptr(handle, FSCTL_SET_SPARSE, std::ptr::null_mut::<c_void>())
|
||||
super::ioctl::ioctl_with_ptr(file, FSCTL_SET_SPARSE, std::ptr::null_mut::<c_void>())
|
||||
};
|
||||
if result != 0 {
|
||||
return Err(io::Error::from_raw_os_error(result));
|
||||
|
|
Loading…
Reference in a new issue