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
a88bf602
Commit
a88bf602
authored
May 22, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change file Read/Write API.
parent
40776fb9
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
55 additions
and
47 deletions
+55
-47
fuse/api.go
fuse/api.go
+3
-3
fuse/copy.go
fuse/copy.go
+6
-10
fuse/defaultfile.go
fuse/defaultfile.go
+3
-3
fuse/defaultraw.go
fuse/defaultraw.go
+1
-1
fuse/files.go
fuse/files.go
+14
-14
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+6
-6
fuse/fsops.go
fuse/fsops.go
+4
-3
fuse/lockingfs.go
fuse/lockingfs.go
+2
-2
fuse/opcode.go
fuse/opcode.go
+4
-2
fuse/request.go
fuse/request.go
+11
-2
unionfs/unionfs.go
unionfs/unionfs.go
+1
-1
No files found.
fuse/api.go
View file @
a88bf602
...
...
@@ -161,8 +161,8 @@ type File interface {
// the inner file here.
InnerFile
()
File
Read
(
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Read
(
dest
[]
byte
,
off
int64
)
([]
byte
,
Status
)
Write
(
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
Status
)
Flush
()
Status
Release
()
Fsync
(
flags
int
)
(
code
Status
)
...
...
@@ -278,7 +278,7 @@ type RawFileSystem interface {
// File handling.
Create
(
out
*
raw
.
CreateOut
,
header
*
raw
.
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
code
Status
)
Open
(
out
*
raw
.
OpenOut
,
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
status
Status
)
Read
(
*
raw
.
InHeader
,
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
Read
(
*
raw
.
InHeader
,
*
ReadIn
,
[]
byte
)
([]
byte
,
Status
)
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
Write
(
*
raw
.
InHeader
,
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
...
...
fuse/copy.go
View file @
a88bf602
...
...
@@ -27,31 +27,27 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte
defer
dst
.
Release
()
defer
dst
.
Flush
()
bp
:=
NewBufferPool
()
r
:=
ReadIn
{
Size
:
128
*
(
1
<<
10
),
}
buf
:=
make
([]
byte
,
128
*
(
1
<<
10
))
off
:=
int64
(
0
)
for
{
data
,
code
:=
src
.
Read
(
&
r
,
bp
)
data
,
code
:=
src
.
Read
(
buf
,
off
)
if
!
code
.
Ok
()
{
return
code
}
if
len
(
data
)
==
0
{
break
}
n
,
code
:=
dst
.
Write
(
&
w
,
data
)
n
,
code
:=
dst
.
Write
(
data
,
off
)
if
!
code
.
Ok
()
{
return
code
}
if
int
(
n
)
<
len
(
data
)
{
return
EIO
}
if
len
(
data
)
<
int
(
r
.
Size
)
{
if
len
(
data
)
<
len
(
buf
)
{
break
}
r
.
Offset
+=
uint64
(
len
(
data
))
w
.
Offset
+=
uint64
(
len
(
data
))
bp
.
FreeBuffer
(
data
)
off
+=
int64
(
len
(
data
))
}
return
OK
}
fuse/defaultfile.go
View file @
a88bf602
...
...
@@ -19,11 +19,11 @@ func (f *DefaultFile) String() string {
return
"DefaultFile"
}
func
(
f
*
DefaultFile
)
Read
(
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
(
""
)
,
ENOSYS
func
(
f
*
DefaultFile
)
Read
(
buf
[]
byte
,
off
int64
)
([]
byte
,
Status
)
{
return
nil
,
ENOSYS
}
func
(
f
*
DefaultFile
)
Write
(
*
WriteIn
,
[]
byte
)
(
uint32
,
Status
)
{
func
(
f
*
DefaultFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
return
0
,
ENOSYS
}
...
...
fuse/defaultraw.go
View file @
a88bf602
...
...
@@ -97,7 +97,7 @@ func (fs *DefaultRawFileSystem) OpenDir(out *raw.OpenOut, header *raw.InHeader,
return
ENOSYS
}
func
(
fs
*
DefaultRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
b
p
BufferPool
)
([]
byte
,
Status
)
{
func
(
fs
*
DefaultRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
b
uf
[]
byte
)
([]
byte
,
Status
)
{
return
nil
,
ENOSYS
}
...
...
fuse/files.go
View file @
a88bf602
...
...
@@ -17,6 +17,8 @@ type DataFile struct {
DefaultFile
}
var
_
=
(
File
)((
*
DataFile
)(
nil
))
func
(
f
*
DataFile
)
String
()
string
{
l
:=
len
(
f
.
data
)
if
l
>
10
{
...
...
@@ -38,13 +40,13 @@ func NewDataFile(data []byte) *DataFile {
return
f
}
func
(
f
*
DataFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
end
:=
int
(
input
.
Offset
)
+
int
(
input
.
Size
)
func
(
f
*
DataFile
)
Read
(
buf
[]
byte
,
off
int64
)
([]
byte
,
Status
)
{
end
:=
int
(
off
)
+
int
(
len
(
buf
)
)
if
end
>
len
(
f
.
data
)
{
end
=
len
(
f
.
data
)
}
return
f
.
data
[
input
.
Offset
:
end
],
OK
return
f
.
data
[
off
:
end
],
OK
}
////////////////
...
...
@@ -64,11 +66,11 @@ func (f *DevNullFile) String() string {
return
"DevNullFile"
}
func
(
f
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
{}
,
OK
func
(
f
*
DevNullFile
)
Read
(
buf
[]
byte
,
off
int64
)
([]
byte
,
Status
)
{
return
nil
,
OK
}
func
(
f
*
DevNullFile
)
Write
(
input
*
WriteIn
,
content
[]
byte
)
(
uint32
,
Status
)
{
func
(
f
*
DevNullFile
)
Write
(
content
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
return
uint32
(
len
(
content
)),
OK
}
...
...
@@ -97,18 +99,16 @@ func (f *LoopbackFile) String() string {
return
fmt
.
Sprintf
(
"LoopbackFile(%s)"
,
f
.
File
.
Name
())
}
func
(
f
*
LoopbackFile
)
Read
(
input
*
ReadIn
,
buffers
BufferPool
)
([]
byte
,
Status
)
{
slice
:=
buffers
.
AllocBuffer
(
input
.
Size
)
n
,
err
:=
f
.
File
.
ReadAt
(
slice
,
int64
(
input
.
Offset
))
func
(
f
*
LoopbackFile
)
Read
(
buf
[]
byte
,
off
int64
)
([]
byte
,
Status
)
{
n
,
err
:=
f
.
File
.
ReadAt
(
buf
,
off
)
if
err
==
io
.
EOF
{
err
=
nil
}
return
slice
[
:
n
],
ToStatus
(
err
)
return
buf
[
:
n
],
ToStatus
(
err
)
}
func
(
f
*
LoopbackFile
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
uint32
,
Status
)
{
n
,
err
:=
f
.
File
.
WriteAt
(
data
,
int64
(
input
.
Offset
)
)
func
(
f
*
LoopbackFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
n
,
err
:=
f
.
File
.
WriteAt
(
data
,
off
)
return
uint32
(
n
),
ToStatus
(
err
)
}
...
...
@@ -159,7 +159,7 @@ func (f *ReadOnlyFile) String() string {
return
fmt
.
Sprintf
(
"ReadOnlyFile(%s)"
,
f
.
File
.
String
())
}
func
(
f
*
ReadOnlyFile
)
Write
(
input
*
WriteIn
,
data
[]
byte
)
(
uint32
,
Status
)
{
func
(
f
*
ReadOnlyFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
return
0
,
EPERM
}
...
...
fuse/fsetattr_test.go
View file @
a88bf602
...
...
@@ -22,19 +22,19 @@ func (f *MutableDataFile) String() string {
return
"MutableDataFile"
}
func
(
f
*
MutableDataFile
)
Read
(
r
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
f
.
data
[
r
.
Offset
:
r
.
Offset
+
uint64
(
r
.
Size
)],
OK
func
(
f
*
MutableDataFile
)
Read
(
buf
[]
byte
,
off
int64
)
([]
byte
,
Status
)
{
return
f
.
data
[
off
:
off
+
int64
(
len
(
buf
)
)],
OK
}
func
(
f
*
MutableDataFile
)
Write
(
w
*
WriteIn
,
d
[]
byte
)
(
uint32
,
Status
)
{
end
:=
uint64
(
w
.
Size
)
+
w
.
Offset
func
(
f
*
MutableDataFile
)
Write
(
d
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
end
:=
int64
(
len
(
d
))
+
off
if
int
(
end
)
>
len
(
f
.
data
)
{
data
:=
make
([]
byte
,
len
(
f
.
data
),
end
)
copy
(
data
,
f
.
data
)
f
.
data
=
data
}
copy
(
f
.
data
[
w
.
Offset
:
end
],
d
)
return
w
.
Size
,
OK
copy
(
f
.
data
[
off
:
end
],
d
)
return
uint32
(
end
-
off
)
,
OK
}
func
(
f
*
MutableDataFile
)
Flush
()
Status
{
...
...
fuse/fsops.go
View file @
a88bf602
...
...
@@ -347,13 +347,14 @@ func (c *FileSystemConnector) ListXAttr(header *raw.InHeader) (data []byte, code
func
(
c
*
FileSystemConnector
)
Write
(
header
*
raw
.
InHeader
,
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
node
:=
c
.
toInode
(
header
.
NodeId
)
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
return
opened
.
WithFlags
.
File
.
Write
(
input
,
data
)
return
opened
.
WithFlags
.
File
.
Write
(
data
,
int64
(
input
.
Offset
)
)
}
func
(
c
*
FileSystemConnector
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
b
p
BufferPool
)
([]
byte
,
Status
)
{
func
(
c
*
FileSystemConnector
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
b
uf
[]
byte
)
([]
byte
,
Status
)
{
node
:=
c
.
toInode
(
header
.
NodeId
)
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
return
opened
.
WithFlags
.
File
.
Read
(
input
,
bp
)
return
opened
.
WithFlags
.
File
.
Read
(
buf
,
int64
(
input
.
Offset
))
}
func
(
c
*
FileSystemConnector
)
StatFs
(
out
*
StatfsOut
,
header
*
raw
.
InHeader
)
Status
{
...
...
fuse/lockingfs.go
View file @
a88bf602
...
...
@@ -276,9 +276,9 @@ func (fs *LockingRawFileSystem) ReleaseDir(header *raw.InHeader, h *raw.ReleaseI
fs
.
RawFileSystem
.
ReleaseDir
(
header
,
h
)
}
func
(
fs
*
LockingRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
b
p
BufferPool
)
([]
byte
,
Status
)
{
func
(
fs
*
LockingRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
b
uf
[]
byte
)
([]
byte
,
Status
)
{
defer
fs
.
locked
()()
return
fs
.
RawFileSystem
.
Read
(
header
,
input
,
b
p
)
return
fs
.
RawFileSystem
.
Read
(
header
,
input
,
b
uf
)
}
func
(
fs
*
LockingRawFileSystem
)
Write
(
header
*
raw
.
InHeader
,
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
...
...
fuse/opcode.go
View file @
a88bf602
...
...
@@ -119,7 +119,7 @@ func doCreate(state *MountState, req *request) {
func
doReadDir
(
state
*
MountState
,
req
*
request
)
{
in
:=
(
*
ReadIn
)(
req
.
inData
)
buf
:=
state
.
buffers
.
AllocBuffer
(
in
.
Size
)
buf
:=
req
.
AllocOut
(
in
.
Size
)
entries
:=
NewDirEntryList
(
buf
,
uint64
(
in
.
Offset
))
code
:=
state
.
fileSystem
.
ReadDir
(
entries
,
req
.
inHeader
,
in
)
...
...
@@ -253,7 +253,9 @@ func doLink(state *MountState, req *request) {
}
func
doRead
(
state
*
MountState
,
req
*
request
)
{
req
.
flatData
,
req
.
status
=
state
.
fileSystem
.
Read
(
req
.
inHeader
,
(
*
ReadIn
)(
req
.
inData
),
state
.
buffers
)
in
:=
(
*
ReadIn
)(
req
.
inData
)
buf
:=
req
.
AllocOut
(
in
.
Size
)
req
.
flatData
,
req
.
status
=
state
.
fileSystem
.
Read
(
req
.
inHeader
,
in
,
buf
)
}
func
doFlush
(
state
*
MountState
,
req
*
request
)
{
...
...
fuse/request.go
View file @
a88bf602
...
...
@@ -14,13 +14,22 @@ var sizeOfOutHeader = unsafe.Sizeof(raw.OutHeader{})
var
zeroOutBuf
[
160
]
byte
func
(
req
*
request
)
Discard
()
{
req
.
pool
.
FreeBuffer
(
req
.
flatData
)
req
.
pool
.
FreeBuffer
(
req
.
bufferPoolOutputBuf
)
req
.
pool
.
FreeBuffer
(
req
.
bufferPoolInputBuf
)
}
func
(
req
*
request
)
AllocOut
(
size
uint32
)
[]
byte
{
if
req
.
bufferPoolOutputBuf
!=
nil
{
req
.
pool
.
FreeBuffer
(
req
.
bufferPoolOutputBuf
)
}
req
.
bufferPoolOutputBuf
=
req
.
pool
.
AllocBuffer
(
size
)
return
req
.
pool
.
AllocBuffer
(
size
)
}
type
request
struct
{
// the input, if obtained through bufferpool
bufferPoolInputBuf
[]
byte
bufferPoolInputBuf
[]
byte
bufferPoolOutputBuf
[]
byte
pool
BufferPool
// If we have a small input, we quickly copy it to here, and
...
...
unionfs/unionfs.go
View file @
a88bf602
...
...
@@ -257,7 +257,7 @@ func (fs *UnionFs) putDeletion(name string) (code fuse.Status) {
}
defer
f
.
Release
()
defer
f
.
Flush
()
n
,
code
:=
f
.
Write
(
&
fuse
.
WriteIn
{},
[]
byte
(
name
)
)
n
,
code
:=
f
.
Write
(
[]
byte
(
name
),
0
)
if
int
(
n
)
!=
len
(
name
)
||
!
code
.
Ok
()
{
panic
(
fmt
.
Sprintf
(
"Error for writing %v: %v, %v (exp %v) %v"
,
name
,
marker
,
n
,
len
(
name
),
code
))
}
...
...
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