Allow seek beyond end of file.

This is enough to fix as. I don't know if it correctly fills the space
with zeros when writing beyond the current EOF.
This commit is contained in:
Ian Douglas Scott
2017-06-02 19:00:54 -07:00
parent 34f9b3f6df
commit 86353cdff5
+3 -3
View File
@@ -164,9 +164,9 @@ impl Resource for FileResource {
let size = fs.node_len(self.block)?;
self.seek = match whence {
SEEK_SET => max(0, min(size as i64, offset as i64)) as u64,
SEEK_CUR => max(0, min(size as i64, self.seek as i64 + offset as i64)) as u64,
SEEK_END => max(0, min(size as i64, size as i64 + offset as i64)) as u64,
SEEK_SET => max(0, offset as i64) as u64,
SEEK_CUR => max(0, self.seek as i64 + offset as i64) as u64,
SEEK_END => max(0, size as i64 + offset as i64) as u64,
_ => return Err(Error::new(EINVAL))
};