forked from Elara6331/itd
Stylistic changes
This commit is contained in:
parent
cc6fc3e1dc
commit
673383f795
2
fuse.go
2
fuse.go
@ -9,7 +9,7 @@ import (
|
|||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func startFuse(ctx context.Context, dev *infinitime.Device) error {
|
func startFUSE(ctx context.Context, dev *infinitime.Device) error {
|
||||||
// This is where we'll mount the FS
|
// This is where we'll mount the FS
|
||||||
os.Mkdir(k.String("fuse.mountpoint"), 0755)
|
os.Mkdir(k.String("fuse.mountpoint"), 0755)
|
||||||
root := fusefs.BuildRootNode(dev)
|
root := fusefs.BuildRootNode(dev)
|
||||||
|
@ -36,6 +36,9 @@ type ITNode struct {
|
|||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var myfs *blefs.FS = nil
|
||||||
|
var inodemap map[string]uint64 = nil
|
||||||
|
|
||||||
func BuildRootNode(dev *infinitime.Device) *ITNode {
|
func BuildRootNode(dev *infinitime.Device) *ITNode {
|
||||||
inodemap = make(map[string]uint64)
|
inodemap = make(map[string]uint64)
|
||||||
myfs, _ = dev.FS()
|
myfs, _ = dev.FS()
|
||||||
@ -80,10 +83,6 @@ func BuildProperties(dev *infinitime.Device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var myfs *blefs.FS = nil;
|
|
||||||
var inodemap map[string]uint64 = nil;
|
|
||||||
|
|
||||||
var _ = (fs.NodeReaddirer)((*ITNode)(nil))
|
var _ = (fs.NodeReaddirer)((*ITNode)(nil))
|
||||||
|
|
||||||
// Readdir is part of the NodeReaddirer interface
|
// Readdir is part of the NodeReaddirer interface
|
||||||
@ -206,7 +205,7 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
|
|||||||
|
|
||||||
for _, file := range n.lst {
|
for _, file := range n.lst {
|
||||||
if file.path != n.path + "/" + name {
|
if file.path != n.path + "/" + name {
|
||||||
continue;
|
continue
|
||||||
}
|
}
|
||||||
log.Info("LookUp successful").Str("path", file.path).Send()
|
log.Info("LookUp successful").Str("path", file.path).Send()
|
||||||
|
|
||||||
@ -230,7 +229,7 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
|
|||||||
child := n.NewInode(ctx, operations, stable)
|
child := n.NewInode(ctx, operations, stable)
|
||||||
return child, 0
|
return child, 0
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
log.Warn("LookUp failed").Str("path", n.path + "/" + name).Send()
|
log.Warn("LookUp failed").Str("path", n.path + "/" + name).Send()
|
||||||
}
|
}
|
||||||
@ -298,7 +297,7 @@ func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno)
|
|||||||
go func() {
|
go func() {
|
||||||
// For every progress event
|
// For every progress event
|
||||||
for sent := range fp.Progress() {
|
for sent := range fp.Progress() {
|
||||||
log.Info("Progress").Int("bytes", int(sent)).Int("of", len(fh.content)).Send();
|
log.Info("Progress").Int("bytes", int(sent)).Int("of", len(fh.content)).Send()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -330,7 +329,7 @@ func (fh *bytesFileWriteHandle) Fsync(ctx context.Context, flags uint32) (errno
|
|||||||
|
|
||||||
var _ = (fs.NodeGetattrer)((*ITNode)(nil))
|
var _ = (fs.NodeGetattrer)((*ITNode)(nil))
|
||||||
func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
|
func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
|
||||||
log.Info("getattr").Str("path", bn.path).Send();
|
log.Info("getattr").Str("path", bn.path).Send()
|
||||||
out.Ino = bn.Ino
|
out.Ino = bn.Ino
|
||||||
out.Mtime = bn.self.modtime
|
out.Mtime = bn.self.modtime
|
||||||
out.Ctime = bn.self.modtime
|
out.Ctime = bn.self.modtime
|
||||||
@ -342,8 +341,8 @@ func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOu
|
|||||||
var _ = (fs.NodeSetattrer)((*ITNode)(nil))
|
var _ = (fs.NodeSetattrer)((*ITNode)(nil))
|
||||||
func (bn *ITNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
|
func (bn *ITNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
|
||||||
log.Info("setattr").Str("path", bn.path).Send()
|
log.Info("setattr").Str("path", bn.path).Send()
|
||||||
out.Size = 0;
|
out.Size = 0
|
||||||
out.Mtime = 0;
|
out.Mtime = 0
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,10 +364,10 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
|
|||||||
}
|
}
|
||||||
return fh, fuse.FOPEN_DIRECT_IO, 0
|
return fh, fuse.FOPEN_DIRECT_IO, 0
|
||||||
} else {
|
} else {
|
||||||
log.Info("Opening file: read").Str("path", f.path).Send();
|
log.Info("Opening file: read").Str("path", f.path).Send()
|
||||||
fp, err := myfs.Open(f.path)
|
fp, err := myfs.Open(f.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Opening file failed").Str("path", f.path).Err(err).Send();
|
log.Error("Opening file failed").Str("path", f.path).Err(err).Send()
|
||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +378,7 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
|
|||||||
go func() {
|
go func() {
|
||||||
// For every progress event
|
// For every progress event
|
||||||
for sent := range fp.Progress() {
|
for sent := range fp.Progress() {
|
||||||
log.Info("Progress").Int("bytes", int(sent)).Int("of", int(f.self.size)).Send();
|
log.Info("Progress").Int("bytes", int(sent)).Int("of", int(f.self.size)).Send()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
2
main.go
2
main.go
@ -188,7 +188,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
// Start fuse socket
|
// Start fuse socket
|
||||||
if k.Bool("fuse.enabled") {
|
if k.Bool("fuse.enabled") {
|
||||||
err = startFuse(ctx, dev)
|
err = startFUSE(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error starting fuse socket").Err(err).Send()
|
log.Error("Error starting fuse socket").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user