-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unfortunately there's a bunch of system calls missing.
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::{io, mem}; | ||
use std::io::Error; | ||
|
||
use super::*; | ||
|
||
pub fn punchfile(file: &File, offset: u64, length: u64) -> io::Result<()> { | ||
// TODO: On solaris we want fcntl(F_FREESP); | ||
let rqsr = libc::spacectl_range { | ||
r_offset: offset.try_into().unwrap(), | ||
r_len: length.try_into().unwrap(), | ||
}; | ||
let mut rmsr: libc::spacectl_range = unsafe { mem::zeroed() }; | ||
let rv = unsafe { | ||
libc::fspacectl( | ||
file.as_fd().as_raw_fd(), | ||
libc::SPACECTL_DEALLOC, | ||
&rqsr, | ||
0, | ||
&mut rmsr, | ||
) | ||
}; | ||
if rv == -1 { | ||
return Err(Error::last_os_error()); | ||
} | ||
if rmsr.r_len != 0 { | ||
warn!( | ||
req_off = rqsr.r_offset, | ||
req_len = rqsr.r_len, | ||
unproc_off = rmsr.r_offset, | ||
unproc_len = rmsr.r_len, | ||
"spacectl dealloc returned unprocessed part" | ||
); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters