Use Debug object instead of fmt
This commit is contained in:
parent
11fb037e7e
commit
d0524ded99
@ -22,7 +22,7 @@ func (be *CryptFS) DecryptBlock(ciphertext []byte) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(ciphertext) < NONCE_LEN {
|
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")
|
return nil, errors.New("Block is too short")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,5 +15,5 @@ func (l logChannel) Printf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var debug = logChannel{true}
|
var Debug = logChannel{false}
|
||||||
var warn = logChannel{true}
|
var Warn = logChannel{true}
|
||||||
|
@ -49,7 +49,7 @@ func (n *nonce96) Get() []byte {
|
|||||||
binary.BigEndian.PutUint64(r[4:12], n.low64)
|
binary.BigEndian.PutUint64(r[4:12], n.low64)
|
||||||
n.lock.Unlock()
|
n.lock.Unlock()
|
||||||
|
|
||||||
debug.Printf("nonce96.Get(): %s\n", hex.EncodeToString(r))
|
Debug.Printf("nonce96.Get(): %s\n", hex.EncodeToString(r))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ type Dir struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewDir(parent string, name string, fs *FS) *Dir {
|
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 {
|
return &Dir {
|
||||||
Dir: cluefs.NewDir(parent, name, fs.ClueFS),
|
Dir: cluefs.NewDir(parent, name, fs.ClueFS),
|
||||||
crfs: fs.CryptFS,
|
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) {
|
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)
|
h, err := d.Dir.Open(ctx, req, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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)
|
req.Name = d.crfs.EncryptPath(req.Name)
|
||||||
node, err := d.Dir.Lookup(ctx, req, resp)
|
node, err := d.Dir.Lookup(ctx, req, resp)
|
||||||
if err != nil {
|
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) {
|
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)
|
entries, err := d.Dir.ReadDirAll(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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)
|
req.Name = d.crfs.EncryptPath(req.Name)
|
||||||
n, err := d.Dir.Mkdir(ctx, req)
|
n, err := d.Dir.Mkdir(ctx, req)
|
||||||
if err != nil {
|
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 {
|
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)
|
req.Name = d.crfs.EncryptPath(req.Name)
|
||||||
return d.Dir.Remove(ctx, req)
|
return d.Dir.Remove(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fusefs.Node, fusefs.Handle, error) {
|
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.Flags, _ = fixFlags(req.Flags)
|
||||||
|
|
||||||
req.Name = d.crfs.EncryptPath(req.Name)
|
req.Name = d.crfs.EncryptPath(req.Name)
|
||||||
n, _, err := d.Dir.Create(ctx, req, resp)
|
n, _, err := d.Dir.Create(ctx, req, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func fixFlags(flags fuse.OpenFlags) (fuse.OpenFlags, bool) {
|
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
|
var writeOnly bool
|
||||||
// We always need read access to do read-modify-write cycles
|
// We always need read access to do read-modify-write cycles
|
||||||
if flags & fuse.OpenWriteOnly > 0 {
|
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
|
// We also cannot open the file in append mode, we need to seek back for RMW
|
||||||
flags = flags &^ fuse.OpenAppend
|
flags = flags &^ fuse.OpenAppend
|
||||||
fmt.Printf("fixFlags: After: %s\n", flags.String())
|
cryptfs.Debug.Printf("fixFlags: After: %s\n", flags.String())
|
||||||
return flags, writeOnly
|
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) {
|
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)
|
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 {
|
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
|
resp.Size = 0
|
||||||
iblocks := f.crfs.SplitRange(uint64(req.Offset), uint64(len(req.Data)))
|
iblocks := f.crfs.SplitRange(uint64(req.Offset), uint64(len(req.Data)))
|
||||||
var blockData []byte
|
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 {
|
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)
|
err := f.File.Node.Attr(ctx, attr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -12,7 +12,6 @@ package frontend
|
|||||||
// This file handles just the root directory
|
// This file handles just the root directory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/rfjakob/gocryptfs/cryptfs"
|
"github.com/rfjakob/gocryptfs/cryptfs"
|
||||||
"github.com/rfjakob/cluefs/lib/cluefs"
|
"github.com/rfjakob/cluefs/lib/cluefs"
|
||||||
fusefs "bazil.org/fuse/fs"
|
fusefs "bazil.org/fuse/fs"
|
||||||
@ -42,6 +41,6 @@ func NewFS(key [16]byte, backing string) *FS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FS) Root() (fusefs.Node, error) {
|
func (fs *FS) Root() (fusefs.Node, error) {
|
||||||
fmt.Printf("Root\n")
|
cryptfs.Debug.Printf("Root\n")
|
||||||
return NewDir("", fs.backing, fs), nil
|
return NewDir("", fs.backing, fs), nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user