summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/fs.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-05-29 22:50:03 +0200
committerJakob Unterwurzacher2016-05-29 22:50:03 +0200
commit1648c54adb9b7d9d8984857a35c6092bbae6bdec (patch)
tree7041cbde59a51e8946f119f6fdb80183e6436294 /internal/fusefrontend/fs.go
parentfd53dfd2ad88d9d277e5ab93fba1b81a5f2255d4 (diff)
fusefrontend: use sync.Once for one-time warnings
Using a simple boolean was racy (which was harmless in this case) and non-idomatic.
Diffstat (limited to 'internal/fusefrontend/fs.go')
-rw-r--r--internal/fusefrontend/fs.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 1ef88b7..988a41a 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -208,14 +208,13 @@ func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context)
return fs.FileSystem.Mknod(cPath, mode, dev, context)
}
-var truncateWarned bool
+// Only warn once
+var truncateWarnOnce sync.Once
func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) {
- // Only warn once
- if !truncateWarned {
+ truncateWarnOnce.Do(func() {
toggledlog.Warn.Printf("truncate(2) is not supported, returning ENOSYS - use ftruncate(2)")
- truncateWarned = true
- }
+ })
return fuse.ENOSYS
}