Handle more errors
This commit is contained in:
parent
673383f795
commit
a54ca7afdf
10
fuse.go
10
fuse.go
@ -12,7 +12,15 @@ import (
|
|||||||
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, err := fusefs.BuildRootNode(dev)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Building root node failed").
|
||||||
|
Err(err).
|
||||||
|
Send()
|
||||||
|
return err
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
server, err := fs.Mount(k.String("fuse.mountpoint"), root, &fs.Options{
|
server, err := fs.Mount(k.String("fuse.mountpoint"), root, &fs.Options{
|
||||||
MountOptions: fuse.MountOptions{
|
MountOptions: fuse.MountOptions{
|
||||||
// Set to true to see how the file system works.
|
// Set to true to see how the file system works.
|
||||||
|
@ -39,11 +39,16 @@ type ITNode struct {
|
|||||||
var myfs *blefs.FS = nil
|
var myfs *blefs.FS = nil
|
||||||
var inodemap map[string]uint64 = nil
|
var inodemap map[string]uint64 = nil
|
||||||
|
|
||||||
func BuildRootNode(dev *infinitime.Device) *ITNode {
|
func BuildRootNode(dev *infinitime.Device) (*ITNode, error) {
|
||||||
|
var err error
|
||||||
inodemap = make(map[string]uint64)
|
inodemap = make(map[string]uint64)
|
||||||
myfs, _ = dev.FS()
|
myfs, err = dev.FS()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("FUSE failed to get filesystem").Err(err).Send()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &ITNode{kind: 0}
|
return &ITNode{kind: 0}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = make([]ITProperty, 6)
|
var properties = make([]ITProperty, 6)
|
||||||
@ -118,12 +123,21 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// on device
|
// on device
|
||||||
files, _ := myfs.ReadDir(n.path)
|
files, err := myfs.ReadDir(n.path)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("ReadDir failed").Str("path", n.path).Err(err).Send()
|
||||||
|
return nil, syscall.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("readdir").Str("path", n.path).Int("objects", len(files)).Send()
|
log.Info("readdir").Str("path", n.path).Int("objects", len(files)).Send()
|
||||||
r := make([]fuse.DirEntry, len(files))
|
r := make([]fuse.DirEntry, len(files))
|
||||||
n.lst = make([]DirEntry, len(files))
|
n.lst = make([]DirEntry, len(files))
|
||||||
for ind, entry := range files {
|
for ind, entry := range files {
|
||||||
info, _ := entry.Info()
|
info, err := entry.Info()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Info failed").Str("path", n.path).Err(err).Send()
|
||||||
|
return nil, syscall.ENOENT
|
||||||
|
}
|
||||||
name := info.Name()
|
name := info.Name()
|
||||||
|
|
||||||
file := DirEntry{
|
file := DirEntry{
|
||||||
|
Loading…
Reference in New Issue
Block a user