Commit 6a1014cd authored by Ben Sidhom's avatar Ben Sidhom Committed by Aaron Jacobs

Enable StatFS on dynamicfs

MacOS apparently invokes StatFS on os.Lstat/os.Stat. Note that the
return fields are not actually populated here.
parent 8edb6e44
package dynamicfs package dynamicfs
import ( import (
"strings" "fmt"
"io" "io"
"log"
"os"
"strings"
"sync"
"time"
"golang.org/x/net/context" "golang.org/x/net/context"
"github.com/jacobsa/timeutil"
"github.com/jacobsa/fuse" "github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/fuse/fuseops" "github.com/jacobsa/fuse/fuseops"
"os" "github.com/jacobsa/fuse/fuseutil"
"fmt" "github.com/jacobsa/timeutil"
"log"
"sync"
"time"
) )
// Create a file system that contains 2 files (`age` and `weekday`) and no directories. Every time // Create a file system that contains 2 files (`age` and `weekday`) and no directories. Every time
...@@ -111,8 +111,8 @@ var gInodeInfo = map[fuseops.InodeID]inodeInfo{ ...@@ -111,8 +111,8 @@ var gInodeInfo = map[fuseops.InodeID]inodeInfo{
} }
func findChildInode( func findChildInode(
name string, name string,
children []fuseutil.Dirent) (inode fuseops.InodeID, err error) { children []fuseutil.Dirent) (inode fuseops.InodeID, err error) {
for _, e := range children { for _, e := range children {
if e.Name == name { if e.Name == name {
inode = e.Inode inode = e.Inode
...@@ -131,13 +131,12 @@ func (fs *dynamicFS) findUnusedHandle() fuseops.HandleID { ...@@ -131,13 +131,12 @@ func (fs *dynamicFS) findUnusedHandle() fuseops.HandleID {
handle++ handle++
} }
fs.nextHandle = handle + 1 fs.nextHandle = handle + 1
log.Printf("Minting new handle: %d", handle)
return handle return handle
} }
func (fs *dynamicFS) GetInodeAttributes( func (fs *dynamicFS) GetInodeAttributes(
ctx context.Context, ctx context.Context,
op *fuseops.GetInodeAttributesOp) (err error) { op *fuseops.GetInodeAttributesOp) (err error) {
// Find the info for this inode. // Find the info for this inode.
info, ok := gInodeInfo[op.Inode] info, ok := gInodeInfo[op.Inode]
if !ok { if !ok {
...@@ -150,8 +149,8 @@ op *fuseops.GetInodeAttributesOp) (err error) { ...@@ -150,8 +149,8 @@ op *fuseops.GetInodeAttributesOp) (err error) {
} }
func (fs *dynamicFS) LookUpInode( func (fs *dynamicFS) LookUpInode(
ctx context.Context, ctx context.Context,
op *fuseops.LookUpInodeOp) (err error) { op *fuseops.LookUpInodeOp) (err error) {
// Find the info for the parent. // Find the info for the parent.
parentInfo, ok := gInodeInfo[op.Parent] parentInfo, ok := gInodeInfo[op.Parent]
if !ok { if !ok {
...@@ -173,15 +172,15 @@ op *fuseops.LookUpInodeOp) (err error) { ...@@ -173,15 +172,15 @@ op *fuseops.LookUpInodeOp) (err error) {
} }
func (fs *dynamicFS) OpenDir( func (fs *dynamicFS) OpenDir(
ctx context.Context, ctx context.Context,
op *fuseops.OpenDirOp) (err error) { op *fuseops.OpenDirOp) (err error) {
// Allow opening directory. // Allow opening directory.
return return
} }
func (fs *dynamicFS) ReadDir( func (fs *dynamicFS) ReadDir(
ctx context.Context, ctx context.Context,
op *fuseops.ReadDirOp) (err error) { op *fuseops.ReadDirOp) (err error) {
// Find the info for this inode. // Find the info for this inode.
info, ok := gInodeInfo[op.Inode] info, ok := gInodeInfo[op.Inode]
if !ok { if !ok {
...@@ -218,8 +217,8 @@ op *fuseops.ReadDirOp) (err error) { ...@@ -218,8 +217,8 @@ op *fuseops.ReadDirOp) (err error) {
} }
func (fs *dynamicFS) OpenFile( func (fs *dynamicFS) OpenFile(
ctx context.Context, ctx context.Context,
op *fuseops.OpenFileOp) (err error) { op *fuseops.OpenFileOp) (err error) {
fs.mu.Lock() fs.mu.Lock()
defer fs.mu.Unlock() defer fs.mu.Unlock()
var contents string var contents string
...@@ -243,8 +242,8 @@ op *fuseops.OpenFileOp) (err error) { ...@@ -243,8 +242,8 @@ op *fuseops.OpenFileOp) (err error) {
} }
func (fs *dynamicFS) ReadFile( func (fs *dynamicFS) ReadFile(
ctx context.Context, ctx context.Context,
op *fuseops.ReadFileOp) (err error) { op *fuseops.ReadFileOp) (err error) {
fs.mu.Lock() fs.mu.Lock()
defer fs.mu.Unlock() defer fs.mu.Unlock()
contents, ok := fs.fileHandles[op.Handle] contents, ok := fs.fileHandles[op.Handle]
...@@ -275,3 +274,8 @@ func (fs *dynamicFS) ReleaseFileHandle( ...@@ -275,3 +274,8 @@ func (fs *dynamicFS) ReleaseFileHandle(
delete(fs.fileHandles, op.Handle) delete(fs.fileHandles, op.Handle)
return return
} }
func (fs *dynamicFS) StatFS(ctx context.Context,
op *fuseops.StatFSOp) (err error) {
return
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment