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 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= 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= 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() } 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= 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= 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