Skip to content

Commit

Permalink
Make start/end edit resilient against inverted request ordering.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwen committed Feb 13, 2013
1 parent b900406 commit 6070a13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 9 additions & 2 deletions fs/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func (f *androidFile) String() string {
}

func (f *androidFile) Write(dest []byte, off int64) (written uint32, status fuse.Status) {
if !f.node.startEdit() {
return 0, fuse.EIO
}

b := bytes.NewBuffer(dest)
err := f.node.fs.dev.AndroidSendPartialObject(f.node.Handle(), off, uint32(len(dest)), b)
if err != nil {
Expand All @@ -46,6 +50,9 @@ func (f *androidFile) Write(dest []byte, off int64) (written uint32, status fuse
return written, fuse.OK
}

func (f *androidFile) Release() {
f.node.endEdit()
func (f *androidFile) Flush() fuse.Status {
if !f.node.endEdit() {
return fuse.EIO
}
return fuse.OK
}
7 changes: 0 additions & 7 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,6 @@ func (n *fileNode) endEdit() bool {
}

func (n *fileNode) Open(flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
write := (flags&fuse.O_ANYWRITE != 0)
if write {
if !n.startEdit() {
return nil, fuse.EIO
}
}

return &androidFile{node: n}, fuse.OK
}

Expand Down

0 comments on commit 6070a13

Please sign in to comment.