Commit f8379610 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: store open flags in openFiles map

parent 6267f14d
...@@ -23,7 +23,7 @@ type loopbackRoot struct { ...@@ -23,7 +23,7 @@ type loopbackRoot struct {
func (n *loopbackRoot) newLoopbackNode() *loopbackNode { func (n *loopbackRoot) newLoopbackNode() *loopbackNode {
return &loopbackNode{ return &loopbackNode{
rootNode: n, rootNode: n,
openFiles: map[*loopbackFile]struct{}{}, openFiles: map[*loopbackFile]uint32{},
} }
} }
...@@ -43,8 +43,10 @@ type loopbackNode struct { ...@@ -43,8 +43,10 @@ type loopbackNode struct {
rootNode *loopbackRoot rootNode *loopbackRoot
mu sync.Mutex mu sync.Mutex
openFiles map[*loopbackFile]struct{}
// file => openflags
openFiles map[*loopbackFile]uint32
} }
func (n *loopbackNode) Release(ctx context.Context, f FileHandle) { func (n *loopbackNode) Release(ctx context.Context, f FileHandle) {
...@@ -177,7 +179,7 @@ func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mo ...@@ -177,7 +179,7 @@ func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mo
lf := newLoopbackFile(f) lf := newLoopbackFile(f)
n.mu.Lock() n.mu.Lock()
defer n.mu.Unlock() defer n.mu.Unlock()
n.openFiles[lf] = struct{}{} n.openFiles[lf] = flags | syscall.O_CREAT
return ch, lf, 0, fuse.OK return ch, lf, 0, fuse.OK
} }
...@@ -190,7 +192,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f ...@@ -190,7 +192,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f
n.mu.Lock() n.mu.Lock()
defer n.mu.Unlock() defer n.mu.Unlock()
lf := newLoopbackFile(f) lf := newLoopbackFile(f)
n.openFiles[lf] = struct{}{} n.openFiles[lf] = flags
return lf, 0, fuse.OK return lf, 0, fuse.OK
} }
...@@ -232,6 +234,6 @@ func NewLoopback(root string) Operations { ...@@ -232,6 +234,6 @@ func NewLoopback(root string) Operations {
root: root, root: root,
} }
n.rootNode = n n.rootNode = n
n.openFiles = map[*loopbackFile]struct{}{} n.openFiles = map[*loopbackFile]uint32{}
return n return n
} }
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