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
6a7e4067
Commit
6a7e4067
authored
Dec 27, 2010
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt on dummyfuse* and fuse.go.
parent
16a98c3e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
35 deletions
+30
-35
fuse/dummyfuse.go
fuse/dummyfuse.go
+1
-1
fuse/dummyfuse_test.go
fuse/dummyfuse_test.go
+0
-1
fuse/fuse.go
fuse/fuse.go
+28
-32
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+1
-1
No files found.
fuse/dummyfuse.go
View file @
6a7e4067
...
@@ -129,7 +129,7 @@ func (self *DummyFuseFile) FsyncDir(input *FsyncIn) (code Status) {
...
@@ -129,7 +129,7 @@ func (self *DummyFuseFile) FsyncDir(input *FsyncIn) (code Status) {
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// DummyPathFuse
// DummyPathFuse
type
DummyPathFuse
struct
{}
type
DummyPathFuse
struct
{}
func
(
self
*
DummyPathFuse
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
func
(
self
*
DummyPathFuse
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
return
nil
,
ENOSYS
return
nil
,
ENOSYS
...
...
fuse/dummyfuse_test.go
View file @
6a7e4067
...
@@ -14,4 +14,3 @@ func TestDummy(t *testing.T) {
...
@@ -14,4 +14,3 @@ func TestDummy(t *testing.T) {
NewPathFileSystemConnector
(
pathFs
)
NewPathFileSystemConnector
(
pathFs
)
}
}
fuse/fuse.go
View file @
6a7e4067
...
@@ -15,9 +15,7 @@ const (
...
@@ -15,9 +15,7 @@ const (
bufSize
=
66000
bufSize
=
66000
)
)
type
Empty
interface
{
type
Empty
interface
{}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// State related to this mount point.
// State related to this mount point.
...
@@ -27,23 +25,23 @@ type MountState struct {
...
@@ -27,23 +25,23 @@ type MountState struct {
// otherwise our files may be GCd. Here, the index is the Fh
// otherwise our files may be GCd. Here, the index is the Fh
// field
// field
openedFiles
map
[
uint64
]
RawFuseFile
openedFiles
map
[
uint64
]
RawFuseFile
openedFilesMutex
sync
.
RWMutex
openedFilesMutex
sync
.
RWMutex
nextFreeFile
uint64
nextFreeFile
uint64
openedDirs
map
[
uint64
]
RawFuseDir
openedDirs
map
[
uint64
]
RawFuseDir
openedDirsMutex
sync
.
RWMutex
openedDirsMutex
sync
.
RWMutex
nextFreeDir
uint64
nextFreeDir
uint64
// Empty if unmounted.
// Empty if unmounted.
mountPoint
string
mountPoint
string
fileSystem
RawFileSystem
fileSystem
RawFileSystem
// I/O with kernel and daemon.
// I/O with kernel and daemon.
mountFile
*
os
.
File
mountFile
*
os
.
File
errorChannel
chan
os
.
Error
errorChannel
chan
os
.
Error
outputChannel
chan
[][]
byte
outputChannel
chan
[][]
byte
// Run each operation in its own Go-routine.
// Run each operation in its own Go-routine.
threaded
bool
threaded
bool
...
@@ -109,7 +107,7 @@ func (self *MountState) Mount(mountPoint string, threaded bool) os.Error {
...
@@ -109,7 +107,7 @@ func (self *MountState) Mount(mountPoint string, threaded bool) os.Error {
self
.
mountPoint
=
mp
self
.
mountPoint
=
mp
self
.
mountFile
=
file
self
.
mountFile
=
file
self
.
threaded
=
threaded
self
.
threaded
=
threaded
if
self
.
threaded
{
if
self
.
threaded
{
self
.
outputChannel
=
make
(
chan
[][]
byte
,
100
)
self
.
outputChannel
=
make
(
chan
[][]
byte
,
100
)
self
.
errorChannel
=
make
(
chan
os
.
Error
,
100
)
self
.
errorChannel
=
make
(
chan
os
.
Error
,
100
)
...
@@ -152,9 +150,9 @@ func (self *MountState) Write(packet [][]byte) {
...
@@ -152,9 +150,9 @@ func (self *MountState) Write(packet [][]byte) {
if
packet
==
nil
{
if
packet
==
nil
{
return
return
}
}
if
self
.
threaded
{
if
self
.
threaded
{
self
.
outputChannel
<-
packet
self
.
outputChannel
<-
packet
}
else
{
}
else
{
self
.
syncWrite
(
packet
)
self
.
syncWrite
(
packet
)
}
}
...
@@ -162,8 +160,8 @@ func (self *MountState) Write(packet [][]byte) {
...
@@ -162,8 +160,8 @@ func (self *MountState) Write(packet [][]byte) {
func
NewMountState
(
fs
RawFileSystem
)
*
MountState
{
func
NewMountState
(
fs
RawFileSystem
)
*
MountState
{
self
:=
new
(
MountState
)
self
:=
new
(
MountState
)
self
.
openedDirs
=
make
(
map
[
uint64
]
RawFuseDir
)
self
.
openedDirs
=
make
(
map
[
uint64
]
RawFuseDir
)
self
.
openedFiles
=
make
(
map
[
uint64
]
RawFuseFile
)
self
.
openedFiles
=
make
(
map
[
uint64
]
RawFuseFile
)
self
.
mountPoint
=
""
self
.
mountPoint
=
""
self
.
fileSystem
=
fs
self
.
fileSystem
=
fs
return
self
return
self
...
@@ -204,14 +202,14 @@ func (self *MountState) loop() {
...
@@ -204,14 +202,14 @@ func (self *MountState) loop() {
// According to fuse_chan_receive()
// According to fuse_chan_receive()
if
errNo
==
syscall
.
ENODEV
{
if
errNo
==
syscall
.
ENODEV
{
break
;
break
}
}
// What I see on linux-x86 2.6.35.10.
// What I see on linux-x86 2.6.35.10.
if
errNo
==
syscall
.
ENOSYS
{
if
errNo
==
syscall
.
ENOSYS
{
break
;
break
}
}
readErr
:=
os
.
NewError
(
fmt
.
Sprintf
(
"Failed to read from fuse conn: %v"
,
err
))
readErr
:=
os
.
NewError
(
fmt
.
Sprintf
(
"Failed to read from fuse conn: %v"
,
err
))
self
.
Error
(
readErr
)
self
.
Error
(
readErr
)
break
break
...
@@ -246,8 +244,6 @@ func (self *MountState) handle(in_data []byte) {
...
@@ -246,8 +244,6 @@ func (self *MountState) handle(in_data []byte) {
}
}
func
dispatch
(
state
*
MountState
,
h
*
InHeader
,
arg
*
bytes
.
Buffer
)
(
outBytes
[][]
byte
)
{
func
dispatch
(
state
*
MountState
,
h
*
InHeader
,
arg
*
bytes
.
Buffer
)
(
outBytes
[][]
byte
)
{
input
:=
newInput
(
h
.
Opcode
)
input
:=
newInput
(
h
.
Opcode
)
if
input
!=
nil
&&
!
parseLittleEndian
(
arg
,
input
)
{
if
input
!=
nil
&&
!
parseLittleEndian
(
arg
,
input
)
{
...
@@ -263,17 +259,17 @@ func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]b
...
@@ -263,17 +259,17 @@ func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]b
filename
:=
""
filename
:=
""
// Perhaps a map is faster?
// Perhaps a map is faster?
if
(
h
.
Opcode
==
FUSE_UNLINK
||
h
.
Opcode
==
FUSE_RMDIR
||
if
h
.
Opcode
==
FUSE_UNLINK
||
h
.
Opcode
==
FUSE_RMDIR
||
h
.
Opcode
==
FUSE_LOOKUP
||
h
.
Opcode
==
FUSE_MKDIR
||
h
.
Opcode
==
FUSE_LOOKUP
||
h
.
Opcode
==
FUSE_MKDIR
||
h
.
Opcode
==
FUSE_MKNOD
||
h
.
Opcode
==
FUSE_CREATE
||
h
.
Opcode
==
FUSE_MKNOD
||
h
.
Opcode
==
FUSE_CREATE
||
h
.
Opcode
==
FUSE_LINK
)
{
h
.
Opcode
==
FUSE_LINK
{
filename
=
strings
.
TrimRight
(
string
(
arg
.
Bytes
()),
"
\x00
"
)
filename
=
strings
.
TrimRight
(
string
(
arg
.
Bytes
()),
"
\x00
"
)
}
}
if
state
.
Debug
{
if
state
.
Debug
{
log
.
Printf
(
"Dispatch: %v, NodeId: %v, n: %v
\n
"
,
operationName
(
h
.
Opcode
),
h
.
NodeId
,
filename
)
log
.
Printf
(
"Dispatch: %v, NodeId: %v, n: %v
\n
"
,
operationName
(
h
.
Opcode
),
h
.
NodeId
,
filename
)
}
}
// Follow ordering of fuse_lowlevel.h.
// Follow ordering of fuse_lowlevel.h.
switch
h
.
Opcode
{
switch
h
.
Opcode
{
case
FUSE_INIT
:
case
FUSE_INIT
:
...
@@ -296,9 +292,9 @@ func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]b
...
@@ -296,9 +292,9 @@ func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]b
case
FUSE_READLINK
:
case
FUSE_READLINK
:
out
,
status
=
fs
.
Readlink
(
h
)
out
,
status
=
fs
.
Readlink
(
h
)
case
FUSE_MKNOD
:
case
FUSE_MKNOD
:
out
,
status
=
fs
.
Mknod
(
h
,
input
.
(
*
MknodIn
),
filename
)
out
,
status
=
fs
.
Mknod
(
h
,
input
.
(
*
MknodIn
),
filename
)
case
FUSE_MKDIR
:
case
FUSE_MKDIR
:
out
,
status
=
fs
.
Mkdir
(
h
,
input
.
(
*
MkdirIn
),
filename
)
out
,
status
=
fs
.
Mkdir
(
h
,
input
.
(
*
MkdirIn
),
filename
)
case
FUSE_UNLINK
:
case
FUSE_UNLINK
:
status
=
fs
.
Unlink
(
h
,
filename
)
status
=
fs
.
Unlink
(
h
,
filename
)
case
FUSE_RMDIR
:
case
FUSE_RMDIR
:
...
@@ -375,7 +371,7 @@ func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]b
...
@@ -375,7 +371,7 @@ func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]b
log
.
Printf
(
"Serialize: %v code: %v value: %v
\n
"
,
log
.
Printf
(
"Serialize: %v code: %v value: %v
\n
"
,
operationName
(
h
.
Opcode
),
errorString
(
status
),
out
)
operationName
(
h
.
Opcode
),
errorString
(
status
),
out
)
}
}
return
serialize
(
h
,
status
,
out
)
return
serialize
(
h
,
status
,
out
)
}
}
...
@@ -390,7 +386,7 @@ func serialize(h *InHeader, res Status, out interface{}) (data [][]byte) {
...
@@ -390,7 +386,7 @@ func serialize(h *InHeader, res Status, out interface{}) (data [][]byte) {
panic
(
fmt
.
Sprintf
(
"Can't serialize out: %v, err: %v"
,
out
,
err
))
panic
(
fmt
.
Sprintf
(
"Can't serialize out: %v, err: %v"
,
out
,
err
))
}
}
}
}
var
hout
OutHeader
var
hout
OutHeader
hout
.
Unique
=
h
.
Unique
hout
.
Unique
=
h
.
Unique
hout
.
Status
=
-
res
hout
.
Status
=
-
res
...
@@ -405,12 +401,12 @@ func serialize(h *InHeader, res Status, out interface{}) (data [][]byte) {
...
@@ -405,12 +401,12 @@ func serialize(h *InHeader, res Status, out interface{}) (data [][]byte) {
return
data
return
data
}
}
func
initFuse
(
state
*
MountState
,
h
*
InHeader
,
input
*
InitIn
)
(
Empty
,
Status
)
{
func
initFuse
(
state
*
MountState
,
h
*
InHeader
,
input
*
InitIn
)
(
Empty
,
Status
)
{
out
,
initStatus
:=
state
.
fileSystem
.
Init
(
h
,
input
)
out
,
initStatus
:=
state
.
fileSystem
.
Init
(
h
,
input
)
if
initStatus
!=
OK
{
if
initStatus
!=
OK
{
return
nil
,
initStatus
return
nil
,
initStatus
}
}
if
input
.
Major
!=
FUSE_KERNEL_VERSION
{
if
input
.
Major
!=
FUSE_KERNEL_VERSION
{
fmt
.
Printf
(
"Major versions does not match. Given %d, want %d
\n
"
,
input
.
Major
,
FUSE_KERNEL_VERSION
)
fmt
.
Printf
(
"Major versions does not match. Given %d, want %d
\n
"
,
input
.
Major
,
FUSE_KERNEL_VERSION
)
return
nil
,
EIO
return
nil
,
EIO
...
@@ -433,7 +429,7 @@ func initFuse(state* MountState, h *InHeader, input *InitIn) (Empty, Status) {
...
@@ -433,7 +429,7 @@ func initFuse(state* MountState, h *InHeader, input *InitIn) (Empty, Status) {
// Handling files.
// Handling files.
func
doOpen
(
state
*
MountState
,
header
*
InHeader
,
input
*
OpenIn
)
(
genericOut
Empty
,
code
Status
)
{
func
doOpen
(
state
*
MountState
,
header
*
InHeader
,
input
*
OpenIn
)
(
genericOut
Empty
,
code
Status
)
{
flags
,
fuseFile
,
status
:=
state
.
fileSystem
.
Open
(
header
,
input
)
;
flags
,
fuseFile
,
status
:=
state
.
fileSystem
.
Open
(
header
,
input
)
if
status
!=
OK
{
if
status
!=
OK
{
return
nil
,
status
return
nil
,
status
}
}
...
@@ -447,7 +443,7 @@ func doOpen(state *MountState, header *InHeader, input *OpenIn) (genericOut Empt
...
@@ -447,7 +443,7 @@ func doOpen(state *MountState, header *InHeader, input *OpenIn) (genericOut Empt
}
}
func
doCreate
(
state
*
MountState
,
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
genericOut
Empty
,
code
Status
)
{
func
doCreate
(
state
*
MountState
,
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
genericOut
Empty
,
code
Status
)
{
flags
,
fuseFile
,
entry
,
status
:=
state
.
fileSystem
.
Create
(
header
,
input
,
name
)
;
flags
,
fuseFile
,
entry
,
status
:=
state
.
fileSystem
.
Create
(
header
,
input
,
name
)
if
status
!=
OK
{
if
status
!=
OK
{
return
nil
,
status
return
nil
,
status
}
}
...
@@ -501,7 +497,7 @@ func doReleaseDir(state *MountState, header *InHeader, input *ReleaseIn) (out Em
...
@@ -501,7 +497,7 @@ func doReleaseDir(state *MountState, header *InHeader, input *ReleaseIn) (out Em
}
}
func
doOpenDir
(
state
*
MountState
,
header
*
InHeader
,
input
*
OpenIn
)
(
genericOut
Empty
,
code
Status
)
{
func
doOpenDir
(
state
*
MountState
,
header
*
InHeader
,
input
*
OpenIn
)
(
genericOut
Empty
,
code
Status
)
{
flags
,
fuseDir
,
status
:=
state
.
fileSystem
.
OpenDir
(
header
,
input
)
;
flags
,
fuseDir
,
status
:=
state
.
fileSystem
.
OpenDir
(
header
,
input
)
if
status
!=
OK
{
if
status
!=
OK
{
return
nil
,
status
return
nil
,
status
}
}
...
...
fuse/pathfilesystem.go
View file @
6a7e4067
...
@@ -264,7 +264,7 @@ func (self *PathFileSystemConnector) Symlink(header *InHeader, pointedTo string,
...
@@ -264,7 +264,7 @@ func (self *PathFileSystemConnector) Symlink(header *InHeader, pointedTo string,
}
}
func
(
self
*
PathFileSystemConnector
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
self
*
PathFileSystemConnector
)
Rename
(
header
*
InHeader
,
input
*
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
// TODO - should also update the path <-> inode mapping?
oldPath
:=
path
.
Join
(
self
.
GetPath
(
header
.
NodeId
),
oldName
)
oldPath
:=
path
.
Join
(
self
.
GetPath
(
header
.
NodeId
),
oldName
)
newPath
:=
path
.
Join
(
self
.
GetPath
(
input
.
Newdir
),
newName
)
newPath
:=
path
.
Join
(
self
.
GetPath
(
input
.
Newdir
),
newName
)
return
self
.
fileSystem
.
Rename
(
oldPath
,
newPath
)
return
self
.
fileSystem
.
Rename
(
oldPath
,
newPath
)
...
...
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