From 4814b0229b9a1cbecc15c509c674a2109aec2abd Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:55:28 +0700 Subject: [PATCH 1/7] added gitignore Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..adb36c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.exe \ No newline at end of file From 30d23de53936030206414d6da1e43e07d66acacf Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:56:11 +0700 Subject: [PATCH 2/7] hellofs go module Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- examples/hellofs/go.mod | 5 +++++ examples/hellofs/go.sum | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 examples/hellofs/go.mod create mode 100644 examples/hellofs/go.sum diff --git a/examples/hellofs/go.mod b/examples/hellofs/go.mod new file mode 100644 index 0000000..ecf94e9 --- /dev/null +++ b/examples/hellofs/go.mod @@ -0,0 +1,5 @@ +module hellofs + +go 1.17 + +require github.com/billziss-gh/cgofuse v1.5.0 diff --git a/examples/hellofs/go.sum b/examples/hellofs/go.sum new file mode 100644 index 0000000..7de6b1b --- /dev/null +++ b/examples/hellofs/go.sum @@ -0,0 +1,2 @@ +github.com/billziss-gh/cgofuse v1.5.0 h1:kH516I/s+Ab4diL/Y/ayFeUjjA8ey+JK12xDfBf4HEs= +github.com/billziss-gh/cgofuse v1.5.0/go.mod h1:LJjoaUojlVjgo5GQoEJTcJNqZJeRU0nCR84CyxKt2YM= From bf9a897d7f03c5d2dbf7b962b83acde5e91024a4 Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:56:34 +0700 Subject: [PATCH 3/7] notifyfs go module Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- examples/notifyfs/go.mod | 5 +++++ examples/notifyfs/go.sum | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 examples/notifyfs/go.mod create mode 100644 examples/notifyfs/go.sum diff --git a/examples/notifyfs/go.mod b/examples/notifyfs/go.mod new file mode 100644 index 0000000..7183554 --- /dev/null +++ b/examples/notifyfs/go.mod @@ -0,0 +1,5 @@ +module notifyfs + +go 1.17 + +require github.com/billziss-gh/cgofuse v1.5.0 diff --git a/examples/notifyfs/go.sum b/examples/notifyfs/go.sum new file mode 100644 index 0000000..7de6b1b --- /dev/null +++ b/examples/notifyfs/go.sum @@ -0,0 +1,2 @@ +github.com/billziss-gh/cgofuse v1.5.0 h1:kH516I/s+Ab4diL/Y/ayFeUjjA8ey+JK12xDfBf4HEs= +github.com/billziss-gh/cgofuse v1.5.0/go.mod h1:LJjoaUojlVjgo5GQoEJTcJNqZJeRU0nCR84CyxKt2YM= From 60fa14080e1c35aed8de773181e7702ccf01f675 Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:57:02 +0700 Subject: [PATCH 4/7] passthrough go module Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- examples/passthrough/go.mod | 5 +++++ examples/passthrough/go.sum | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 examples/passthrough/go.mod create mode 100644 examples/passthrough/go.sum diff --git a/examples/passthrough/go.mod b/examples/passthrough/go.mod new file mode 100644 index 0000000..a5e6e4a --- /dev/null +++ b/examples/passthrough/go.mod @@ -0,0 +1,5 @@ +module passthrough + +go 1.17 + +require github.com/billziss-gh/cgofuse v1.5.0 diff --git a/examples/passthrough/go.sum b/examples/passthrough/go.sum new file mode 100644 index 0000000..7de6b1b --- /dev/null +++ b/examples/passthrough/go.sum @@ -0,0 +1,2 @@ +github.com/billziss-gh/cgofuse v1.5.0 h1:kH516I/s+Ab4diL/Y/ayFeUjjA8ey+JK12xDfBf4HEs= +github.com/billziss-gh/cgofuse v1.5.0/go.mod h1:LJjoaUojlVjgo5GQoEJTcJNqZJeRU0nCR84CyxKt2YM= From 9e3afb1480ac02d8c46a955fc6138e543ab08096 Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:57:41 +0700 Subject: [PATCH 5/7] memfs go module Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- examples/memfs/go.mod | 5 +++++ examples/memfs/go.sum | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 examples/memfs/go.mod create mode 100644 examples/memfs/go.sum diff --git a/examples/memfs/go.mod b/examples/memfs/go.mod new file mode 100644 index 0000000..f0b41a3 --- /dev/null +++ b/examples/memfs/go.mod @@ -0,0 +1,5 @@ +module memfs + +go 1.17 + +require github.com/billziss-gh/cgofuse v1.5.0 diff --git a/examples/memfs/go.sum b/examples/memfs/go.sum new file mode 100644 index 0000000..7de6b1b --- /dev/null +++ b/examples/memfs/go.sum @@ -0,0 +1,2 @@ +github.com/billziss-gh/cgofuse v1.5.0 h1:kH516I/s+Ab4diL/Y/ayFeUjjA8ey+JK12xDfBf4HEs= +github.com/billziss-gh/cgofuse v1.5.0/go.mod h1:LJjoaUojlVjgo5GQoEJTcJNqZJeRU0nCR84CyxKt2YM= From d443151fbba3294e4198fe279335c3cd96215e22 Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:58:21 +0700 Subject: [PATCH 6/7] memfs added Statfs example Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- examples/memfs/memfs.go | 51 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/examples/memfs/memfs.go b/examples/memfs/memfs.go index 5eb3ddd..f3b30e1 100644 --- a/examples/memfs/memfs.go +++ b/examples/memfs/memfs.go @@ -8,8 +8,9 @@ * * It is licensed under the MIT license. The full license text can be found * in the License.txt file at the root of this project. + * */ - + package main import ( @@ -98,6 +99,33 @@ type Memfs struct { openmap map[uint64]*node_t } + +func (self *Memfs) Statfs(path string, stat *fuse.Statfs_t) (err int) { + fmt.Printf("STAT FS!!! %s\n", path) + stat.Bsize = 4096 + // f_frsize + stat.Frsize = 4096 + + // 8 EB - 1 + vtotal := (8 << 50) / stat.Frsize * 1024 - 1 + vavail := (2 << 50) / stat.Frsize * 1024 + vfree := (1 << 50) / stat.Frsize * 1024 + //used := total - free + + // f_blocks + stat.Blocks = vtotal + stat.Bfree = vfree + stat.Bavail = vavail + + stat.Files = 2240224 + stat.Ffree = 1927486 + stat.Favail = 9900000 + + stat.Namemax = 255 + return 0 +} + + func (self *Memfs) Mknod(path string, mode uint32, dev uint64) (errc int) { defer trace(path, mode, dev)(&errc) defer self.synchronize()() @@ -582,8 +610,21 @@ var _ fuse.FileSystemSetcrtime = (*Memfs)(nil) var _ fuse.FileSystemSetchgtime = (*Memfs)(nil) func main() { - memfs := NewMemfs() - host := fuse.NewFileSystemHost(memfs) - host.SetCapReaddirPlus(true) - host.Mount("", os.Args[1:]) + var wg sync.WaitGroup + cpy := 4 + wg.Add(cpy) + for i := 0; i < cpy; i++ { + memfs := NewMemfs() + host := fuse.NewFileSystemHost(memfs) + host.SetCapReaddirPlus(true) + go func(i int) { + fmt.Printf("mount %d\n", i) + host.Mount("", append([]string{ + "-o", "ExactFileSystemName=NTFS", + "-o", fmt.Sprintf("volname=MyVolume%d", i), + }, os.Args[1:]...)) + wg.Done() + }(i) + } + wg.Wait() } From 1b18cfff9e52015a35b80f6c6061ac8894a4213b Mon Sep 17 00:00:00 2001 From: ii64 <26342994+ii64@users.noreply.github.com> Date: Mon, 11 Oct 2021 15:19:14 +0700 Subject: [PATCH 7/7] fuse go module Signed-off-by: ii64 <26342994+ii64@users.noreply.github.com> --- fuse/go.mod | 3 +++ go.mod | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 fuse/go.mod create mode 100644 go.mod diff --git a/fuse/go.mod b/fuse/go.mod new file mode 100644 index 0000000..16cb3c3 --- /dev/null +++ b/fuse/go.mod @@ -0,0 +1,3 @@ +module github.com/billziss-gh/cgofuse/fuse + +go 1.17 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bfe7655 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/billziss-gh/cgofuse + +go 1.17