qcow: add no-op set_len() for QcowFile

We won't support resizing a QcowFile for now, since it would require
resizing refcount and L1 tables.

BUG=chromium:858815
TEST=build_test

Change-Id: Ia108e07be8b06b6fbe81838831a8ecbffdfb341c
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1394149
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
Daniel Verkamp 2018-12-06 15:47:36 -08:00 committed by chrome-bot
parent 6d47e1b005
commit e57d906dbb

View file

@ -24,7 +24,7 @@ use std::io::{self, Read, Seek, SeekFrom, Write};
use std::mem::size_of;
use std::os::unix::io::{AsRawFd, RawFd};
use sys_util::{FileSync, PunchHole, SeekHole, WriteZeroes};
use sys_util::{FileSetLen, FileSync, PunchHole, SeekHole, WriteZeroes};
#[derive(Debug)]
pub enum Error {
@ -1382,6 +1382,15 @@ impl FileSync for QcowFile {
}
}
impl FileSetLen for QcowFile {
fn set_len(&self, _len: u64) -> std::io::Result<()> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"set_len() not supported for QcowFile",
))
}
}
impl PunchHole for QcowFile {
fn punch_hole(&mut self, offset: u64, length: u64) -> std::io::Result<()> {
let mut remaining = length;