File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 13
13
ErrCrossedBoundary = errors .New ("chroot boundary crossed" )
14
14
)
15
15
16
- // Capability holds the supported features of a filesystem.
16
+ // Capability holds the supported features of a billy filesystem. This does
17
+ // not mean that the capability has to be supported by the underlying storage.
18
+ // For example, a billy filesystem may support CapWrite but the storage be
19
+ // mounted in read only mode.
17
20
type Capability uint64
18
21
19
22
const (
@@ -30,6 +33,12 @@ const (
30
33
// CapLock is the ability to lock a file.
31
34
CapLock
32
35
36
+ // CapDefault lists all capable features supported by filesystems without
37
+ // Capability interface. This list should not be changed until a major
38
+ // version is released.
39
+ CapDefault Capability = CapWrite | CapRead | CapReadAndWrite |
40
+ CapSeek | CapTruncate | CapLock
41
+
33
42
// CapAll lists all capable features.
34
43
CapAll Capability = CapWrite | CapRead | CapReadAndWrite |
35
44
CapSeek | CapTruncate | CapLock
@@ -177,7 +186,7 @@ type Capable interface {
177
186
func Capabilities (fs Basic ) Capability {
178
187
capable , ok := fs .(Capable )
179
188
if ! ok {
180
- return CapAll
189
+ return CapDefault
181
190
}
182
191
183
192
return capable .Capabilities ()
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ func (h *Mount) Underlying() billy.Basic {
169
169
170
170
// Capabilities implements the Capable interface.
171
171
func (fs * Mount ) Capabilities () billy.Capability {
172
- return billy .Capabilities (fs .underlying )
172
+ return billy .Capabilities (fs .underlying ) & billy . Capabilities ( fs . source )
173
173
}
174
174
175
175
func (fs * Mount ) getBasicAndPath (path string ) (billy.Basic , string ) {
Original file line number Diff line number Diff line change @@ -27,5 +27,5 @@ func (s *MemorySuite) TestCapabilities(c *C) {
27
27
c .Assert (ok , Equals , true )
28
28
29
29
caps := billy .Capabilities (s .FS )
30
- c .Assert (caps , Equals , billy .CapAll &^billy .CapLock )
30
+ c .Assert (caps , Equals , billy .CapDefault &^billy .CapLock )
31
31
}
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ func (fs *OS) Readlink(link string) (string, error) {
129
129
130
130
// Capabilities implements the Capable interface.
131
131
func (fs * OS ) Capabilities () billy.Capability {
132
- return billy .CapAll
132
+ return billy .CapDefault
133
133
}
134
134
135
135
// file is a wrapper for an os.File which adds support for file locking.
You can’t perform that action at this time.
0 commit comments