Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go-fuse
Commits
f58785aa
Commit
f58785aa
authored
Nov 18, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename OsErrorToErrno to ToStatus.
parent
ba19bafd
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
45 additions
and
45 deletions
+45
-45
fuse/files.go
fuse/files.go
+7
-7
fuse/loopback.go
fuse/loopback.go
+17
-17
fuse/memnode.go
fuse/memnode.go
+3
-3
fuse/misc.go
fuse/misc.go
+4
-4
fuse/misc_test.go
fuse/misc_test.go
+4
-4
fuse/mount_test.go
fuse/mount_test.go
+1
-1
fuse/mountstate.go
fuse/mountstate.go
+2
-2
unionfs/autounion_test.go
unionfs/autounion_test.go
+2
-2
unionfs/memunionfs.go
unionfs/memunionfs.go
+3
-3
unionfs/memunionfs_test.go
unionfs/memunionfs_test.go
+1
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+1
-1
No files found.
fuse/files.go
View file @
f58785aa
...
...
@@ -101,12 +101,12 @@ func (me *LoopbackFile) Read(input *ReadIn, buffers BufferPool) ([]byte, Status)
if
err
==
io
.
EOF
{
err
=
nil
}
return
slice
[
:
n
],
OsErrorToErrno
(
err
)
return
slice
[
:
n
],
ToStatus
(
err
)
}
func
(
me
*
LoopbackFile
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
uint32
,
Status
)
{
n
,
err
:=
me
.
File
.
WriteAt
(
data
,
int64
(
input
.
Offset
))
return
uint32
(
n
),
OsErrorToErrno
(
err
)
return
uint32
(
n
),
ToStatus
(
err
)
}
func
(
me
*
LoopbackFile
)
Release
()
{
...
...
@@ -114,27 +114,27 @@ func (me *LoopbackFile) Release() {
}
func
(
me
*
LoopbackFile
)
Fsync
(
*
FsyncIn
)
(
code
Status
)
{
return
OsErrorToErrno
(
syscall
.
Fsync
(
me
.
File
.
Fd
()))
return
ToStatus
(
syscall
.
Fsync
(
me
.
File
.
Fd
()))
}
func
(
me
*
LoopbackFile
)
Truncate
(
size
uint64
)
Status
{
return
OsErrorToErrno
(
syscall
.
Ftruncate
(
me
.
File
.
Fd
(),
int64
(
size
)))
return
ToStatus
(
syscall
.
Ftruncate
(
me
.
File
.
Fd
(),
int64
(
size
)))
}
// futimens missing from 6g runtime.
func
(
me
*
LoopbackFile
)
Chmod
(
mode
uint32
)
Status
{
return
OsErrorToErrno
(
me
.
File
.
Chmod
(
mode
))
return
ToStatus
(
me
.
File
.
Chmod
(
mode
))
}
func
(
me
*
LoopbackFile
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
{
return
OsErrorToErrno
(
me
.
File
.
Chown
(
int
(
uid
),
int
(
gid
)))
return
ToStatus
(
me
.
File
.
Chown
(
int
(
uid
),
int
(
gid
)))
}
func
(
me
*
LoopbackFile
)
GetAttr
()
(
*
os
.
FileInfo
,
Status
)
{
fi
,
err
:=
me
.
File
.
Stat
()
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
return
nil
,
ToStatus
(
err
)
}
return
fi
,
OK
}
...
...
fuse/loopback.go
View file @
f58785aa
...
...
@@ -44,7 +44,7 @@ func (me *LoopbackFileSystem) GetAttr(name string, context *Context) (fi *os.Fil
fi
,
err
=
os
.
Lstat
(
fullPath
)
}
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
return
nil
,
ToStatus
(
err
)
}
return
fi
,
OK
}
...
...
@@ -54,7 +54,7 @@ func (me *LoopbackFileSystem) OpenDir(name string, context *Context) (stream cha
// directories?
f
,
err
:=
os
.
Open
(
me
.
GetPath
(
name
))
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
return
nil
,
ToStatus
(
err
)
}
want
:=
500
output
:=
make
(
chan
DirEntry
,
want
)
...
...
@@ -85,70 +85,70 @@ func (me *LoopbackFileSystem) OpenDir(name string, context *Context) (stream cha
func
(
me
*
LoopbackFileSystem
)
Open
(
name
string
,
flags
uint32
,
context
*
Context
)
(
fuseFile
File
,
status
Status
)
{
f
,
err
:=
os
.
OpenFile
(
me
.
GetPath
(
name
),
int
(
flags
),
0
)
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
return
nil
,
ToStatus
(
err
)
}
return
&
LoopbackFile
{
File
:
f
},
OK
}
func
(
me
*
LoopbackFileSystem
)
Chmod
(
path
string
,
mode
uint32
,
context
*
Context
)
(
code
Status
)
{
err
:=
os
.
Chmod
(
me
.
GetPath
(
path
),
mode
)
return
OsErrorToErrno
(
err
)
return
ToStatus
(
err
)
}
func
(
me
*
LoopbackFileSystem
)
Chown
(
path
string
,
uid
uint32
,
gid
uint32
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
os
.
Chown
(
me
.
GetPath
(
path
),
int
(
uid
),
int
(
gid
)))
return
ToStatus
(
os
.
Chown
(
me
.
GetPath
(
path
),
int
(
uid
),
int
(
gid
)))
}
func
(
me
*
LoopbackFileSystem
)
Truncate
(
path
string
,
offset
uint64
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
os
.
Truncate
(
me
.
GetPath
(
path
),
int64
(
offset
)))
return
ToStatus
(
os
.
Truncate
(
me
.
GetPath
(
path
),
int64
(
offset
)))
}
func
(
me
*
LoopbackFileSystem
)
Utimens
(
path
string
,
AtimeNs
uint64
,
MtimeNs
uint64
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
os
.
Chtimes
(
me
.
GetPath
(
path
),
int64
(
AtimeNs
),
int64
(
MtimeNs
)))
return
ToStatus
(
os
.
Chtimes
(
me
.
GetPath
(
path
),
int64
(
AtimeNs
),
int64
(
MtimeNs
)))
}
func
(
me
*
LoopbackFileSystem
)
Readlink
(
name
string
,
context
*
Context
)
(
out
string
,
code
Status
)
{
f
,
err
:=
os
.
Readlink
(
me
.
GetPath
(
name
))
return
f
,
OsErrorToErrno
(
err
)
return
f
,
ToStatus
(
err
)
}
func
(
me
*
LoopbackFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
syscall
.
Mknod
(
me
.
GetPath
(
name
),
mode
,
int
(
dev
)))
return
ToStatus
(
syscall
.
Mknod
(
me
.
GetPath
(
name
),
mode
,
int
(
dev
)))
}
func
(
me
*
LoopbackFileSystem
)
Mkdir
(
path
string
,
mode
uint32
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
os
.
Mkdir
(
me
.
GetPath
(
path
),
mode
))
return
ToStatus
(
os
.
Mkdir
(
me
.
GetPath
(
path
),
mode
))
}
// Don't use os.Remove, it removes twice (unlink followed by rmdir).
func
(
me
*
LoopbackFileSystem
)
Unlink
(
name
string
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
syscall
.
Unlink
(
me
.
GetPath
(
name
)))
return
ToStatus
(
syscall
.
Unlink
(
me
.
GetPath
(
name
)))
}
func
(
me
*
LoopbackFileSystem
)
Rmdir
(
name
string
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
syscall
.
Rmdir
(
me
.
GetPath
(
name
)))
return
ToStatus
(
syscall
.
Rmdir
(
me
.
GetPath
(
name
)))
}
func
(
me
*
LoopbackFileSystem
)
Symlink
(
pointedTo
string
,
linkName
string
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
os
.
Symlink
(
pointedTo
,
me
.
GetPath
(
linkName
)))
return
ToStatus
(
os
.
Symlink
(
pointedTo
,
me
.
GetPath
(
linkName
)))
}
func
(
me
*
LoopbackFileSystem
)
Rename
(
oldPath
string
,
newPath
string
,
context
*
Context
)
(
code
Status
)
{
err
:=
os
.
Rename
(
me
.
GetPath
(
oldPath
),
me
.
GetPath
(
newPath
))
return
OsErrorToErrno
(
err
)
return
ToStatus
(
err
)
}
func
(
me
*
LoopbackFileSystem
)
Link
(
orig
string
,
newName
string
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
os
.
Link
(
me
.
GetPath
(
orig
),
me
.
GetPath
(
newName
)))
return
ToStatus
(
os
.
Link
(
me
.
GetPath
(
orig
),
me
.
GetPath
(
newName
)))
}
func
(
me
*
LoopbackFileSystem
)
Access
(
name
string
,
mode
uint32
,
context
*
Context
)
(
code
Status
)
{
return
OsErrorToErrno
(
syscall
.
Access
(
me
.
GetPath
(
name
),
mode
))
return
ToStatus
(
syscall
.
Access
(
me
.
GetPath
(
name
),
mode
))
}
func
(
me
*
LoopbackFileSystem
)
Create
(
path
string
,
flags
uint32
,
mode
uint32
,
context
*
Context
)
(
fuseFile
File
,
code
Status
)
{
f
,
err
:=
os
.
OpenFile
(
me
.
GetPath
(
path
),
int
(
flags
)
|
os
.
O_CREATE
,
mode
)
return
&
LoopbackFile
{
File
:
f
},
OsErrorToErrno
(
err
)
return
&
LoopbackFile
{
File
:
f
},
ToStatus
(
err
)
}
func
(
me
*
LoopbackFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
Context
)
([]
byte
,
Status
)
{
...
...
fuse/memnode.go
View file @
f58785aa
...
...
@@ -129,7 +129,7 @@ func (me *memNode) Create(name string, flags uint32, mode uint32, context *Conte
f
,
err
:=
os
.
Create
(
n
.
filename
())
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
OsErrorToErrno
(
err
)
return
nil
,
nil
,
nil
,
ToStatus
(
err
)
}
me
.
Inode
()
.
AddChild
(
name
,
n
.
Inode
())
return
n
.
newFile
(
f
),
&
n
.
info
,
n
,
OK
...
...
@@ -166,7 +166,7 @@ func (me *memNode) newFile(f *os.File) File {
func
(
me
*
memNode
)
Open
(
flags
uint32
,
context
*
Context
)
(
file
File
,
code
Status
)
{
f
,
err
:=
os
.
OpenFile
(
me
.
filename
(),
int
(
flags
),
0666
)
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
return
nil
,
ToStatus
(
err
)
}
return
me
.
newFile
(
f
),
OK
...
...
@@ -184,7 +184,7 @@ func (me *memNode) Truncate(file File, size uint64, context *Context) (code Stat
me
.
info
.
Size
=
int64
(
size
)
err
:=
os
.
Truncate
(
me
.
filename
(),
int64
(
size
))
me
.
info
.
Ctime_ns
=
time
.
Nanoseconds
()
return
OsErrorToErrno
(
err
)
return
ToStatus
(
err
)
}
func
(
me
*
memNode
)
Utimens
(
file
File
,
atime
uint64
,
mtime
uint64
,
context
*
Context
)
(
code
Status
)
{
...
...
fuse/misc.go
View file @
f58785aa
...
...
@@ -30,8 +30,8 @@ func (code Status) Ok() bool {
return
code
==
OK
}
// Convert
os.E
rror back to Errno based errors.
func
OsErrorToErrno
(
err
error
)
Status
{
// Convert
e
rror back to Errno based errors.
func
ToStatus
(
err
error
)
Status
{
if
err
!=
nil
{
switch
t
:=
err
.
(
type
)
{
case
syscall
.
Errno
:
...
...
@@ -39,9 +39,9 @@ func OsErrorToErrno(err error) Status {
case
*
os
.
SyscallError
:
return
Status
(
t
.
Errno
.
(
syscall
.
Errno
))
case
*
os
.
PathError
:
return
OsErrorToErrno
(
t
.
Err
)
return
ToStatus
(
t
.
Err
)
case
*
os
.
LinkError
:
return
OsErrorToErrno
(
t
.
Err
)
return
ToStatus
(
t
.
Err
)
default
:
log
.
Println
(
"can't convert error type:"
,
err
)
return
ENOSYS
...
...
fuse/misc_test.go
View file @
f58785aa
...
...
@@ -7,20 +7,20 @@ import (
"testing"
)
func
Test
OsErrorToErrno
(
t
*
testing
.
T
)
{
errNo
:=
OsErrorToErrno
(
os
.
EPERM
)
func
Test
ToStatus
(
t
*
testing
.
T
)
{
errNo
:=
ToStatus
(
os
.
EPERM
)
if
errNo
!=
EPERM
{
t
.
Errorf
(
"Wrong conversion %v != %v"
,
errNo
,
syscall
.
EPERM
)
}
e
:=
os
.
NewSyscallError
(
"syscall"
,
syscall
.
EPERM
)
errNo
=
OsErrorToErrno
(
e
)
errNo
=
ToStatus
(
e
)
if
errNo
!=
EPERM
{
t
.
Errorf
(
"Wrong conversion %v != %v"
,
errNo
,
syscall
.
EPERM
)
}
e
=
os
.
Remove
(
"this-file-surely-does-not-exist"
)
errNo
=
OsErrorToErrno
(
e
)
errNo
=
ToStatus
(
e
)
if
errNo
!=
ENOENT
{
t
.
Errorf
(
"Wrong conversion %v != %v"
,
errNo
,
syscall
.
ENOENT
)
}
...
...
fuse/mount_test.go
View file @
f58785aa
...
...
@@ -40,7 +40,7 @@ func TestMountRename(t *testing.T) {
t
.
Fatal
(
"mount should succeed"
)
}
err
:=
os
.
Rename
(
ts
.
mnt
+
"/mnt"
,
ts
.
mnt
+
"/foobar"
)
if
OsErrorToErrno
(
err
)
!=
EBUSY
{
if
ToStatus
(
err
)
!=
EBUSY
{
t
.
Fatal
(
"rename mount point should fail with EBUSY:"
,
err
)
}
ts
.
pathFs
.
Unmount
(
"mnt"
)
...
...
fuse/mountstate.go
View file @
f58785aa
...
...
@@ -132,7 +132,7 @@ func (me *MountState) readRequest(req *request) Status {
req
.
startNs
=
time
.
Nanoseconds
()
}
req
.
inputBuf
=
req
.
inputBuf
[
0
:
n
]
return
OsErrorToErrno
(
err
)
return
ToStatus
(
err
)
}
func
(
me
*
MountState
)
recordStats
(
req
*
request
)
{
...
...
@@ -251,7 +251,7 @@ func (me *MountState) write(req *request) Status {
[][]
byte
{
req
.
outHeaderBytes
,
req
.
flatData
})
}
return
OsErrorToErrno
(
err
)
return
ToStatus
(
err
)
}
func
(
me
*
MountState
)
writeInodeNotify
(
entry
*
NotifyInvalInodeOut
)
Status
{
...
...
unionfs/autounion_test.go
View file @
f58785aa
...
...
@@ -181,13 +181,13 @@ func TestCreationChecks(t *testing.T) {
CheckSuccess
(
err
)
err
=
os
.
Symlink
(
wd
+
"/store/foo"
,
wd
+
"/mnt/config/foo"
)
code
:=
fuse
.
OsErrorToErrno
(
err
)
code
:=
fuse
.
ToStatus
(
err
)
if
code
!=
fuse
.
EBUSY
{
t
.
Error
(
"Should return EBUSY"
,
err
)
}
err
=
os
.
Symlink
(
wd
+
"/store/ws2"
,
wd
+
"/mnt/config/config"
)
code
=
fuse
.
OsErrorToErrno
(
err
)
code
=
fuse
.
ToStatus
(
err
)
if
code
!=
fuse
.
EINVAL
{
t
.
Error
(
"Should return EINVAL"
,
err
)
}
...
...
unionfs/memunionfs.go
View file @
f58785aa
...
...
@@ -410,7 +410,7 @@ func (me *memNode) Create(name string, flags uint32, mode uint32, context *fuse.
f
,
err
:=
os
.
Create
(
n
.
backing
)
if
err
!=
nil
{
log
.
Printf
(
"Backing store error %q: %v"
,
n
.
backing
,
err
)
return
nil
,
nil
,
nil
,
fuse
.
OsErrorToErrno
(
err
)
return
nil
,
nil
,
nil
,
fuse
.
ToStatus
(
err
)
}
me
.
Inode
()
.
AddChild
(
name
,
n
.
Inode
())
me
.
touch
()
...
...
@@ -494,7 +494,7 @@ func (me *memNode) Open(flags uint32, context *fuse.Context) (file fuse.File, co
if
me
.
backing
!=
""
{
f
,
err
:=
os
.
OpenFile
(
me
.
backing
,
int
(
flags
),
0666
)
if
err
!=
nil
{
return
nil
,
fuse
.
OsErrorToErrno
(
err
)
return
nil
,
fuse
.
ToStatus
(
err
)
}
wr
:=
flags
&
fuse
.
O_ANYWRITE
!=
0
if
wr
{
...
...
@@ -542,7 +542,7 @@ func (me *memNode) Truncate(file fuse.File, size uint64, context *fuse.Context)
me
.
info
.
Size
=
int64
(
size
)
err
:=
os
.
Truncate
(
me
.
backing
,
int64
(
size
))
me
.
touch
()
return
fuse
.
OsErrorToErrno
(
err
)
return
fuse
.
ToStatus
(
err
)
}
func
(
me
*
memNode
)
Utimens
(
file
fuse
.
File
,
atime
uint64
,
mtime
uint64
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
...
...
unionfs/memunionfs_test.go
View file @
f58785aa
...
...
@@ -145,7 +145,7 @@ func TestMemUnionFsChown(t *testing.T) {
writeToFile
(
ro_fn
,
"a"
)
err
:=
os
.
Chown
(
m_fn
,
0
,
0
)
code
:=
fuse
.
OsErrorToErrno
(
err
)
code
:=
fuse
.
ToStatus
(
err
)
if
code
!=
fuse
.
EPERM
{
t
.
Error
(
"Unexpected error code"
,
code
,
err
)
}
...
...
unionfs/unionfs_test.go
View file @
f58785aa
...
...
@@ -223,7 +223,7 @@ func TestUnionFsChown(t *testing.T) {
writeToFile
(
ro_fn
,
"a"
)
err
:=
os
.
Chown
(
m_fn
,
0
,
0
)
code
:=
fuse
.
OsErrorToErrno
(
err
)
code
:=
fuse
.
ToStatus
(
err
)
if
code
!=
fuse
.
EPERM
{
t
.
Error
(
"Unexpected error code"
,
code
,
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment