fusefs: support FUSE_IOCTL
@asomers
any real-world fuse file systems that implement FUSE_IOCTL
None that I'm aware of.
However, one of my work-in-progress hobby projects (which is a pseudo filesystem for managing web browser bookmarks) requires ioctl for some of its major features.
I'd like to make it work on FreeBSD, otherwise it would be Linux-only (which is inconvenient for myself, since I'm primarily using FreeBSD for daily work and entertainment).
Recently I came across two FUSE filesystems that implement FUSE_IOCTL.
One of them is bindfs. When launched with the -o enable-ioctl option, it enables ioctl forwarding.
However, it only works for the ioctls that do not require copying extra data between kernel and user address space, since FUSE servers are not allowed to perform "unrestricted ioctl".
Another is ntfs-3g. The only supported ioctl is FITRIM.
Although there is currently no FITRIM equivalent on FreeBSD, it's not difficult to port: Just adding a new entry in sys/filio.h, and porting fstrim(8) from util-linux would suffice.
Note: For the TRIM feature, ntfs-3g server requires BLKDISCARD internally. Since we already have DIOCGDELETE as its equivalent, this won't be a problem.
Recently I came across two FUSE filesystems that implement
FUSE_IOCTL.One of them is bindfs. When launched with the
-o enable-ioctloption, it enables ioctl forwarding.However, it only works for the ioctls that do not require copying extra data between kernel and user address space, since FUSE servers are not allowed to perform "unrestricted ioctl".
That's certainly an interesting use case.
Another is ntfs-3g. The only supported ioctl is
FITRIM.Although there is currently no
FITRIMequivalent on FreeBSD, it's not difficult to port: Just adding a new entry insys/filio.h, and portingfstrim(8)from util-linux would suffice.Note: For the TRIM feature, ntfs-3g server requires
BLKDISCARDinternally. Since we already haveDIOCGDELETEas its equivalent, this won't be a problem.
That wouldn't work very well, because few to no FreeBSD applications will use FITRIM. A far better option would be for ntfs-3g to switch from libfuse2 to libfuse3. Then it could use the native FUSE_FALLOCATE request for hole-punching.
Patch updated with the following changes:
- [x] Update the copyright notice in the added test file.
- [x] Add a
Signed-off-by:line in all commit messages. - [x] Add
FUSE_HAS_IOCTL_DIRflag infuse_internal_send_init(). - [x] Take
COMPAT_FREEBSD32into consideration when settingFUSE_IOCTL_32BIT.
Also removed the bogus "XXX" comment lines - The ioctl(2) man-page does not say that ioctl always returns 0 on success. I must have mistaken that for something else...
@asomers
Sorry if I'm being pushy, but it's been a while since the last update. Would you have time to continue reviewing this patch?
Just rebased HEAD without other changes. Fortunately the patch still works :)
@asomers this looks reasonable to my eye. Any reason I shouldn't push it into head before 15?
@asomers I've refactored the tests as you suggested.
I'd like you to know that I haven't been ignoring this. I've been looking at it today, and adding a few more test cases, which I'll push soon. Sometime next week, I think.
@asomers
15.0-ALPHA has been around for a while, and I'm wondering if this patch could still make it into 15. If there are anything else I need to do, please let me know.