Commit 75f62dbe authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use Status.Ok()

......@@ -218,7 +218,7 @@ func (me *MountState) handleRequest(req *request) {
return
}
if req.status == OK {
if req.status.Ok() {
req.handler.Func(me, req)
}
......
......@@ -16,7 +16,7 @@ import (
func (code Status) String() string {
if code == OK {
if code.Ok() {
return "OK"
}
return fmt.Sprintf("%d=%v", int(code), os.Errno(code))
......
......@@ -110,7 +110,7 @@ func doOpen(state *MountState, req *request) {
func doCreate(state *MountState, req *request) {
flags, handle, entry, status := state.fileSystem.Create(req.inHeader, (*CreateIn)(req.inData), req.filenames[0])
req.status = status
if status == OK {
if status.Ok() {
req.outData = unsafe.Pointer(&CreateOut{
EntryOut: *entry,
OpenOut: OpenOut{
......@@ -134,7 +134,7 @@ func doReadDir(state *MountState, req *request) {
func doOpenDir(state *MountState, req *request) {
flags, handle, status := state.fileSystem.OpenDir(req.inHeader, (*OpenIn)(req.inData))
req.status = status
if status == OK {
if status.Ok() {
req.outData = unsafe.Pointer(&OpenOut{
Fh: handle,
OpenFlags: flags,
......
......@@ -486,18 +486,18 @@ func (me *FileSystemConnector) Unmount(path string) Status {
// don't use defer: we don't want to call out to
// mount.fs.Unmount() with lock held.
if unmountError == OK && (node.totalOpenCount() > 0 || node.totalMountCount() > 1) {
if unmountError.Ok() && (node.totalOpenCount() > 0 || node.totalMountCount() > 1) {
unmountError = EBUSY
}
if unmountError == OK {
if unmountError.Ok() {
// We settle for eventual consistency.
mount.unmountPending = true
}
me.fileLock.Unlock()
me.treeLock.RUnlock()
if unmountError == OK {
if unmountError.Ok() {
if me.Debug {
log.Println("Unmount: ", mount)
}
......
......@@ -172,7 +172,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
}
fileResult := ENOSYS
if err == OK && input.Valid&FATTR_MODE != 0 {
if err.Ok() && input.Valid&FATTR_MODE != 0 {
permissions := uint32(07777) & input.Mode
if f != nil {
fileResult = f.Chmod(permissions)
......@@ -184,7 +184,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult = ENOSYS
}
}
if err == OK && (input.Valid&(FATTR_UID|FATTR_GID) != 0) {
if err.Ok() && (input.Valid&(FATTR_UID|FATTR_GID) != 0) {
if f != nil {
fileResult = f.Chown(uint32(input.Uid), uint32(input.Gid))
}
......@@ -197,7 +197,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult = ENOSYS
}
}
if err == OK && input.Valid&FATTR_SIZE != 0 {
if err.Ok() && input.Valid&FATTR_SIZE != 0 {
if f != nil {
fileResult = f.Truncate(input.Size)
}
......@@ -208,7 +208,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult = ENOSYS
}
}
if err == OK && (input.Valid&(FATTR_ATIME|FATTR_MTIME|FATTR_ATIME_NOW|FATTR_MTIME_NOW) != 0) {
if err.Ok() && (input.Valid&(FATTR_ATIME|FATTR_MTIME|FATTR_ATIME_NOW|FATTR_MTIME_NOW) != 0) {
atime := uint64(input.Atime*1e9) + uint64(input.Atimensec)
if input.Valid&FATTR_ATIME_NOW != 0 {
atime = uint64(time.Nanoseconds())
......@@ -264,7 +264,7 @@ func (me *FileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name stri
return nil, ENOENT
}
code = mount.fs.Mkdir(filepath.Join(fullPath, name), input.Mode)
if code == OK {
if code.Ok() {
out, code = me.internalLookup(parent, name, 1)
}
return out, code
......@@ -276,7 +276,7 @@ func (me *FileSystemConnector) Unlink(header *InHeader, name string) (code Statu
return ENOENT
}
code = mount.fs.Unlink(filepath.Join(fullPath, name))
if code == OK {
if code.Ok() {
// Like fuse.c, we update our internal tables.
me.unlinkUpdate(parent, name)
}
......@@ -289,7 +289,7 @@ func (me *FileSystemConnector) Rmdir(header *InHeader, name string) (code Status
return ENOENT
}
code = mount.fs.Rmdir(filepath.Join(fullPath, name))
if code == OK {
if code.Ok() {
me.unlinkUpdate(parent, name)
}
return code
......@@ -322,7 +322,7 @@ func (me *FileSystemConnector) Rename(header *InHeader, input *RenameIn, oldName
oldPath = filepath.Join(oldPath, oldName)
newPath = filepath.Join(newPath, newName)
code = mount.fs.Rename(oldPath, newPath)
if code == OK {
if code.Ok() {
me.renameUpdate(oldParent, oldName, newParent, newName)
}
return code
......
......@@ -86,7 +86,7 @@ func (me *CachingFileSystem) Readlink(name string) (string, fuse.Status) {
func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.Status) {
r := me.dirs.Get(name).(*dirResponse)
if r.Status == fuse.OK {
if r.Status.Ok() {
stream = make(chan fuse.DirEntry, len(r.entries))
for _, d := range r.entries {
stream <- d
......
......@@ -157,7 +157,7 @@ func (me *UnionFs) getBranchAttrNoCache(name string) branchResult {
}
a, s := fs.GetAttr(name)
if s == fuse.OK {
if s.Ok() {
if a.Mode&fuse.S_IFDIR != 0 {
// Make all directories appear writable
a.Mode |= 0200
......@@ -282,7 +282,7 @@ func (me *UnionFs) Rmdir(path string) (code fuse.Status) {
}
if r.branch > 0 {
stream, code := me.fileSystems[r.branch].OpenDir(path)
if code == fuse.OK {
if code.Ok() {
_, ok := <-stream
if ok {
// TODO - should consume stream.
......@@ -312,10 +312,10 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
}
code = me.promoteDirsTo(path)
if code == fuse.OK {
if code.Ok() {
code = me.fileSystems[0].Mkdir(path, mode)
}
if code == fuse.OK {
if code.Ok() {
me.removeDeletion(path)
attr := &fuse.Attr{
Mode: fuse.S_IFDIR | mode,
......@@ -327,7 +327,7 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
func (me *UnionFs) Symlink(pointedTo string, linkName string) (code fuse.Status) {
code = me.fileSystems[0].Symlink(pointedTo, linkName)
if code == fuse.OK {
if code.Ok() {
me.removeDeletion(linkName)
me.branchCache.Set(linkName, branchResult{nil, fuse.OK, 0})
}
......@@ -351,14 +351,14 @@ func (me *UnionFs) Utimens(name string, atime uint64, ctime uint64) (code fuse.S
r := me.getBranch(name)
code = r.code
if code == fuse.OK && r.branch > 0 {
if code.Ok() && r.branch > 0 {
code = me.Promote(name, r)
r.branch = 0
}
if code == fuse.OK {
if code.Ok() {
code = me.fileSystems[0].Utimens(name, atime, ctime)
}
if code == fuse.OK {
if code.Ok() {
r.attr.Atime = uint64(atime / 1e9)
r.attr.Atimensec = uint32(atime % 1e9)
r.attr.Ctime = uint64(ctime / 1e9)
......@@ -462,7 +462,7 @@ func (me *UnionFs) Readlink(name string) (out string, code fuse.Status) {
func IsDir(fs fuse.FileSystem, name string) bool {
a, code := fs.GetAttr(name)
return code == fuse.OK && a.Mode&fuse.S_IFDIR != 0
return code.Ok() && a.Mode&fuse.S_IFDIR != 0
}
func stripSlash(fn string) string {
......@@ -518,7 +518,7 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse
return nil, code
}
fuseFile, code = writable.Create(name, flags, mode)
if code == fuse.OK {
if code.Ok() {
me.removeDeletion(name)
a := fuse.Attr{
......@@ -591,7 +591,7 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
go func(j int, pfs fuse.FileSystem) {
ch, s := pfs.OpenDir(directory)
statuses[j] = s
for s == fuse.OK {
for s.Ok() {
v := <-ch
if v.Name == "" {
break
......@@ -653,20 +653,20 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
srcResult := me.getBranch(src)
code = srcResult.code
if code == fuse.OK {
if code.Ok() {
code = srcResult.code
}
if code == fuse.OK && srcResult.branch > 0 {
if code.Ok() && srcResult.branch > 0 {
code = me.Promote(src, srcResult)
}
if code == fuse.OK {
if code.Ok() {
code = me.promoteDirsTo(dst)
}
if code == fuse.OK {
if code.Ok() {
code = me.fileSystems[0].Rename(src, dst)
}
if code == fuse.OK {
if code.Ok() {
me.removeDeletion(dst)
srcResult.branch = 0
me.branchCache.Set(dst, srcResult)
......
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