aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-07 18:59:22 +0100
committerrfjakob2019-01-07 21:25:23 +0100
commit57a52d6aef9b320800a42f9a12fd7e1f47f63073 (patch)
tree16f7da63066df8b289977084aaeb791e3b5c9611 /internal
parent2332462e7821d2ebc579f8b4e8bd097449167a0c (diff)
fusefrontend: Clarify access mode check related to O_WRONLY handling.
Use O_ACCMODE mask in openWriteOnlyFile for improved readability.
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/fs.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index e379465..7671215 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -114,7 +114,7 @@ func (fs *FS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.S
func (fs *FS) mangleOpenFlags(flags uint32) (newFlags int) {
newFlags = int(flags)
// Convert WRONLY to RDWR. We always need read access to do read-modify-write cycles.
- if newFlags&os.O_WRONLY > 0 {
+ if (newFlags & syscall.O_ACCMODE) == syscall.O_WRONLY {
newFlags = newFlags ^ os.O_WRONLY | os.O_RDWR
}
// We also cannot open the file in append mode, we need to seek back for RMW
@@ -157,7 +157,7 @@ func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile n
syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
tlog.Warn.Printf("Open %q: too many open files. Current \"ulimit -n\": %d", cName, lim.Cur)
}
- if err == syscall.EACCES && (int(flags)&os.O_WRONLY > 0) {
+ if err == syscall.EACCES && (int(flags)&syscall.O_ACCMODE) == syscall.O_WRONLY {
return fs.openWriteOnlyFile(dirfd, cName, newFlags)
}
return nil, fuse.ToStatus(err)