From d0524ded993f870c2dd8a559efed0d612e85d588 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 5 Sep 2015 20:36:26 +0200 Subject: Use Debug object instead of fmt --- cryptfs/cryptfs_content.go | 2 +- cryptfs/log.go | 4 ++-- cryptfs/nonce.go | 2 +- frontend/fe_dir.go | 16 +++++++--------- frontend/fe_file.go | 10 +++++----- frontend/fe_fs.go | 3 +-- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/cryptfs/cryptfs_content.go b/cryptfs/cryptfs_content.go index b3c7f95..0ebf34d 100644 --- a/cryptfs/cryptfs_content.go +++ b/cryptfs/cryptfs_content.go @@ -22,7 +22,7 @@ func (be *CryptFS) DecryptBlock(ciphertext []byte) ([]byte, error) { } if len(ciphertext) < NONCE_LEN { - warn.Printf("decryptBlock: Block is too short: %d bytes\n", len(ciphertext)) + Warn.Printf("decryptBlock: Block is too short: %d bytes\n", len(ciphertext)) return nil, errors.New("Block is too short") } diff --git a/cryptfs/log.go b/cryptfs/log.go index 947b1c3..f9c46c8 100644 --- a/cryptfs/log.go +++ b/cryptfs/log.go @@ -15,5 +15,5 @@ func (l logChannel) Printf(format string, args ...interface{}) { } -var debug = logChannel{true} -var warn = logChannel{true} +var Debug = logChannel{false} +var Warn = logChannel{true} diff --git a/cryptfs/nonce.go b/cryptfs/nonce.go index 3803b8c..f93f59c 100644 --- a/cryptfs/nonce.go +++ b/cryptfs/nonce.go @@ -49,7 +49,7 @@ func (n *nonce96) Get() []byte { binary.BigEndian.PutUint64(r[4:12], n.low64) n.lock.Unlock() - debug.Printf("nonce96.Get(): %s\n", hex.EncodeToString(r)) + Debug.Printf("nonce96.Get(): %s\n", hex.EncodeToString(r)) return r } diff --git a/frontend/fe_dir.go b/frontend/fe_dir.go index 75b665b..9849968 100644 --- a/frontend/fe_dir.go +++ b/frontend/fe_dir.go @@ -27,7 +27,7 @@ type Dir struct { } func NewDir(parent string, name string, fs *FS) *Dir { - fmt.Printf("NewDir parent=%s name=%s\n", parent, name) + cryptfs.Debug.Printf("NewDir parent=%s name=%s\n", parent, name) return &Dir { Dir: cluefs.NewDir(parent, name, fs.ClueFS), crfs: fs.CryptFS, @@ -35,7 +35,7 @@ func NewDir(parent string, name string, fs *FS) *Dir { } func (d *Dir) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) { - fmt.Printf("Open\n") + cryptfs.Debug.Printf("Open\n") h, err := d.Dir.Open(ctx, req, resp) if err != nil { return nil, err @@ -49,7 +49,7 @@ func (d *Dir) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenRe } func (d *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fusefs.Node, error) { - fmt.Printf("Lookup %s\n", req.Name) + cryptfs.Debug.Printf("Lookup %s\n", req.Name) req.Name = d.crfs.EncryptPath(req.Name) node, err := d.Dir.Lookup(ctx, req, resp) if err != nil { @@ -72,7 +72,7 @@ func (d *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.Lo } func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { - fmt.Printf("ReadDirAll\n") + cryptfs.Debug.Printf("ReadDirAll\n") entries, err := d.Dir.ReadDirAll(ctx) if err != nil { return nil, err @@ -95,7 +95,7 @@ func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { } func (d *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fusefs.Node, error) { - fmt.Printf("Mkdir %s\n", req.Name) + cryptfs.Debug.Printf("Mkdir %s\n", req.Name) req.Name = d.crfs.EncryptPath(req.Name) n, err := d.Dir.Mkdir(ctx, req) if err != nil { @@ -109,16 +109,14 @@ func (d *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fusefs.Node, e } func (d *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error { - fmt.Printf("Remove\n") + cryptfs.Debug.Printf("Remove\n") req.Name = d.crfs.EncryptPath(req.Name) return d.Dir.Remove(ctx, req) } func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fusefs.Node, fusefs.Handle, error) { - fmt.Printf("Create\n") - + cryptfs.Debug.Printf("Create\n") req.Flags, _ = fixFlags(req.Flags) - req.Name = d.crfs.EncryptPath(req.Name) n, _, err := d.Dir.Create(ctx, req, resp) if err != nil { diff --git a/frontend/fe_file.go b/frontend/fe_file.go index 4bd623f..7cc23ad 100644 --- a/frontend/fe_file.go +++ b/frontend/fe_file.go @@ -22,7 +22,7 @@ import ( ) func fixFlags(flags fuse.OpenFlags) (fuse.OpenFlags, bool) { - fmt.Printf("fixFlags: Before: %s\n", flags.String()) + cryptfs.Debug.Printf("fixFlags: Before: %s\n", flags.String()) var writeOnly bool // We always need read access to do read-modify-write cycles if flags & fuse.OpenWriteOnly > 0 { @@ -32,7 +32,7 @@ func fixFlags(flags fuse.OpenFlags) (fuse.OpenFlags, bool) { } // We also cannot open the file in append mode, we need to seek back for RMW flags = flags &^ fuse.OpenAppend - fmt.Printf("fixFlags: After: %s\n", flags.String()) + cryptfs.Debug.Printf("fixFlags: After: %s\n", flags.String()) return flags, writeOnly } @@ -51,7 +51,7 @@ type File struct { } func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) { - fmt.Printf("File.Open\n") + cryptfs.Debug.Printf("File.Open\n") req.Flags, f.writeOnly = fixFlags(req.Flags) @@ -91,7 +91,7 @@ func (f *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadR } func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error { - fmt.Printf("File.Write\n") + cryptfs.Debug.Printf("File.Write\n") resp.Size = 0 iblocks := f.crfs.SplitRange(uint64(req.Offset), uint64(len(req.Data))) var blockData []byte @@ -134,7 +134,7 @@ func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.Wri } func (f *File) Attr(ctx context.Context, attr *fuse.Attr) error { - fmt.Printf("Attr\n") + cryptfs.Debug.Printf("Attr\n") err := f.File.Node.Attr(ctx, attr) if err != nil { return err diff --git a/frontend/fe_fs.go b/frontend/fe_fs.go index 470095f..012d7f0 100644 --- a/frontend/fe_fs.go +++ b/frontend/fe_fs.go @@ -12,7 +12,6 @@ package frontend // This file handles just the root directory import ( - "fmt" "github.com/rfjakob/gocryptfs/cryptfs" "github.com/rfjakob/cluefs/lib/cluefs" fusefs "bazil.org/fuse/fs" @@ -42,6 +41,6 @@ func NewFS(key [16]byte, backing string) *FS { } func (fs *FS) Root() (fusefs.Node, error) { - fmt.Printf("Root\n") + cryptfs.Debug.Printf("Root\n") return NewDir("", fs.backing, fs), nil } -- cgit v1.2.3