Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/api/filesystem/sync_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,9 @@ pub trait FileSystem {
}

/// Remap the external IDs in context to internal IDs.
fn id_remap(&self, ctx: &mut Context) -> io::Result<()> {
/// `nodeid` is the FUSE inode number, which may encode a filesystem index
/// (e.g. VfsInode) allowing per-mount id_mapping lookup.
fn id_remap(&self, ctx: &mut Context, _nodeid: Self::Inode) -> io::Result<()> {
Ok(())
}
}
Expand Down Expand Up @@ -1354,7 +1356,7 @@ impl<FS: FileSystem> FileSystem for Arc<FS> {
}

#[inline]
fn id_remap(&self, ctx: &mut Context) -> io::Result<()> {
self.deref().id_remap(ctx)
fn id_remap(&self, ctx: &mut Context, nodeid: Self::Inode) -> io::Result<()> {
self.deref().id_remap(ctx, nodeid)
}
}
4 changes: 4 additions & 0 deletions src/api/server/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ impl<F: AsyncFileSystem + Sync> Server<F> {
) -> Result<usize> {
let in_header = r.read_obj().map_err(Error::DecodeMessage)?;
let mut ctx = SrvContext::<F, S>::new(in_header, r, w);
let nodeid = ctx.nodeid();
self.fs
.id_remap(&mut ctx.context, nodeid)
.map_err(|e| Error::FailedToRemapID((ctx.context.uid, ctx.context.gid)))?;
if ctx.in_header.len > (MAX_BUFFER_SIZE + BUFFER_HEADER_SIZE)
|| ctx.w.available_bytes() < size_of::<OutHeader>()
{
Expand Down
3 changes: 2 additions & 1 deletion src/api/server/sync_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ impl<F: FileSystem + Sync> Server<F> {
) -> Result<usize> {
let in_header: InHeader = r.read_obj().map_err(Error::DecodeMessage)?;
let mut ctx = SrvContext::<F, S>::new(in_header, r, w);
let nodeid = ctx.nodeid();
self.fs
.id_remap(&mut ctx.context)
.id_remap(&mut ctx.context, nodeid)
.map_err(|e| Error::FailedToRemapID((ctx.context.uid, ctx.context.gid)))?;
if ctx.in_header.len > (MAX_BUFFER_SIZE + BUFFER_HEADER_SIZE) {
if in_header.opcode == Opcode::Forget as u32
Expand Down
19 changes: 17 additions & 2 deletions src/api/vfs/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ impl AsyncFileSystem for Vfs {
) -> Result<(libc::stat64, Duration)> {
match self.get_real_rootfs(inode)? {
(Left(fs), idata) => fs.getattr(ctx, idata.ino(), handle),
(Right(fs), idata) => fs.async_getattr(ctx, idata.ino(), handle).await,
(Right(fs), idata) => {
fs.async_getattr(ctx, idata.ino(), handle)
.await
.map(|(mut attr, duration)| {
attr.st_ino = idata.into();
self.remap_attr_id(idata.fs_idx(), true, &mut attr);
(attr, duration)
})
}
}
}

Expand All @@ -54,8 +62,15 @@ impl AsyncFileSystem for Vfs {
match self.get_real_rootfs(inode)? {
(Left(fs), idata) => fs.setattr(ctx, idata.ino(), attr, handle, valid),
(Right(fs), idata) => {
let mut attr = attr;
self.remap_attr_id(idata.fs_idx(), false, &mut attr);
fs.async_setattr(ctx, idata.ino(), attr, handle, valid)
.await
.map(|(mut attr, duration)| {
attr.st_ino = idata.into();
self.remap_attr_id(idata.fs_idx(), true, &mut attr);
(attr, duration)
})
}
}
}
Expand Down Expand Up @@ -224,7 +239,7 @@ mod tests {
pid: 0,
};

assert!(vfs.mount(Box::new(fs), "/x/y").is_ok());
assert!(vfs.mount(Box::new(fs), "/x/y", None).is_ok());

let handle = tokio::spawn(async move {
// Lookup inode on pseudo file system.
Expand Down
Loading
Loading