mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vhost_user_fs: Implement support for FUSE_LSEEK
Implement missing support for FUSE_LSEEK, which basically implies calling to libc::lseek on the file handle. As this operation alters the file offset, we take a write lock on the File's RwLock. Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
committed by
Rob Bradford
parent
5aa9abca5e
commit
c821e96e2a
@@ -1241,11 +1241,24 @@ impl<F: FileSystem + Sync> Server<F> {
|
||||
}
|
||||
}
|
||||
|
||||
fn lseek(&self, in_header: InHeader, mut _r: Reader, w: Writer) -> Result<usize> {
|
||||
if let Err(e) = self.fs.lseek() {
|
||||
reply_error(e, in_header.unique, w)
|
||||
} else {
|
||||
Ok(0)
|
||||
fn lseek(&self, in_header: InHeader, mut r: Reader, w: Writer) -> Result<usize> {
|
||||
let LseekIn {
|
||||
fh, offset, whence, ..
|
||||
} = r.read_obj().map_err(Error::DecodeMessage)?;
|
||||
|
||||
match self.fs.lseek(
|
||||
Context::from(in_header),
|
||||
in_header.nodeid.into(),
|
||||
fh.into(),
|
||||
offset,
|
||||
whence,
|
||||
) {
|
||||
Ok(offset) => {
|
||||
let out = LseekOut { offset };
|
||||
|
||||
reply_ok(Some(out), None, in_header.unique, w)
|
||||
}
|
||||
Err(e) => reply_error(e, in_header.unique, w),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user