itd/internal/fusefs/syscallerr.go
yannickulrich 77680704e1 Added FUSE support (#55)
This exposes the watches' file system over FUSE. This way, we can access files on the watch without having to go through `itctl` or developing 3rd party tools.

**Features**

- [x] read/write access to the file system
- [x] read access to momentary sensor data
- [x] live access to sensor data (i.e. WatchMotion rather than Motion)
- [x] configuration of mount point

Co-authored-by: Yannick Ulrich <yannick.ulrich@durham.ac.uk>
Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/55
Co-authored-by: yannickulrich <yannick.ulrich@protonmail.com>
Co-committed-by: yannickulrich <yannick.ulrich@protonmail.com>
2023-03-25 22:23:51 +00:00

68 lines
2.1 KiB
Go

package fusefs
import (
"go.arsenm.dev/infinitime/blefs"
"syscall"
)
func syscallErr(err error) syscall.Errno {
if err == nil {
return 0
}
switch err {
case blefs.FSError{0x02}: // filesystem error
return syscall.EIO // TODO
case blefs.FSError{0x05}: // read-only filesystem
return syscall.EROFS
case blefs.FSError{0x03}: // no such file
return syscall.ENOENT
case blefs.FSError{0x04}: // protocol error
return syscall.EPROTO
case blefs.FSError{-5}: // input/output error
return syscall.EIO
case blefs.FSError{-84}: // filesystem is corrupted
return syscall.ENOTRECOVERABLE // TODO
case blefs.FSError{-2}: // no such directory entry
return syscall.ENOENT
case blefs.FSError{-17}: // entry already exists
return syscall.EEXIST
case blefs.FSError{-20}: // entry is not a directory
return syscall.ENOTDIR
case blefs.FSError{-39}: // directory is not empty
return syscall.ENOTEMPTY
case blefs.FSError{-9}: // bad file number
return syscall.EBADF
case blefs.FSError{-27}: // file is too large
return syscall.EFBIG
case blefs.FSError{-22}: // invalid parameter
return syscall.EINVAL
case blefs.FSError{-28}: // no space left on device
return syscall.ENOSPC
case blefs.FSError{-12}: // no more memory available
return syscall.ENOMEM
case blefs.FSError{-61}: // no attr available
return syscall.ENODATA // TODO
case blefs.FSError{-36}: // file name is too long
return syscall.ENAMETOOLONG
case blefs.ErrFileNotExists: // file does not exist
return syscall.ENOENT
case blefs.ErrFileReadOnly: // file is read only
return syscall.EACCES
case blefs.ErrFileWriteOnly: // file is write only
return syscall.EACCES
case blefs.ErrInvalidOffset: // invalid file offset
return syscall.EFAULT // TODO
case blefs.ErrOffsetChanged: // offset has already been changed
return syscall.ESPIPE
case blefs.ErrReadOpen: // only one file can be opened for reading at a time
return syscall.ENFILE
case blefs.ErrWriteOpen: // only one file can be opened for writing at a time
return syscall.ENFILE
case blefs.ErrNoRemoveRoot: // refusing to remove root directory
return syscall.EPERM
}
return syscall.EIO // TODO
}