Commit 075525b6 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fs: rename Options.DefaultPermissions to NullPermissions

This makes the default setting more useful.

Change-Id: Iab40ad0ab0e2c9b75b786a883f6ad989178ee5b5
parent da70f4d4
......@@ -32,9 +32,8 @@ func main() {
root := &zipfs.MultiZipFs{}
sec := time.Second
opts := fs.Options{
EntryTimeout: &sec,
AttrTimeout: &sec,
DefaultPermissions: true,
EntryTimeout: &sec,
AttrTimeout: &sec,
}
opts.Debug = *debug
server, err := fs.Mount(flag.Arg(0), root, &opts)
......
......@@ -57,9 +57,8 @@ func main() {
}
opts := &fs.Options{
AttrTimeout: ttl,
EntryTimeout: ttl,
DefaultPermissions: true,
AttrTimeout: ttl,
EntryTimeout: ttl,
}
opts.Debug = *debug
server, err := fs.Mount(flag.Arg(0), root, opts)
......
......@@ -217,9 +217,12 @@ type NodeAccesser interface {
Access(ctx context.Context, mask uint32) syscall.Errno
}
// GetAttr reads attributes for an Inode. The library will
// ensure that Mode and Ino are set correctly. For regular
// files, Size should be set so it can be read correctly.
// GetAttr reads attributes for an Inode. The library will ensure that
// Mode and Ino are set correctly. For files that are not opened with
// FOPEN_DIRECTIO, Size should be set so it can be read correctly. If
// returning zeroed permissions, the default behavior is to change the
// mode of 0755 (directory) or 0644 (files). This can be switched off
// with the Options.NullPermissions setting.
type NodeGetattrer interface {
Getattr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno
}
......@@ -584,9 +587,11 @@ type Options struct {
// functionality of the root node.
OnAdd func(ctx context.Context)
// DefaultPermissions sets null file permissions to 755 (dirs)
// or 644 (other files.)
DefaultPermissions bool
// 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
......
......@@ -147,7 +147,7 @@ func (b *rawBridge) setEntryOutTimeout(out *fuse.EntryOut) {
}
func (b *rawBridge) setAttr(out *fuse.Attr) {
if b.options.DefaultPermissions && out.Mode&07777 == 0 {
if !b.options.NullPermissions && out.Mode&07777 == 0 {
out.Mode |= 0644
if out.Mode&syscall.S_IFDIR != 0 {
out.Mode |= 0111
......
......@@ -117,11 +117,6 @@ func Example_dynamic() {
// Set to true to see how the file system works.
Debug: true,
},
// This adds read permissions to the files and
// directories, which is necessary for doing a chdir
// into the mount.
DefaultPermissions: true,
})
if err != nil {
log.Panic(err)
......
......@@ -80,11 +80,6 @@ func Example() {
root := &inMemoryFS{}
server, err := fs.Mount(mntDir, root, &fs.Options{
MountOptions: fuse.MountOptions{Debug: true},
// This adds read permissions to the files and
// directories, which is necessary for doing a chdir
// into the mount.
DefaultPermissions: true,
})
if err != nil {
log.Panic(err)
......
......@@ -29,7 +29,6 @@ func TestDefaultPermissions(t *testing.T) {
root := &Inode{}
mntDir, _, clean := testMount(t, root, &Options{
DefaultPermissions: true,
OnAdd: func(ctx context.Context) {
dir := root.NewPersistentInode(ctx, &Inode{}, StableAttr{Mode: syscall.S_IFDIR})
file := root.NewPersistentInode(ctx, &Inode{}, StableAttr{Mode: syscall.S_IFREG})
......
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