fusefs: only search for FREAD fufh in readdir
The extra search for an FEXEC fufh shall be removed, since readdir is only supposed to be called on a directory opened with FREAD.
Also remove the fuse_filehandle_get_dir() function, since it's not used anywhere else.
More background on this patch:
The fuse_filehandle_get_dir() function was introduced in commit f8d4af104b7d.
This commit (unintentionally?) added an extra search for an FEXEC file handle
in fuse_vnop_readdir(), which is not a valid access mode for getdirentries(),
but should be harmless, since such syscalls fail with EBADF before VOP_READDIR().
fuse_filehandle_get_dir() was also called in fuse_vnop_close(), however,
this usage was removed in commit 35cf0e7e56ca.
Thus it should be okay to remove the function completely, since there's no longer
any legitimate usage for getting a "FREAD or FEXEC" directory file handle.
@asomers
Please review this patch, thanks!
@asomers can you look at this please?
kern_getdirentries does indeed require that the file be opened with FREAD. But that's not the only caller of VOP_READDIR. NFS calls it. So does autofs, and a few other places. I don't think we can assume that FREAD will always be set in fuse_vnop_readdir.
kern_getdirentriesdoes indeed require that the file be opened withFREAD. But that's not the only caller ofVOP_READDIR. NFS calls it. So does autofs, and a few other places. I don't think we can assume thatFREADwill always be set infuse_vnop_readdir.
- For those who call
VOP_READDIR()withoutVOP_OPEN(), it fails, with or without this patch.- This includes autofs and a few others, notably
mountwithMNT_EMPTYDIR. - For NFS, there's already an implicit open in
fuse_vnop_readdir(). Perhaps this could be applied beyond NFS? (provided that the server does not implementFUSE_OPENDIR)
- This includes autofs and a few others, notably
- For (potential) callers who call
VOP_READDIR()on a directory explicitly opened withFEXEC, failing withEBADFshould be the correct thing to do.- Actually, I'm yet to find an example for this case.
The only remaining callers to
VOP_READDIR()that may call it on a fusefs are unionfs andvop_stdvptocnp(). They both properly open the directory withFREADbefore doing so.
- Actually, I'm yet to find an example for this case.
The only remaining callers to