github.com/hanwen/go-fuse@v1.0.0/fuse/pathfs/api.go (about) 1 // Copyright 2016 the Go-FUSE Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package pathfs 6 7 import ( 8 "time" 9 10 "github.com/hanwen/go-fuse/fuse" 11 "github.com/hanwen/go-fuse/fuse/nodefs" 12 ) 13 14 // A filesystem API that uses paths rather than inodes. A minimal 15 // file system should have at least a functional GetAttr method. 16 // Typically, each call happens in its own goroutine, so take care to 17 // make the file system thread-safe. 18 // 19 // NewDefaultFileSystem provides a null implementation of required 20 // methods. 21 type FileSystem interface { 22 // Used for pretty printing. 23 String() string 24 25 // If called, provide debug output through the log package. 26 SetDebug(debug bool) 27 28 // Attributes. This function is the main entry point, through 29 // which FUSE discovers which files and directories exist. 30 // 31 // If the filesystem wants to implement hard-links, it should 32 // return consistent non-zero FileInfo.Ino data. Using 33 // hardlinks incurs a performance hit. 34 GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) 35 36 // These should update the file's ctime too. 37 Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) 38 Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) 39 Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) 40 41 Truncate(name string, size uint64, context *fuse.Context) (code fuse.Status) 42 43 Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) 44 45 // Tree structure 46 Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) 47 Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status 48 Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status 49 Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) 50 Rmdir(name string, context *fuse.Context) (code fuse.Status) 51 Unlink(name string, context *fuse.Context) (code fuse.Status) 52 53 // Extended attributes. 54 GetXAttr(name string, attribute string, context *fuse.Context) (data []byte, code fuse.Status) 55 ListXAttr(name string, context *fuse.Context) (attributes []string, code fuse.Status) 56 RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status 57 SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status 58 59 // Called after mount. 60 OnMount(nodeFs *PathNodeFs) 61 OnUnmount() 62 63 // File handling. If opening for writing, the file's mtime 64 // should be updated too. 65 Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) 66 Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) 67 68 // Directory handling 69 OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, code fuse.Status) 70 71 // Symlinks. 72 Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) 73 Readlink(name string, context *fuse.Context) (string, fuse.Status) 74 75 StatFs(name string) *fuse.StatfsOut 76 } 77 78 type PathNodeFsOptions struct { 79 // If ClientInodes is set, use Inode returned from GetAttr to 80 // find hard-linked files. 81 ClientInodes bool 82 83 // Debug controls printing of debug information. 84 Debug bool 85 }