-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi.go
More file actions
108 lines (87 loc) · 4.45 KB
/
api.go
File metadata and controls
108 lines (87 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2022 someonegg. All rights reserscoreed.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Copyright 2019 the Go-FUSE Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package pathfs provides a file system API expressed in filenames.
package pathfs
import (
"log"
"time"
"github.com/hanwen/go-fuse/v2/fuse"
)
// FileSystem API that uses paths rather than inodes. A minimal
// file system should have at least a functional GetAttr method, and
// the returned attr needs to have a valid Ino.
// Typically, each call happens in its own goroutine, so take care to
// make the file system thread-safe.
type FileSystem interface {
// uFh may be 0.
GetAttr(ctx *Context, path string, uFh uint32, out *fuse.Attr) fuse.Status
Access(ctx *Context, path string, mask uint32) fuse.Status
// Tree structure
Mknod(ctx *Context, path string, mode uint32, dev uint32) fuse.Status
Mkdir(ctx *Context, path string, mode uint32) fuse.Status
Unlink(ctx *Context, path string) fuse.Status
Rmdir(ctx *Context, path string) fuse.Status
Rename(ctx *Context, path string, newPath string) fuse.Status
Link(ctx *Context, path string, newPath string) fuse.Status
// Symlinks
Symlink(ctx *Context, path string, target string) fuse.Status
Readlink(ctx *Context, path string) (target string, code fuse.Status)
// Extended attributes
GetXAttr(ctx *Context, path string, attr string) (data []byte, code fuse.Status)
ListXAttr(ctx *Context, path string) (attrs []string, code fuse.Status)
SetXAttr(ctx *Context, path string, attr string, data []byte, flags uint32) fuse.Status
RemoveXAttr(ctx *Context, path string, attr string) fuse.Status
// File
Create(ctx *Context, path string, flags uint32, mode uint32) (uFh uint32, forceDIO bool, code fuse.Status)
Open(ctx *Context, path string, flags uint32) (uFh uint32, keepCache, forceDIO bool, code fuse.Status)
Read(ctx *Context, path string, uFh uint32, dest []byte, off uint64) (result fuse.ReadResult, code fuse.Status)
Write(ctx *Context, path string, uFh uint32, data []byte, off uint64) (written uint32, code fuse.Status)
Fallocate(ctx *Context, path string, uFh uint32, off uint64, size uint64, mode uint32) fuse.Status
Fsync(ctx *Context, path string, uFh uint32, flags uint32) fuse.Status
Flush(ctx *Context, path string, uFh uint32, lockOwner uint64) fuse.Status
Release(ctx *Context, path string, uFh uint32)
GetLk(ctx *Context, path string, uFh uint32, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) fuse.Status
SetLk(ctx *Context, path string, uFh uint32, owner uint64, lk *fuse.FileLock, flags uint32) fuse.Status
SetLkw(ctx *Context, path string, uFh uint32, owner uint64, lk *fuse.FileLock, flags uint32) fuse.Status
// uFh may be 0.
Chmod(ctx *Context, path string, uFh uint32, mode uint32) fuse.Status
Chown(ctx *Context, path string, uFh uint32, uid uint32, gid uint32) fuse.Status
Truncate(ctx *Context, path string, uFh uint32, size uint64) fuse.Status
Utimens(ctx *Context, path string, uFh uint32, atime *time.Time, mtime *time.Time) fuse.Status
// Directory
Lsdir(ctx *Context, path string) (stream []fuse.DirEntry, code fuse.Status)
StatFs(ctx *Context, path string, out *fuse.StatfsOut) fuse.Status
}
// Options sets options for the entire filesystem
type Options struct {
// If set to nonnil, this defines the overall entry timeout
// for the file system. See fuse.EntryOut for more information.
EntryTimeout *time.Duration
// If set to nonnil, this defines the overall attribute
// timeout for the file system. See fuse.EntryOut for more
// information.
AttrTimeout *time.Duration
// If set to nonnil, this defines the overall entry timeout
// for failed lookups (fuse.ENOENT). See fuse.EntryOut for
// more information.
NegativeTimeout *time.Duration
// NullPermissions if set, leaves null file permissions
// alone. Otherwise, they are set to 755 (dirs) or 644 (other
// files.), which is necessary for doing a chdir into the FUSE
// directories.
NullPermissions bool
// If nonzero, replace default (zero) UID with the given UID
UID uint32
// If nonzero, replace default (zero) GID with the given GID
GID uint32
// Logger is a sink for diagnostic messages. Diagnostic
// messages are printed under conditions where we cannot
// return error, but want to signal something seems off
// anyway. If unset, no messages are printed.
Logger *log.Logger
}