Added FUSE support #55
@ -103,7 +103,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
||||
// root folder
|
||||
r := make([]fuse.DirEntry, 2)
|
||||
r[0] = fuse.DirEntry{
|
||||
Name: "device",
|
||||
Name: "info",
|
||||
Ino: 0,
|
||||
Mode: fuse.S_IFDIR,
|
||||
}
|
||||
@ -115,7 +115,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
||||
return fs.NewListDirStream(r), 0
|
||||
|
||||
case 1:
|
||||
// device folder
|
||||
// info folder
|
||||
r := make([]fuse.DirEntry, 6)
|
||||
for ind, value := range properties {
|
||||
r[ind] = fuse.DirEntry{
|
||||
@ -128,7 +128,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
||||
return fs.NewListDirStream(r), 0
|
||||
|
||||
Elara6331 marked this conversation as resolved
Outdated
|
||||
case 2:
|
||||
// on device
|
||||
// on info
|
||||
files, err := myfs.ReadDir(n.path)
|
||||
if err != nil {
|
||||
log.Error("FUSE ReadDir failed").Str("path", n.path).Err(err).Send()
|
||||
@ -185,7 +185,7 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
|
||||
switch n.kind {
|
||||
case 0:
|
||||
// root folder
|
||||
if name == "device" {
|
||||
if name == "info" {
|
||||
stable := fs.StableAttr{
|
||||
Mode: fuse.S_IFDIR,
|
||||
Ino: uint64(0),
|
||||
@ -203,7 +203,7 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
|
||||
return child, 0
|
||||
}
|
||||
case 1:
|
||||
// device folder
|
||||
// info folder
|
||||
for _, value := range properties {
|
||||
if value.name == name {
|
||||
stable := fs.StableAttr{
|
||||
|
Loading…
Reference in New Issue
Block a user
How would you recommend doing this? I suppose it could fail for all sorts of reasons such as
ENOENT
EIO
EINVAL
ECONNABORTED
ECONNREFUSED
ECONNRESET
EISNAM
In other places such as when we open a file, we could have
EISDIR
EEXIST
Again, I'm sorry but I'm not a Go expert and don't really now how to do this properly.. especially when dealing with
FSError
The
err
can be several different kinds of errors, andFSError
is just one of them. It's actually a type I made. You can see it here: https://gitea.arsenm.dev/Arsen6331/infinitime/src/commit/512d48bc2469/blefs/error.go#L20. It contains an error code you can check to see what went wrong, and you can scroll down to see the meaning of each code.In this case, I'd use a Go type switch to check which error type actually occurred and then check the code or do whatever else needs to be done. Maybe there could be a function like
syscallErr()
that takes anerror
and returns the proper syscall error?If you don't feel comfortable doing that, I can merge this and then implement it myself and send you the commit so you can see how I did it, or you can just try it yourself, whatever you feel would be better.
Something like in 4c59561a99? There are a few
TODO
where I'm not sure what the correct POSIX error would be and improvised. If you have a better idea, feel free to change them thoughThat looks good, thanks