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