@@ -26,7 +26,6 @@ import (
2626
2727 "github.com/jacobsa/fuse/fuseops"
2828 "github.com/rs/zerolog"
29- "github.com/sirupsen/logrus"
3029 "github.com/tigrisdata/tigrisfs/core/cfg"
3130 "github.com/winfsp/cgofuse/fuse"
3231)
@@ -115,11 +114,15 @@ func (fs *GoofysWin) Statfs(path string, stat *fuse.Statfs_t) int {
115114 return 0
116115}
117116
117+ func logDebugEnabled () bool {
118+ return fuseLog .GetLevel () <= zerolog .DebugLevel
119+ }
120+
118121func mapWinError (err error ) int {
119122 if err == nil {
120123 return 0
121124 }
122- if fuseLog . Level == zerolog . DebugLevel {
125+ if logDebugEnabled () {
123126 pc , _ , _ , _ := runtime .Caller (1 )
124127 details := runtime .FuncForPC (pc )
125128 fuseLog .Debugf ("%v: error %v" , details , err )
@@ -181,7 +184,7 @@ func mapWinError(err error) int {
181184
182185// Mknod creates a file node.
183186func (fs * GoofysWin ) Mknod (path string , mode uint32 , dev uint64 ) (ret int ) {
184- if fuseLog . Level == logrus . DebugLevel {
187+ if logDebugEnabled () {
185188 fuseLog .Debugf ("-> Mknod %v %v %v" , path , mode , dev )
186189 defer func () {
187190 fuseLog .Debugf ("<- Mknod %v %v %v = %v" , path , mode , dev , ret )
@@ -216,7 +219,7 @@ func (fs *GoofysWin) Mknod(path string, mode uint32, dev uint64) (ret int) {
216219 fh .Release ()
217220 }
218221 inode .Attributes .Rdev = uint32 (dev )
219- inode .setFileMode (fuseops .ConvertFileMode (mode ))
222+ _ , _ = inode .setFileMode (fuseops .ConvertFileMode (mode ))
220223
221224 if fs .flags .FsyncOnClose {
222225 err = inode .SyncFile ()
@@ -230,7 +233,7 @@ func (fs *GoofysWin) Mknod(path string, mode uint32, dev uint64) (ret int) {
230233
231234// Mkdir creates a directory.
232235func (fs * GoofysWin ) Mkdir (path string , mode uint32 ) (ret int ) {
233- if fuseLog . Level == logrus . DebugLevel {
236+ if logDebugEnabled () {
234237 fuseLog .Debugf ("-> Mkdir %v %v" , path , mode )
235238 defer func () {
236239 fuseLog .Debugf ("<- Mkdir %v %v = %v" , path , mode , ret )
@@ -259,7 +262,7 @@ func (fs *GoofysWin) Mkdir(path string, mode uint32) (ret int) {
259262
260263// Unlink removes a file.
261264func (fs * GoofysWin ) Unlink (path string ) (ret int ) {
262- if fuseLog . Level == logrus . DebugLevel {
265+ if logDebugEnabled () {
263266 fuseLog .Debugf ("-> Unlink %v" , path )
264267 defer func () {
265268 fuseLog .Debugf ("<- Unlink %v = %v" , path , ret )
@@ -279,7 +282,7 @@ func (fs *GoofysWin) Unlink(path string) (ret int) {
279282
280283// Rmdir removes a directory.
281284func (fs * GoofysWin ) Rmdir (path string ) (ret int ) {
282- if fuseLog . Level == logrus . DebugLevel {
285+ if logDebugEnabled () {
283286 fuseLog .Debugf ("-> Rmdir %v" , path )
284287 defer func () {
285288 fuseLog .Debugf ("<- Rmdir %v = %v" , path , ret )
@@ -299,7 +302,7 @@ func (fs *GoofysWin) Rmdir(path string) (ret int) {
299302
300303// Symlink creates a symbolic link.
301304func (fs * GoofysWin ) Symlink (target string , newpath string ) (ret int ) {
302- if fuseLog . Level == logrus . DebugLevel {
305+ if logDebugEnabled () {
303306 fuseLog .Debugf ("-> Symlink %v %v" , target , newpath )
304307 defer func () {
305308 fuseLog .Debugf ("<- Symlink %v %v = %v" , target , newpath , ret )
@@ -313,13 +316,13 @@ func (fs *GoofysWin) Symlink(target string, newpath string) (ret int) {
313316 return mapWinError (err )
314317 }
315318
316- parent .CreateSymlink (child , target )
319+ _ , _ = parent .CreateSymlink (child , target )
317320 return 0
318321}
319322
320323// Readlink reads the target of a symbolic link.
321324func (fs * GoofysWin ) Readlink (path string ) (ret int , target string ) {
322- if fuseLog . Level == logrus . DebugLevel {
325+ if logDebugEnabled () {
323326 fuseLog .Debugf ("-> Readlink %v" , path )
324327 defer func () {
325328 fuseLog .Debugf ("<- Readlink %v = %v %v" , path , ret , target )
@@ -343,7 +346,7 @@ func (fs *GoofysWin) Readlink(path string) (ret int, target string) {
343346
344347// Rename renames a file.
345348func (fs * GoofysWin ) Rename (oldpath string , newpath string ) (ret int ) {
346- if fuseLog . Level == logrus . DebugLevel {
349+ if logDebugEnabled () {
347350 fuseLog .Debugf ("-> Rename %v %v" , oldpath , newpath )
348351 defer func () {
349352 fuseLog .Debugf ("<- Rename %v %v = %v" , oldpath , newpath , ret )
@@ -368,7 +371,7 @@ func (fs *GoofysWin) Rename(oldpath string, newpath string) (ret int) {
368371
369372// Chmod changes the permission bits of a file.
370373func (fs * GoofysWin ) Chmod (path string , mode uint32 ) (ret int ) {
371- if fuseLog . Level == logrus . DebugLevel {
374+ if logDebugEnabled () {
372375 fuseLog .Debugf ("-> Chmod %v %v" , path , mode )
373376 defer func () {
374377 fuseLog .Debugf ("<- Chmod %v %v = %v" , path , mode , ret )
@@ -389,7 +392,7 @@ func (fs *GoofysWin) Chmod(path string, mode uint32) (ret int) {
389392
390393// Chown changes the owner and group of a file.
391394func (fs * GoofysWin ) Chown (path string , uid uint32 , gid uint32 ) (ret int ) {
392- if fuseLog . Level == logrus . DebugLevel {
395+ if logDebugEnabled () {
393396 fuseLog .Debugf ("-> Chown %v %v %v" , path , uid , gid )
394397 defer func () {
395398 fuseLog .Debugf ("<- Chown %v %v %v = %v" , path , uid , gid , ret )
@@ -408,7 +411,7 @@ func (fs *GoofysWin) Chown(path string, uid uint32, gid uint32) (ret int) {
408411
409412// Utimens changes the access and modification times of a file.
410413func (fs * GoofysWin ) Utimens (path string , tmsp []fuse.Timespec ) (ret int ) {
411- if fuseLog . Level == logrus . DebugLevel {
414+ if logDebugEnabled () {
412415 fuseLog .Debugf ("-> Utimens %v %v" , path , tmsp )
413416 defer func () {
414417 fuseLog .Debugf ("<- Utimens %v %v = %v" , path , tmsp , ret )
@@ -430,7 +433,7 @@ func (fs *GoofysWin) Utimens(path string, tmsp []fuse.Timespec) (ret int) {
430433
431434// Access is only used by winfsp with FSP_FUSE_DELETE_OK. Ignore it
432435func (fs * GoofysWin ) Access (path string , mask uint32 ) int {
433- if fuseLog . Level == logrus . DebugLevel {
436+ if logDebugEnabled () {
434437 fuseLog .Debugf ("<--> Access %v %v = 0" , path , mask )
435438 }
436439 atomic .AddInt64 (& fs .stats .noops , 1 )
@@ -440,7 +443,7 @@ func (fs *GoofysWin) Access(path string, mask uint32) int {
440443// Create creates and opens a file.
441444// The flags are a combination of the fuse.O_* constants.
442445func (fs * GoofysWin ) Create (path string , flags int , mode uint32 ) (ret int , fhId uint64 ) {
443- if fuseLog . Level == logrus . DebugLevel {
446+ if logDebugEnabled () {
444447 fuseLog .Debugf ("-> Create %v %v %v" , path , flags , mode )
445448 defer func () {
446449 fuseLog .Debugf ("<- Create %v %v %v = %v %v" , path , flags , mode , ret , fhId )
@@ -455,10 +458,8 @@ func (fs *GoofysWin) Create(path string, flags int, mode uint32) (ret int, fhId
455458 }
456459
457460 if fs .flags .FlushFilename != "" && child == fs .flags .FlushFilename {
458- err = fs .SyncTree (parent )
459- if err == nil {
460- err = syscall .ENOENT
461- }
461+ fs .SyncTree (parent )
462+ err = syscall .ENOENT
462463 return mapWinError (err ), 0
463464 }
464465
@@ -475,7 +476,7 @@ func (fs *GoofysWin) Create(path string, flags int, mode uint32) (ret int, fhId
475476 return mapWinError (err ), 0
476477 }
477478
478- inode .setFileMode (fuseops .ConvertFileMode (mode ))
479+ _ , _ = inode .setFileMode (fuseops .ConvertFileMode (mode ))
479480
480481 handleID := fs .AddFileHandle (fh )
481482
@@ -490,7 +491,7 @@ func endsWith(path, part string) bool {
490491// Open opens a file.
491492// The flags are a combination of the fuse.O_* constants.
492493func (fs * GoofysWin ) Open (path string , flags int ) (ret int , fhId uint64 ) {
493- if fuseLog . Level == logrus . DebugLevel {
494+ if logDebugEnabled () {
494495 fuseLog .Debugf ("-> Open %v %v" , path , flags )
495496 defer func () {
496497 fuseLog .Debugf ("<- Open %v %v = %v %v" , path , flags , ret , fhId )
@@ -506,21 +507,14 @@ func (fs *GoofysWin) Open(path string, flags int) (ret int, fhId uint64) {
506507 if err != nil {
507508 return mapWinError (err ), 0
508509 }
509- if err == nil {
510- err = fs .SyncTree (parent )
511- }
512- if err == nil {
513- err = syscall .ENOENT
514- }
510+ fs .SyncTree (parent )
515511 }
516512 if endsWith (path , fs .flags .RefreshFilename ) {
517513 parent , _ , err := fs .LookupParent (path )
518514 if err != nil {
519515 return mapWinError (err ), 0
520516 }
521- if err == nil {
522- err = fs .RefreshInodeCache (parent )
523- }
517+ err = fs .RefreshInodeCache (parent )
524518 if err == nil {
525519 err = syscall .ENOENT
526520 }
@@ -540,7 +534,7 @@ func (fs *GoofysWin) Open(path string, flags int) (ret int, fhId uint64) {
540534
541535// Getattr gets file attributes.
542536func (fs * GoofysWin ) Getattr (path string , stat * fuse.Stat_t , fh uint64 ) (ret int ) {
543- if fuseLog . Level == logrus . DebugLevel {
537+ if logDebugEnabled () {
544538 fuseLog .Debugf ("-> Getattr %v %v" , path , fh )
545539 defer func () {
546540 fuseLog .Debugf ("<- Getattr %v %v = %v %v" , path , fh , ret , * stat )
@@ -580,7 +574,7 @@ func makeFuseAttributes(attr *fuseops.InodeAttributes, stat *fuse.Stat_t) {
580574
581575// Truncate changes the size of a file.
582576func (fs * GoofysWin ) Truncate (path string , size int64 , fh uint64 ) (ret int ) {
583- if fuseLog . Level == logrus . DebugLevel {
577+ if logDebugEnabled () {
584578 fuseLog .Debugf ("-> Truncate %v %v %v" , path , size , fh )
585579 defer func () {
586580 fuseLog .Debugf ("<- Truncate %v %v %v = %v" , path , size , fh , ret )
@@ -601,7 +595,7 @@ func (fs *GoofysWin) Truncate(path string, size int64, fh uint64) (ret int) {
601595
602596// Read reads data from a file.
603597func (fs * GoofysWin ) Read (path string , buff []byte , ofst int64 , fhId uint64 ) (ret int ) {
604- if fuseLog . Level == logrus . DebugLevel {
598+ if logDebugEnabled () {
605599 fuseLog .Debugf ("-> Read %v %v %v %v" , path , len (buff ), ofst , fhId )
606600 defer func () {
607601 fuseLog .Debugf ("<- Read %v %v %v %v = %v" , path , len (buff ), ofst , fhId , ret )
@@ -632,7 +626,7 @@ func (fs *GoofysWin) Read(path string, buff []byte, ofst int64, fhId uint64) (re
632626
633627// Write writes data to a file.
634628func (fs * GoofysWin ) Write (path string , buff []byte , ofst int64 , fhId uint64 ) (ret int ) {
635- if fuseLog . Level == logrus . DebugLevel {
629+ if logDebugEnabled () {
636630 fuseLog .Debugf ("-> Write %v %v %v %v" , path , len (buff ), ofst , fhId )
637631 defer func () {
638632 fuseLog .Debugf ("<- Write %v %v %v %v = %v" , path , len (buff ), ofst , fhId , ret )
@@ -658,7 +652,7 @@ func (fs *GoofysWin) Write(path string, buff []byte, ofst int64, fhId uint64) (r
658652
659653// Flush flushes cached file data. Ignore it.
660654func (fs * GoofysWin ) Flush (path string , fhId uint64 ) (ret int ) {
661- if fuseLog . Level == logrus . DebugLevel {
655+ if logDebugEnabled () {
662656 fuseLog .Debugf ("<--> Flush %v %v = 0" , path , fhId )
663657 }
664658 atomic .AddInt64 (& fs .stats .noops , 1 )
@@ -667,7 +661,7 @@ func (fs *GoofysWin) Flush(path string, fhId uint64) (ret int) {
667661
668662// Release closes an open file.
669663func (fs * GoofysWin ) Release (path string , fhId uint64 ) (ret int ) {
670- if fuseLog . Level == logrus . DebugLevel {
664+ if logDebugEnabled () {
671665 fuseLog .Debugf ("-> Release %v %v" , path , fhId )
672666 defer func () {
673667 fuseLog .Debugf ("<- Release %v %v = %v" , path , fhId , ret )
@@ -700,7 +694,7 @@ func (fs *GoofysWin) Release(path string, fhId uint64) (ret int) {
700694
701695// Fsync synchronizes file contents.
702696func (fs * GoofysWin ) Fsync (path string , datasync bool , fhId uint64 ) (ret int ) {
703- if fuseLog . Level == logrus . DebugLevel {
697+ if logDebugEnabled () {
704698 fuseLog .Debugf ("-> Fsync %v %v %v" , path , datasync , fhId )
705699 defer func () {
706700 fuseLog .Debugf ("<- Fsync %v %v %v = %v" , path , datasync , fhId , ret )
@@ -727,9 +721,9 @@ func (fs *GoofysWin) Fsync(path string, datasync bool, fhId uint64) (ret int) {
727721 }
728722 }
729723 if inode .Id == fuseops .RootInodeID {
730- err = fs .SyncTree (nil )
724+ fs .SyncTree (nil )
731725 } else if inode .isDir () {
732- err = fs .SyncTree (inode )
726+ fs .SyncTree (inode )
733727 } else {
734728 err = inode .SyncFile ()
735729 }
@@ -741,7 +735,7 @@ func (fs *GoofysWin) Fsync(path string, datasync bool, fhId uint64) (ret int) {
741735
742736// Opendir opens a directory.
743737func (fs * GoofysWin ) Opendir (path string ) (ret int , dhId uint64 ) {
744- if fuseLog . Level == logrus . DebugLevel {
738+ if logDebugEnabled () {
745739 fuseLog .Debugf ("-> Opendir %v" , path )
746740 defer func () {
747741 fuseLog .Debugf ("<- Opendir %v = %v %v" , path , ret , dhId )
@@ -766,7 +760,7 @@ func (fs *GoofysWin) Readdir(path string,
766760 fill func (name string , stat * fuse.Stat_t , ofst int64 ) bool ,
767761 ofst int64 , dhId uint64 ,
768762) (ret int ) {
769- if fuseLog . Level == logrus . DebugLevel {
763+ if logDebugEnabled () {
770764 fuseLog .Debugf ("-> Readdir %v %v %v" , path , ofst , dhId )
771765 defer func () {
772766 fuseLog .Debugf ("<- Readdir %v %v %v = %v" , path , ofst , dhId , ret )
@@ -823,7 +817,7 @@ func (fs *GoofysWin) Readdir(path string,
823817
824818// Releasedir closes an open directory.
825819func (fs * GoofysWin ) Releasedir (path string , dhId uint64 ) (ret int ) {
826- if fuseLog . Level == logrus . DebugLevel {
820+ if logDebugEnabled () {
827821 fuseLog .Debugf ("-> Releasedir %v %v" , path , dhId )
828822 defer func () {
829823 fuseLog .Debugf ("<- Releasedir %v %v = %v" , path , dhId , ret )
@@ -836,7 +830,7 @@ func (fs *GoofysWin) Releasedir(path string, dhId uint64) (ret int) {
836830 dh := fs .dirHandles [fuseops .HandleID (dhId )]
837831 fs .mu .RUnlock ()
838832
839- dh .CloseDir ()
833+ _ = dh .CloseDir ()
840834
841835 fs .mu .Lock ()
842836 delete (fs .dirHandles , fuseops .HandleID (dhId ))
@@ -856,7 +850,7 @@ func (fs *GoofysWin) Setxattr(path string, name string, value []byte, flags int)
856850 return - fuse .EOPNOTSUPP
857851 }
858852
859- if fuseLog . Level == logrus . DebugLevel {
853+ if logDebugEnabled () {
860854 fuseLog .Debugf ("-> Setxattr %v %v %v %v" , path , name , value , flags )
861855 defer func () {
862856 fuseLog .Debugf ("<- Setxattr %v %v %v %v = %v" , path , name , value , flags , ret )
@@ -885,7 +879,7 @@ func (fs *GoofysWin) Getxattr(path string, name string) (ret int, data []byte) {
885879 return - fuse .EOPNOTSUPP , nil
886880 }
887881
888- if fuseLog . Level == logrus . DebugLevel {
882+ if logDebugEnabled () {
889883 fuseLog .Debugf ("-> Getxattr %v %v" , path , name )
890884 defer func () {
891885 fuseLog .Debugf ("<- Getxattr %v %v = %v %v" , path , name , ret , data )
@@ -913,7 +907,7 @@ func (fs *GoofysWin) Removexattr(path string, name string) (ret int) {
913907 return - fuse .EOPNOTSUPP
914908 }
915909
916- if fuseLog . Level == logrus . DebugLevel {
910+ if logDebugEnabled () {
917911 fuseLog .Debugf ("-> Removexattr %v %v" , path , name )
918912 defer func () {
919913 fuseLog .Debugf ("<- Removexattr %v %v = %v" , path , name , ret )
@@ -937,7 +931,7 @@ func (fs *GoofysWin) Listxattr(path string, fill func(name string) bool) (ret in
937931 return - fuse .EOPNOTSUPP
938932 }
939933
940- if fuseLog . Level == logrus . DebugLevel {
934+ if logDebugEnabled () {
941935 fuseLog .Debugf ("-> Listxattr %v" , path )
942936 defer func () {
943937 fuseLog .Debugf ("<- Listxattr %v = %v" , path , ret )
@@ -1077,7 +1071,7 @@ func mountFuseFS(fs *Goofys) (mfs MountedFS, err error) {
10771071}
10781072
10791073// Join is a part of MountedFS interface
1080- func (fs * GoofysWin ) Join (ctx context.Context ) error {
1074+ func (fs * GoofysWin ) Join (_ context.Context ) error {
10811075 <- fs .initCh
10821076 return nil
10831077}
0 commit comments