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
Levin Zimmermann
go-fuse
Commits
3fe3cb8f
Commit
3fe3cb8f
authored
May 01, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Centralize filename error handling.
parent
400e77ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
48 deletions
+42
-48
fuse/opcode.go
fuse/opcode.go
+20
-31
fuse/request.go
fuse/request.go
+22
-17
No files found.
fuse/opcode.go
View file @
3fe3cb8f
...
...
@@ -108,7 +108,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
.
filename
()
)
flags
,
handle
,
entry
,
status
:=
state
.
fileSystem
.
Create
(
req
.
inHeader
,
(
*
CreateIn
)(
req
.
inData
),
req
.
filename
s
[
0
]
)
req
.
status
=
status
if
status
==
OK
{
req
.
outData
=
unsafe
.
Pointer
(
&
CreateOut
{
...
...
@@ -162,7 +162,7 @@ func doGetXAttr(state *MountState, req *request) {
input
:=
(
*
GetXAttrIn
)(
req
.
inData
)
var
data
[]
byte
if
req
.
inHeader
.
opcode
==
_OP_GETXATTR
{
data
,
req
.
status
=
state
.
fileSystem
.
GetXAttr
(
req
.
inHeader
,
req
.
filename
()
)
data
,
req
.
status
=
state
.
fileSystem
.
GetXAttr
(
req
.
inHeader
,
req
.
filename
s
[
0
]
)
}
else
{
data
,
req
.
status
=
state
.
fileSystem
.
ListXAttr
(
req
.
inHeader
)
}
...
...
@@ -206,33 +206,33 @@ func doDestroy(state *MountState, req *request) {
}
func
doLookup
(
state
*
MountState
,
req
*
request
)
{
lookupOut
,
s
:=
state
.
fileSystem
.
Lookup
(
req
.
inHeader
,
req
.
filename
()
)
lookupOut
,
s
:=
state
.
fileSystem
.
Lookup
(
req
.
inHeader
,
req
.
filename
s
[
0
]
)
req
.
status
=
s
req
.
outData
=
unsafe
.
Pointer
(
lookupOut
)
}
func
doMknod
(
state
*
MountState
,
req
*
request
)
{
entryOut
,
s
:=
state
.
fileSystem
.
Mknod
(
req
.
inHeader
,
(
*
MknodIn
)(
req
.
inData
),
req
.
filename
()
)
entryOut
,
s
:=
state
.
fileSystem
.
Mknod
(
req
.
inHeader
,
(
*
MknodIn
)(
req
.
inData
),
req
.
filename
s
[
0
]
)
req
.
status
=
s
req
.
outData
=
unsafe
.
Pointer
(
entryOut
)
}
func
doMkdir
(
state
*
MountState
,
req
*
request
)
{
entryOut
,
s
:=
state
.
fileSystem
.
Mkdir
(
req
.
inHeader
,
(
*
MkdirIn
)(
req
.
inData
),
req
.
filename
()
)
entryOut
,
s
:=
state
.
fileSystem
.
Mkdir
(
req
.
inHeader
,
(
*
MkdirIn
)(
req
.
inData
),
req
.
filename
s
[
0
]
)
req
.
status
=
s
req
.
outData
=
unsafe
.
Pointer
(
entryOut
)
}
func
doUnlink
(
state
*
MountState
,
req
*
request
)
{
req
.
status
=
state
.
fileSystem
.
Unlink
(
req
.
inHeader
,
req
.
filename
()
)
req
.
status
=
state
.
fileSystem
.
Unlink
(
req
.
inHeader
,
req
.
filename
s
[
0
]
)
}
func
doRmdir
(
state
*
MountState
,
req
*
request
)
{
req
.
status
=
state
.
fileSystem
.
Rmdir
(
req
.
inHeader
,
req
.
filename
()
)
req
.
status
=
state
.
fileSystem
.
Rmdir
(
req
.
inHeader
,
req
.
filename
s
[
0
]
)
}
func
doLink
(
state
*
MountState
,
req
*
request
)
{
entryOut
,
s
:=
state
.
fileSystem
.
Link
(
req
.
inHeader
,
(
*
LinkIn
)(
req
.
inData
),
req
.
filename
()
)
entryOut
,
s
:=
state
.
fileSystem
.
Link
(
req
.
inHeader
,
(
*
LinkIn
)(
req
.
inData
),
req
.
filename
s
[
0
]
)
req
.
status
=
s
req
.
outData
=
unsafe
.
Pointer
(
entryOut
)
}
...
...
@@ -260,7 +260,7 @@ func doSetXAttr(state *MountState, req *request) {
}
func
doRemoveXAttr
(
state
*
MountState
,
req
*
request
)
{
req
.
status
=
state
.
fileSystem
.
RemoveXAttr
(
req
.
inHeader
,
req
.
filename
()
)
req
.
status
=
state
.
fileSystem
.
RemoveXAttr
(
req
.
inHeader
,
req
.
filename
s
[
0
]
)
}
func
doAccess
(
state
*
MountState
,
req
*
request
)
{
...
...
@@ -268,25 +268,13 @@ func doAccess(state *MountState, req *request) {
}
func
doSymlink
(
state
*
MountState
,
req
*
request
)
{
filenames
:=
req
.
filenames
(
3
)
if
len
(
filenames
)
>=
2
{
entryOut
,
s
:=
state
.
fileSystem
.
Symlink
(
req
.
inHeader
,
filenames
[
1
],
filenames
[
0
])
req
.
status
=
s
req
.
outData
=
unsafe
.
Pointer
(
entryOut
)
}
else
{
log
.
Println
(
"Symlink: missing arguments"
,
filenames
)
req
.
status
=
EIO
}
entryOut
,
s
:=
state
.
fileSystem
.
Symlink
(
req
.
inHeader
,
req
.
filenames
[
1
],
req
.
filenames
[
0
])
req
.
status
=
s
req
.
outData
=
unsafe
.
Pointer
(
entryOut
)
}
func
doRename
(
state
*
MountState
,
req
*
request
)
{
filenames
:=
req
.
filenames
(
3
)
if
len
(
filenames
)
>=
2
{
req
.
status
=
state
.
fileSystem
.
Rename
(
req
.
inHeader
,
(
*
RenameIn
)(
req
.
inData
),
filenames
[
0
],
filenames
[
1
])
}
else
{
log
.
Println
(
"Rename: missing arguments"
,
filenames
)
req
.
status
=
EIO
}
req
.
status
=
state
.
fileSystem
.
Rename
(
req
.
inHeader
,
(
*
RenameIn
)(
req
.
inData
),
req
.
filenames
[
0
],
req
.
filenames
[
1
])
}
////////////////////////////////////////////////////////////////
...
...
@@ -479,16 +467,17 @@ func init() {
operationHandlers
[
op
]
.
DecodeIn
=
f
}
for
op
,
count
:=
range
map
[
opcode
]
int
{
_OP_CREATE
:
1
,
_OP_GETXATTR
:
1
,
_OP_LINK
:
1
,
_OP_LOOKUP
:
1
,
_OP_MKDIR
:
1
,
_OP_MKNOD
:
1
,
_OP_REMOVEXATTR
:
1
,
_OP_RENAME
:
2
,
_OP_RMDIR
:
1
,
_OP_SYMLINK
:
2
,
_OP_GETXATTR
:
1
,
_OP_CREATE
:
1
,
_OP_MKNOD
:
1
,
_OP_MKDIR
:
1
,
_OP_UNLINK
:
1
,
_OP_RMDIR
:
1
,
_OP_REMOVEXATTR
:
1
,
}
{
operationHandlers
[
op
]
.
FileNames
=
count
}
...
...
fuse/request.go
View file @
3fe3cb8f
...
...
@@ -14,12 +14,13 @@ type request struct {
inHeader
*
InHeader
// generic header
inData
unsafe
.
Pointer
// per op data
arg
[]
byte
// flat data.
filenames
[]
string
// filename arguments
// Unstructured data, a pointer to the relevant XxxxOut struct.
outData
unsafe
.
Pointer
status
Status
flatData
[]
byte
// Header + structured data for what we send back to the kernel.
// May be followed by flatData.
outHeaderBytes
[]
byte
...
...
@@ -32,19 +33,6 @@ type request struct {
handler
*
operationHandler
}
func
(
me
*
request
)
filename
()
string
{
return
string
(
me
.
arg
[
:
len
(
me
.
arg
)
-
1
])
}
func
(
me
*
request
)
filenames
(
count
int
)
[]
string
{
names
:=
bytes
.
Split
(
me
.
arg
[
:
len
(
me
.
arg
)
-
1
],
[]
byte
{
0
},
count
)
nameStrings
:=
make
([]
string
,
len
(
names
))
for
i
,
n
:=
range
names
{
nameStrings
[
i
]
=
string
(
n
)
}
return
nameStrings
}
func
(
me
*
request
)
InputDebug
()
string
{
val
:=
" "
if
me
.
handler
.
DecodeIn
!=
nil
{
...
...
@@ -52,8 +40,8 @@ func (me *request) InputDebug() string {
}
names
:=
""
if
me
.
handler
.
FileNames
>
0
{
names
=
fmt
.
Sprintf
(
"names: %v"
,
me
.
filenames
(
me
.
handler
.
FileNames
)
)
if
me
.
filenames
!=
nil
{
names
=
fmt
.
Sprintf
(
"names: %v"
,
me
.
filenames
)
}
return
fmt
.
Sprintf
(
"Dispatch: %v, NodeId: %v.%v%v"
,
...
...
@@ -116,6 +104,23 @@ func (req *request) parse() {
req
.
inData
=
unsafe
.
Pointer
(
&
req
.
arg
[
0
])
req
.
arg
=
req
.
arg
[
req
.
handler
.
InputSize
:
]
}
count
:=
req
.
handler
.
FileNames
if
count
>
0
{
if
count
==
1
{
req
.
filenames
=
[]
string
{
string
(
req
.
arg
[
:
len
(
req
.
arg
)
-
1
])}
}
else
{
names
:=
bytes
.
Split
(
req
.
arg
[
:
len
(
req
.
arg
)
-
1
],
[]
byte
{
0
},
count
)
req
.
filenames
=
make
([]
string
,
len
(
names
))
for
i
,
n
:=
range
names
{
req
.
filenames
[
i
]
=
string
(
n
)
}
if
len
(
names
)
!=
count
{
log
.
Println
(
"filename argument mismatch"
,
names
,
count
)
req
.
status
=
EIO
}
}
}
}
func
(
req
*
request
)
serialize
()
{
...
...
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