forked from Elara6331/itd
Compare commits
No commits in common. "3b9690103b489b23383c1c076837731f6a815bd8" and "cc6fc3e1dc9eeae7624922f622d3e09277594377" have entirely different histories.
3b9690103b
...
cc6fc3e1dc
12
fuse.go
12
fuse.go
@ -9,18 +9,10 @@ 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, err := fusefs.BuildRootNode(dev)
|
root := 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.
|
||||||
|
@ -36,19 +36,11 @@ type ITNode struct {
|
|||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
var myfs *blefs.FS = nil
|
func BuildRootNode(dev *infinitime.Device) *ITNode {
|
||||||
var inodemap map[string]uint64 = nil
|
|
||||||
|
|
||||||
func BuildRootNode(dev *infinitime.Device) (*ITNode, error) {
|
|
||||||
var err error
|
|
||||||
inodemap = make(map[string]uint64)
|
inodemap = make(map[string]uint64)
|
||||||
myfs, err = dev.FS()
|
myfs, _ = dev.FS()
|
||||||
if err != nil {
|
|
||||||
log.Error("FUSE Failed to get filesystem").Err(err).Send()
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &ITNode{kind: 0}, nil
|
return &ITNode{kind: 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = make([]ITProperty, 6)
|
var properties = make([]ITProperty, 6)
|
||||||
@ -88,7 +80,11 @@ func BuildProperties(dev *infinitime.Device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var _ fs.NodeReaddirer = (*ITNode)(nil)
|
|
||||||
|
var myfs *blefs.FS = nil;
|
||||||
|
var inodemap map[string]uint64 = nil;
|
||||||
|
|
||||||
|
var _ = (fs.NodeReaddirer)((*ITNode)(nil))
|
||||||
|
|
||||||
// Readdir is part of the NodeReaddirer interface
|
// Readdir is part of the NodeReaddirer interface
|
||||||
func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
||||||
@ -123,21 +119,12 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// on device
|
// on device
|
||||||
files, err := myfs.ReadDir(n.path)
|
files, _ := myfs.ReadDir(n.path)
|
||||||
if err != nil {
|
log.Info("readdir").Str("path", n.path).Int("objects", len(files)).Send()
|
||||||
log.Error("FUSE ReadDir failed").Str("path", n.path).Err(err).Send()
|
|
||||||
return nil, syscall.ENOENT
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debug("FUSE ReadDir succeeded").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, err := entry.Info()
|
info, _ := entry.Info()
|
||||||
if err != nil {
|
|
||||||
log.Error("FUSE Info failed").Str("path", n.path).Err(err).Send()
|
|
||||||
return nil, syscall.ENOENT
|
|
||||||
}
|
|
||||||
name := info.Name()
|
name := info.Name()
|
||||||
|
|
||||||
file := DirEntry{
|
file := DirEntry{
|
||||||
@ -174,7 +161,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
|||||||
return fs.NewListDirStream(r), 0
|
return fs.NewListDirStream(r), 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeLookuper = (*ITNode)(nil)
|
var _ = (fs.NodeLookuper)((*ITNode)(nil))
|
||||||
func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
|
func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
|
||||||
switch n.kind {
|
switch n.kind {
|
||||||
case 0:
|
case 0:
|
||||||
@ -219,9 +206,9 @@ 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.Debug("FUSE Lookup successful").Str("path", file.path).Send()
|
log.Info("LookUp successful").Str("path", file.path).Send()
|
||||||
|
|
||||||
if file.isDir {
|
if file.isDir {
|
||||||
stable := fs.StableAttr{
|
stable := fs.StableAttr{
|
||||||
@ -243,9 +230,9 @@ 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("FUSE Lookup failed").Str("path", n.path + "/" + name).Send()
|
log.Warn("LookUp failed").Str("path", n.path + "/" + name).Send()
|
||||||
}
|
}
|
||||||
return nil, syscall.ENOENT
|
return nil, syscall.ENOENT
|
||||||
}
|
}
|
||||||
@ -253,10 +240,10 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
|
|||||||
type bytesFileReadHandle struct {
|
type bytesFileReadHandle struct {
|
||||||
content []byte
|
content []byte
|
||||||
}
|
}
|
||||||
|
var _ = (fs.FileReader)((*bytesFileReadHandle)(nil))
|
||||||
|
|
||||||
var _ fs.FileReader = (*bytesFileReadHandle)(nil)
|
|
||||||
func (fh *bytesFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
|
func (fh *bytesFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
|
||||||
log.Debug("FUSE Executing Read").Int("size", len(fh.content)).Send()
|
log.Info("Executing Read").Int("size", len(fh.content)).Send()
|
||||||
end := off + int64(len(dest))
|
end := off + int64(len(dest))
|
||||||
if end > int64(len(fh.content)) {
|
if end > int64(len(fh.content)) {
|
||||||
end = int64(len(fh.content))
|
end = int64(len(fh.content))
|
||||||
@ -268,13 +255,13 @@ type sensorFileReadHandle struct {
|
|||||||
ch <-chan []byte
|
ch <-chan []byte
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
}
|
}
|
||||||
var _ fs.FileReader = (*sensorFileReadHandle)(nil)
|
var _ = (fs.FileReader)((*sensorFileReadHandle)(nil))
|
||||||
func (fh *sensorFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
|
func (fh *sensorFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
|
||||||
content := <-fh.ch
|
content := <-fh.ch
|
||||||
return fuse.ReadResultData(content), 0
|
return fuse.ReadResultData(content), 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.FileFlusher = (*sensorFileReadHandle)(nil)
|
var _ = (fs.FileFlusher)((*sensorFileReadHandle)(nil))
|
||||||
func (fh *sensorFileReadHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
func (fh *sensorFileReadHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
||||||
fh.cancel()
|
fh.cancel()
|
||||||
return 0
|
return 0
|
||||||
@ -286,7 +273,7 @@ type bytesFileWriteHandle struct {
|
|||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.FileWriter = (*bytesFileWriteHandle)(nil)
|
var _ = (fs.FileWriter)((*bytesFileWriteHandle)(nil))
|
||||||
func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno) {
|
func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno) {
|
||||||
log.Info("Executing Write").Str("path", fh.path).Int("prev_size", len(fh.content)).Int("next_size", len(data)).Send()
|
log.Info("Executing Write").Str("path", fh.path).Int("prev_size", len(fh.content)).Int("next_size", len(data)).Send()
|
||||||
if off != int64(len(fh.content)) {
|
if off != int64(len(fh.content)) {
|
||||||
@ -295,55 +282,55 @@ func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int6
|
|||||||
return uint32(len(data)), 0
|
return uint32(len(data)), 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.FileFlusher = (*bytesFileWriteHandle)(nil)
|
var _ = (fs.FileFlusher)((*bytesFileWriteHandle)(nil))
|
||||||
func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
||||||
if len(fh.content) == 0 {
|
if len(fh.content) == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("FUSE Attempting flush").Str("path", fh.path).Send()
|
log.Info("Attempting flush").Str("path", fh.path).Send()
|
||||||
fp, err := myfs.Create(fh.path, uint32(len(fh.content)))
|
fp, err := myfs.Create(fh.path, uint32(len(fh.content)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Flush failed: create").Str("path", fh.path).Err(err).Send()
|
log.Error("Flush failed: create").Str("path", fh.path).Err(err).Send()
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// For every progress event
|
// For every progress event
|
||||||
for sent := range fp.Progress() {
|
for sent := range fp.Progress() {
|
||||||
log.Debug("FUSE Flush progress").Int("bytes", int(sent)).Int("total", len(fh.content)).Send()
|
log.Info("Progress").Int("bytes", int(sent)).Int("of", len(fh.content)).Send();
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
r := bytes.NewReader(fh.content)
|
r := bytes.NewReader(fh.content)
|
||||||
nread, err := io.Copy(fp, r)
|
nread, err := io.Copy(fp, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Flush failed during write").Str("path", fh.path).Err(err).Send()
|
log.Error("Flush failed: write").Str("path", fh.path).Err(err).Send()
|
||||||
fp.Close()
|
fp.Close()
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
if int(nread) != len(fh.content) {
|
if int(nread) != len(fh.content) {
|
||||||
log.Error("FUSE Flush failed during write").Str("path", fh.path).Int("expect", len(fh.content)).Int("got", int(nread)).Send()
|
log.Error("Flush failed: write").Str("path", fh.path).Int("expect", len(fh.content)).Int("got", int(nread)).Send()
|
||||||
fp.Close()
|
fp.Close()
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
err = fp.Close()
|
err = fp.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Flush failed during close").Str("path", fh.path).Err(err).Send()
|
log.Error("Flush failed: close").Str("path", fh.path).Err(err).Send()
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
log.Debug("FUSE Flush done").Str("path", fh.path).Int("size", len(fh.content)).Send()
|
log.Info("Flush done").Str("path", fh.path).Int("size", len(fh.content)).Send()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
var _ fs.FileFsyncer = (*bytesFileWriteHandle)(nil)
|
var _ = (fs.FileFsyncer)((*bytesFileWriteHandle)(nil))
|
||||||
func (fh *bytesFileWriteHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) {
|
func (fh *bytesFileWriteHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) {
|
||||||
return fh.Flush(ctx)
|
return fh.Flush(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
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.Debug("FUSE 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
|
||||||
@ -352,36 +339,36 @@ func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOu
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
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.Debug("FUSE 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
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeOpener = (*ITNode)(nil)
|
var _ = (fs.NodeOpener)((*ITNode)(nil))
|
||||||
func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
|
func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
|
||||||
switch f.kind {
|
switch f.kind {
|
||||||
case 2:
|
case 2:
|
||||||
// FS file
|
// FS file
|
||||||
if openFlags&syscall.O_RDWR != 0 {
|
if openFlags&syscall.O_RDWR != 0 {
|
||||||
log.Error("FUSE Open failed: RDWR").Str("path", f.path).Send()
|
log.Warn("open: failed RDWR").Str("path", f.path).Send()
|
||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
if openFlags & syscall.O_WRONLY != 0 {
|
if openFlags & syscall.O_WRONLY != 0 {
|
||||||
log.Debug("FUSE Opening for write").Str("path", f.path).Send()
|
log.Info("Opening file: write").Str("path", f.path).Send()
|
||||||
fh = &bytesFileWriteHandle{
|
fh = &bytesFileWriteHandle{
|
||||||
path : f.path,
|
path : f.path,
|
||||||
content : make([]byte, 0),
|
content : make([]byte, 0),
|
||||||
}
|
}
|
||||||
return fh, fuse.FOPEN_DIRECT_IO, 0
|
return fh, fuse.FOPEN_DIRECT_IO, 0
|
||||||
} else {
|
} else {
|
||||||
log.Debug("FUSE Opening for 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("FUSE: Opening 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,13 +379,13 @@ 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.Debug("FUSE Read progress").Int("bytes", int(sent)).Int("total", int(f.self.size)).Send()
|
log.Info("Progress").Int("bytes", int(sent)).Int("of", int(f.self.size)).Send();
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
_, err = io.Copy(b, fp)
|
_, err = io.Copy(b, fp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Read failed").Str("path", f.path).Err(err).Send()
|
log.Error("Read failed").Str("path", f.path).Err(err).Send()
|
||||||
fp.Close()
|
fp.Close()
|
||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
@ -436,7 +423,7 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
|
|||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeCreater = (*ITNode)(nil)
|
var _ = (fs.NodeCreater)((*ITNode)(nil))
|
||||||
func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
|
func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
|
||||||
if f.kind != 2 {
|
if f.kind != 2 {
|
||||||
return nil, nil, 0, syscall.EROFS
|
return nil, nil, 0, syscall.EROFS
|
||||||
@ -461,13 +448,13 @@ func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uin
|
|||||||
content : make([]byte, 0),
|
content : make([]byte, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("FUSE Creating file").Str("path", path).Send()
|
log.Info("Creating file").Str("path", path).Send()
|
||||||
|
|
||||||
errno = 0
|
errno = 0
|
||||||
return node, fh, fuseFlags, 0
|
return node, fh, fuseFlags, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeMkdirer = (*ITNode)(nil)
|
var _ = (fs.NodeMkdirer)((*ITNode)(nil))
|
||||||
func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
|
func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
|
||||||
if f.kind != 2 {
|
if f.kind != 2 {
|
||||||
return nil, syscall.EROFS
|
return nil, syscall.EROFS
|
||||||
@ -476,7 +463,7 @@ func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.
|
|||||||
path := f.path + "/" + name
|
path := f.path + "/" + name
|
||||||
err := myfs.Mkdir(path)
|
err := myfs.Mkdir(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Mkdir failed").
|
log.Info("Mkdir failed").
|
||||||
Str("path", path).
|
Str("path", path).
|
||||||
Err(err).
|
Err(err).
|
||||||
Send()
|
Send()
|
||||||
@ -496,21 +483,21 @@ func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.
|
|||||||
}
|
}
|
||||||
node := f.NewInode(ctx, operations, stable)
|
node := f.NewInode(ctx, operations, stable)
|
||||||
|
|
||||||
log.Debug("FUSE Mkdir success").
|
log.Info("Mkdir sucess").
|
||||||
Str("path", path).
|
Str("path", path).
|
||||||
Int("ino", int(ino)).
|
Int("ino", int(ino)).
|
||||||
Send()
|
Send()
|
||||||
return node, 0
|
return node, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeRenamer = (*ITNode)(nil)
|
var _ = (fs.NodeRenamer)((*ITNode)(nil))
|
||||||
func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno {
|
func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno {
|
||||||
p1 := f.path + "/" + name
|
p1 := f.path + "/" + name
|
||||||
p2 := newParent.EmbeddedInode().Path(nil)[2:] + "/" + newName
|
p2 := newParent.EmbeddedInode().Path(nil)[2:] + "/" + newName
|
||||||
|
|
||||||
err := myfs.Rename(p1, p2)
|
err := myfs.Rename(p1, p2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Rename failed").
|
log.Error("Rename failed").
|
||||||
Str("src", p1).
|
Str("src", p1).
|
||||||
Str("dest", p2).
|
Str("dest", p2).
|
||||||
Err(err).
|
Err(err).
|
||||||
@ -518,7 +505,7 @@ func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbe
|
|||||||
|
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
log.Debug("FUSE Rename sucess").
|
log.Info("Rename sucess").
|
||||||
Str("src", p1).
|
Str("src", p1).
|
||||||
Str("dest", p2).
|
Str("dest", p2).
|
||||||
Send()
|
Send()
|
||||||
@ -530,12 +517,12 @@ func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbe
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeUnlinker = (*ITNode)(nil)
|
var _ = (fs.NodeUnlinker)((*ITNode)(nil))
|
||||||
func (f *ITNode) Unlink(ctx context.Context, name string) syscall.Errno {
|
func (f *ITNode) Unlink(ctx context.Context, name string) syscall.Errno {
|
||||||
delete(inodemap, f.path + "/" + name)
|
delete(inodemap, f.path + "/" + name)
|
||||||
err := myfs.Remove(f.path + "/" + name)
|
err := myfs.Remove(f.path + "/" + name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("FUSE Unlink failed").
|
log.Error("Unlink failed").
|
||||||
Str("file", f.path + "/" + name).
|
Str("file", f.path + "/" + name).
|
||||||
Err(err).
|
Err(err).
|
||||||
Send()
|
Send()
|
||||||
@ -543,13 +530,13 @@ func (f *ITNode) Unlink(ctx context.Context, name string) syscall.Errno {
|
|||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("FUSE Unlink success").
|
log.Info("Unlink success").
|
||||||
Str("file", f.path + "/" + name).
|
Str("file", f.path + "/" + name).
|
||||||
Send()
|
Send()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fs.NodeRmdirer = (*ITNode)(nil)
|
var _ = (fs.NodeRmdirer)((*ITNode)(nil))
|
||||||
func (f *ITNode) Rmdir(ctx context.Context, name string) syscall.Errno {
|
func (f *ITNode) Rmdir(ctx context.Context, name string) syscall.Errno {
|
||||||
return f.Unlink(ctx, name)
|
return f.Unlink(ctx, name)
|
||||||
}
|
}
|
||||||
|
15
main.go
15
main.go
@ -181,19 +181,18 @@ func main() {
|
|||||||
log.Error("Error intializing puremaps integration").Err(err).Send()
|
log.Error("Error intializing puremaps integration").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start fuse socket
|
|
||||||
if k.Bool("fuse.enabled") {
|
|
||||||
err = startFUSE(ctx, dev)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Error starting fuse socket").Err(err).Send()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start control socket
|
// Start control socket
|
||||||
err = startSocket(ctx, dev)
|
err = startSocket(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error starting socket").Err(err).Send()
|
log.Error("Error starting socket").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
// Start fuse socket
|
||||||
|
if k.Bool("fuse.enabled") {
|
||||||
|
err = startFuse(ctx, dev)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error starting fuse socket").Err(err).Send()
|
||||||
|
}
|
||||||
|
}
|
||||||
// Block forever
|
// Block forever
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user