Implemented Read for watcher
This commit is contained in:
parent
2c899b4660
commit
e2bd52b5a0
11
fuse.go
11
fuse.go
@ -248,6 +248,7 @@ func (fh *bytesFileReadHandle) Read(ctx context.Context, dest []byte, off int64)
|
|||||||
|
|
||||||
type sensorFileReadHandle struct {
|
type sensorFileReadHandle struct {
|
||||||
ch <-chan uint8
|
ch <-chan uint8
|
||||||
|
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) {
|
||||||
@ -256,6 +257,12 @@ func (fh *sensorFileReadHandle) Read(ctx context.Context, dest []byte, off int64
|
|||||||
return fuse.ReadResultData(content), 0
|
return fuse.ReadResultData(content), 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ = (fs.FileFlusher)((*sensorFileReadHandle)(nil))
|
||||||
|
func (fh *sensorFileReadHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
||||||
|
fh.cancel()
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
type bytesFileWriteHandle struct {
|
type bytesFileWriteHandle struct {
|
||||||
content []byte
|
content []byte
|
||||||
@ -395,13 +402,15 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
|
|||||||
|
|
||||||
for _, value := range properties {
|
for _, value := range properties {
|
||||||
if value.Ino == f.Ino {
|
if value.Ino == f.Ino {
|
||||||
ans, err := value.gen(ctx)
|
sub_ctx, cancel := context.WithCancel(ctx)
|
||||||
|
ans, err := value.gen(sub_ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
fh = &sensorFileReadHandle{
|
fh = &sensorFileReadHandle{
|
||||||
ch: ans,
|
ch: ans,
|
||||||
|
cancel : cancel,
|
||||||
}
|
}
|
||||||
return fh, fuse.FOPEN_DIRECT_IO, 0
|
return fh, fuse.FOPEN_DIRECT_IO, 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user