-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Size of syscall.Dirent not always consistent with FUSE #197
Comments
Wow, good find. The FUSE side of things should be fine, as it has its own fuse_dirent definition at https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fuse.h?h=v4.12#n707 .
This is independent of what the Looks like the |
What is |
Like you I think golang does the right thing. The print statement unintentionally reverses the values (my quote was patched) but it was that |
I am thinking about using Linux's FUSE dirent until |
No the FUSE binary interface and the syscall interface are independent,
using the FUSE data type for the getdents syscall would break things worse
…On Jan 25, 2018 16:55, "Felix Lechner" ***@***.***> wrote:
I am thinking about using Linux's FUSE dirent
<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fuse.h?h=v4.12#n707>
until go-fuse exports its _Dirent type. Would you like to see a pull
request? Thank you!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARgf4sYJ2kV7ZKjzqEOo7dRpQ5jTtiCks5tOKQMgaJpZM4RsIFS>
.
|
It looks like the assumption that reclen cannot be longer than the Dirent is just wrong. Linux can insert arbitrary padding in between. And it does, to improve alignment, apparently: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/readdir.c?h=v4.15-rc9#n173 |
Due to padding between entries, it is 280 even on 32-bit architectures. See #197 for details.
Fixed by f3838c0 . |
Hi,
This is from Debian packaging. On i386 the
Getdents
test in version 1.4.2 fails because thesyscall.Dirent
data structure gocryptfs uses has inconsistent sizes between architectures.While the
inode
andoffset
members can vary in scenarios like this, they are not the issue here. The golang runtime uses only thegetdents64
syscall and via cgo tweaksstruct dirent
to its liking (although I might have preferredstruct dirent64
). The issue here are the data types forname length
andfile type
, as well as the padding for alignment.On all architectures, both
go-fuse
andlibfuse
return at most 280 bytes. On amd64, that size matches thesyscall.Dirent
data type gocryptfs uses, but on i386 the latter drops to 276 bytes. It causes an error ininternal/syscallcompat/getdents_linux.go
:Here is a small program to illustrate the various sizes. This is the output for amd64:
For i386, the sizes are not nearly as consistent:
Which data structure should be used in gocryptfs? Bonus question: Is FUSE safe on i386? Thank you!
The text was updated successfully, but these errors were encountered: