1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-02 16:43:28 +00:00

cmount, mount, mountlib: make --read-only reject modify operations

Normally mount/cmount use `-o ro` to get the kernel to mark the fs as
read only.  However this is ignored by WinFsp, so in addition if
`--read-only` is in effect then return EROFS ("Read only File System")
from all methods which attempt to modify something.
This commit is contained in:
Nick Craig-Wood
2017-05-11 13:15:51 +01:00
parent 8be8a8e41b
commit b259f8b752
6 changed files with 52 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ type FS struct {
root *Dir
noSeek bool // don't allow seeking if set
noChecksum bool // don't check checksums if set
readOnly bool // if set FS is read only
}
// NewFS creates a new filing system and root directory
@@ -66,6 +67,13 @@ func (fsys *FS) NoChecksum() *FS {
return fsys
}
// ReadOnly sets the fs into read only mode, returning EROFS for any
// write operations.
func (fsys *FS) ReadOnly() *FS {
fsys.readOnly = true
return fsys
}
// Root returns the root node
func (fsys *FS) Root() (*Dir, error) {
// fs.Debugf(fsys.f, "Root()")