feat: Implement example in alternative FUSE library
This commit is contained in:
@@ -9,14 +9,14 @@ import (
|
||||
"github.com/hanwen/go-fuse/v2/fuse"
|
||||
)
|
||||
|
||||
type Root struct {
|
||||
type FileSystem struct {
|
||||
fs.Inode
|
||||
}
|
||||
|
||||
func (r *Root) OnAdd(ctx context.Context) {
|
||||
r.AddChild(
|
||||
func (f *FileSystem) OnAdd(ctx context.Context) {
|
||||
f.AddChild(
|
||||
"hello_world.txt",
|
||||
r.NewPersistentInode(
|
||||
f.NewPersistentInode(
|
||||
ctx,
|
||||
&fs.MemRegularFile{
|
||||
Data: []byte("Hello, world!"),
|
||||
@@ -38,7 +38,7 @@ func main() {
|
||||
|
||||
server, err := fs.Mount(
|
||||
*mountpoint,
|
||||
&Root{},
|
||||
&FileSystem{},
|
||||
&fs.Options{
|
||||
Logger: func() *log.Logger {
|
||||
if *verbose {
|
||||
|
||||
55
cmd/stfs-jacobsa-fuse/main.go
Normal file
55
cmd/stfs-jacobsa-fuse/main.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/jacobsa/fuse"
|
||||
"github.com/jacobsa/fuse/fuseops"
|
||||
"github.com/jacobsa/fuse/fuseutil"
|
||||
)
|
||||
|
||||
type FileSystem struct {
|
||||
fuseutil.NotImplementedFileSystem
|
||||
}
|
||||
|
||||
func (f *FileSystem) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAttributesOp) error {
|
||||
op.Attributes = fuseops.InodeAttributes{
|
||||
Nlink: 1,
|
||||
Mode: 0555 | os.ModeDir,
|
||||
}
|
||||
|
||||
log.Println(op.Inode)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
mountpoint := flag.String("mountpoint", ".", "Directory to mount the FUSE in")
|
||||
verbose := flag.Bool("verbose", false, "Enable verbose logging")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
srv, err := fuse.Mount(
|
||||
*mountpoint,
|
||||
fuseutil.NewFileSystemServer(&FileSystem{}),
|
||||
&fuse.MountConfig{
|
||||
DebugLogger: func() *log.Logger {
|
||||
if *verbose {
|
||||
return log.Default()
|
||||
}
|
||||
|
||||
return nil
|
||||
}(),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := srv.Join(context.Background()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
5
go.mod
5
go.mod
@@ -4,4 +4,7 @@ go 1.17
|
||||
|
||||
require github.com/hanwen/go-fuse/v2 v2.1.0
|
||||
|
||||
require golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 // indirect
|
||||
require (
|
||||
github.com/jacobsa/fuse v0.0.0-20211108140243-7c4418392f94 // indirect
|
||||
golang.org/x/sys v0.0.0-20211112193437-faf0a1b62c6b // indirect
|
||||
)
|
||||
|
||||
18
go.sum
18
go.sum
@@ -1,9 +1,27 @@
|
||||
github.com/detailyang/go-fallocate v0.0.0-20180908115635-432fa640bd2e/go.mod h1:3ZQK6DMPSz/QZ73jlWxBtUhNA8xZx7LzUFSq/OfP8vk=
|
||||
github.com/hanwen/go-fuse v1.0.0 h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc=
|
||||
github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok=
|
||||
github.com/hanwen/go-fuse/v2 v2.1.0 h1:+32ffteETaLYClUj0a3aHjZ1hOPxxaNEHiZiujuDaek=
|
||||
github.com/hanwen/go-fuse/v2 v2.1.0/go.mod h1:oRyA5eK+pvJyv5otpO/DgccS8y/RvYMaO00GgRLGryc=
|
||||
github.com/jacobsa/fuse v0.0.0-20211108140243-7c4418392f94 h1:OksZl7Q9Xks+XMFrVbxqur+QarcAoTwPVkXRWTeD2uU=
|
||||
github.com/jacobsa/fuse v0.0.0-20211108140243-7c4418392f94/go.mod h1:xtZnnLxHY6QniCrfIpTwr5h8mH8zr+jsOFj0y9cfyp4=
|
||||
github.com/jacobsa/oglematchers v0.0.0-20150720000706-141901ea67cd/go.mod h1:TlmyIZDpGmwRoTWiakdr+HA1Tukze6C6XbRVidYq02M=
|
||||
github.com/jacobsa/oglemock v0.0.0-20150831005832-e94d794d06ff/go.mod h1:gJWba/XXGl0UoOmBQKRWCJdHrr3nE0T65t6ioaj3mLI=
|
||||
github.com/jacobsa/ogletest v0.0.0-20170503003838-80d50a735a11/go.mod h1:+DBdDyfoO2McrOyDemRBq0q9CMEByef7sYl7JH5Q3BI=
|
||||
github.com/jacobsa/reqtrace v0.0.0-20150505043853-245c9e0234cb/go.mod h1:ivcmUvxXWjb27NsPEaiYK7AidlZXS7oQ5PowUS9z3I4=
|
||||
github.com/jacobsa/syncutil v0.0.0-20180201203307-228ac8e5a6c3/go.mod h1:mPvulh9VKXvo+yOlrD4VYOOYuLdZJ36wa/5QIrtXvWs=
|
||||
github.com/jacobsa/timeutil v0.0.0-20170205232429-577e5acbbcf6/go.mod h1:JEWKD6V8xETMW+DEv+IQVz++f8Cn8O/X0HPeDY3qNis=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211112193437-faf0a1b62c6b h1:uo+9AuR+gDt/gdj+1BaLhdOHsaGI6YU6585IiDcLrFE=
|
||||
golang.org/x/sys v0.0.0-20211112193437-faf0a1b62c6b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
Reference in New Issue
Block a user