Skip to content

Commit 1031db0

Browse files
sctb512bergwolf
authored andcommitted
vfs: fix incorrect st_ino in entry.attr
At present, the entry.inode is the correct inode number, but the linux kernel uses the entry.attr.st_ino as inode number. So, we should correct the value of entry.attr.st_ino to let it work. Signed-off-by: Bin Tang <[email protected]>
1 parent 4108ccd commit 1031db0

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/api/vfs/sync_io.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ impl FileSystem for Vfs {
105105
) -> Result<(stat64, Duration)> {
106106
match self.get_real_rootfs(inode)? {
107107
(Left(fs), idata) => fs.getattr(ctx, idata.ino(), handle),
108-
(Right(fs), idata) => fs.getattr(ctx, idata.ino(), handle),
108+
(Right(fs), idata) => {
109+
fs.getattr(ctx, idata.ino(), handle)
110+
.map(|(mut attr, duration)| {
111+
attr.st_ino = idata.into();
112+
(attr, duration)
113+
})
114+
}
109115
}
110116
}
111117

@@ -119,7 +125,13 @@ impl FileSystem for Vfs {
119125
) -> Result<(stat64, Duration)> {
120126
match self.get_real_rootfs(inode)? {
121127
(Left(fs), idata) => fs.setattr(ctx, idata.ino(), attr, handle, valid),
122-
(Right(fs), idata) => fs.setattr(ctx, idata.ino(), attr, handle, valid),
128+
(Right(fs), idata) => {
129+
fs.setattr(ctx, idata.ino(), attr, handle, valid)
130+
.map(|(mut attr, duration)| {
131+
attr.st_ino = idata.into();
132+
(attr, duration)
133+
})
134+
}
123135
}
124136
}
125137

@@ -574,7 +586,7 @@ impl FileSystem for Vfs {
574586
entry.inode = dir_entry.ino;
575587
}
576588
}
577-
589+
entry.attr.st_ino = entry.inode;
578590
add_entry(dir_entry, entry)
579591
},
580592
),
@@ -585,8 +597,10 @@ impl FileSystem for Vfs {
585597
handle,
586598
size,
587599
offset,
588-
&mut |dir_entry, mut entry| {
589-
entry.inode = self.convert_inode(idata.fs_idx(), entry.inode)?;
600+
&mut |mut dir_entry, mut entry| {
601+
dir_entry.ino = self.convert_inode(idata.fs_idx(), entry.inode)?;
602+
entry.inode = dir_entry.ino;
603+
entry.attr.st_ino = entry.inode;
590604
add_entry(dir_entry, entry)
591605
},
592606
),

0 commit comments

Comments
 (0)