winfsp / cgofuse

Cross-platform FUSE library for Go - Works on Windows, macOS, Linux, FreeBSD, NetBSD, OpenBSD
https://winfsp.dev
MIT License
527 stars 84 forks source link

WinFsp: Can't set read only file system #15

Open ncw opened 7 years ago

ncw commented 7 years ago

If I pass -o ro to WinFsp then doesn't mark the file system as read only as it does on linux. I think libfuse passes unknown options on to mount.fuse which says in its man page

Most of the generic mount options described in mount are supported (ro, rw, suid, nosuid, dev, nodev, exec, noexec, atime, noatime, sync, async, dirsync).

This brings to mind 3 options

What is your preferred option?

Thanks

billziss-gh commented 7 years ago

It is possible to mark a file system as read-only on WinFsp-FUSE by passing the (WinFsp specific) flag FSP_FUSE_CAP_READ_ONLY during fuse_operations::init. However I did not implement this flag on cgofuse. There are two reasons for this:

Clearly this is an area where the WinFsp core could be improved (e.g. by rejecting write requests at the kernel level if the file system is marked read-only). Until that happens I recommend treating every file system as read-write and explicitly rejecting the requests that you do not want to handle with -EROFS.

[NOTE: The WinFsp-FUSE supported options are here and a few additional ones here].