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
c4df48de
Commit
c4df48de
authored
May 27, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have Read() return Status separately.
parent
fa85dd80
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
27 additions
and
33 deletions
+27
-33
fuse/api.go
fuse/api.go
+2
-2
fuse/copy.go
fuse/copy.go
+3
-3
fuse/defaultfile.go
fuse/defaultfile.go
+2
-2
fuse/defaultraw.go
fuse/defaultraw.go
+2
-2
fuse/files.go
fuse/files.go
+6
-8
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+2
-2
fuse/fsops.go
fuse/fsops.go
+1
-1
fuse/lockingfs.go
fuse/lockingfs.go
+3
-1
fuse/opcode.go
fuse/opcode.go
+1
-3
fuse/read.go
fuse/read.go
+5
-9
No files found.
fuse/api.go
View file @
c4df48de
...
...
@@ -161,7 +161,7 @@ type File interface {
// the inner file here.
InnerFile
()
File
Read
(
dest
[]
byte
,
off
int64
)
ReadResult
Read
(
dest
[]
byte
,
off
int64
)
(
ReadResult
,
Status
)
Write
(
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
Status
)
Flush
()
Status
Release
()
...
...
@@ -281,7 +281,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
,
*
raw
.
ReadIn
,
[]
byte
)
ReadResult
Read
(
*
raw
.
InHeader
,
*
raw
.
ReadIn
,
[]
byte
)
(
ReadResult
,
Status
)
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
Write
(
*
raw
.
InHeader
,
*
raw
.
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
...
...
fuse/copy.go
View file @
c4df48de
...
...
@@ -27,9 +27,9 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte
buf
:=
make
([]
byte
,
128
*
(
1
<<
10
))
off
:=
int64
(
0
)
for
{
res
:=
src
.
Read
(
buf
,
off
)
if
!
res
.
Ok
()
{
return
res
.
Status
res
,
code
:=
src
.
Read
(
buf
,
off
)
if
!
code
.
Ok
()
{
return
code
}
res
.
Read
(
buf
)
...
...
fuse/defaultfile.go
View file @
c4df48de
...
...
@@ -21,8 +21,8 @@ func (f *DefaultFile) String() string {
return
"DefaultFile"
}
func
(
f
*
DefaultFile
)
Read
(
buf
[]
byte
,
off
int64
)
ReadResult
{
return
ReadResult
{
Status
:
ENOSYS
}
func
(
f
*
DefaultFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
ReadResult
,
Status
)
{
return
ReadResult
{
},
ENOSYS
}
func
(
f
*
DefaultFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
...
...
fuse/defaultraw.go
View file @
c4df48de
...
...
@@ -96,8 +96,8 @@ func (fs *DefaultRawFileSystem) OpenDir(out *raw.OpenOut, header *raw.InHeader,
return
ENOSYS
}
func
(
fs
*
DefaultRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReadIn
,
buf
[]
byte
)
ReadResult
{
return
ReadResult
{}
func
(
fs
*
DefaultRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReadIn
,
buf
[]
byte
)
(
ReadResult
,
Status
)
{
return
ReadResult
{}
,
ENOSYS
}
func
(
fs
*
DefaultRawFileSystem
)
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
{
...
...
fuse/files.go
View file @
c4df48de
...
...
@@ -39,15 +39,14 @@ func NewDataFile(data []byte) *DataFile {
return
f
}
func
(
f
*
DataFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
ReadResult
)
{
func
(
f
*
DataFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
ReadResult
,
code
Status
)
{
end
:=
int
(
off
)
+
int
(
len
(
buf
))
if
end
>
len
(
f
.
data
)
{
end
=
len
(
f
.
data
)
}
res
.
Data
=
f
.
data
[
off
:
end
]
res
.
Status
=
OK
return
res
return
res
,
OK
}
////////////////
...
...
@@ -67,8 +66,8 @@ func (f *DevNullFile) String() string {
return
"DevNullFile"
}
func
(
f
*
DevNullFile
)
Read
(
buf
[]
byte
,
off
int64
)
ReadResult
{
return
ReadResult
{}
func
(
f
*
DevNullFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
ReadResult
,
Status
)
{
return
ReadResult
{}
,
OK
}
func
(
f
*
DevNullFile
)
Write
(
content
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
...
...
@@ -100,13 +99,12 @@ func (f *LoopbackFile) String() string {
return
fmt
.
Sprintf
(
"LoopbackFile(%s)"
,
f
.
File
.
Name
())
}
func
(
f
*
LoopbackFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
ReadResult
)
{
func
(
f
*
LoopbackFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
ReadResult
,
code
Status
)
{
return
ReadResult
{
Fd
:
f
.
File
.
Fd
(),
FdOff
:
off
,
FdSize
:
len
(
buf
),
Status
:
OK
,
}
},
OK
}
func
(
f
*
LoopbackFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
...
...
fuse/fsetattr_test.go
View file @
c4df48de
...
...
@@ -22,13 +22,13 @@ func (f *MutableDataFile) String() string {
return
"MutableDataFile"
}
func
(
f
*
MutableDataFile
)
Read
(
buf
[]
byte
,
off
int64
)
ReadResult
{
func
(
f
*
MutableDataFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
ReadResult
,
Status
)
{
end
:=
int
(
off
)
+
len
(
buf
)
if
end
>
len
(
f
.
data
)
{
end
=
len
(
f
.
data
)
}
return
ReadResult
{
Data
:
f
.
data
[
off
:
end
]}
return
ReadResult
{
Data
:
f
.
data
[
off
:
end
]}
,
OK
}
func
(
f
*
MutableDataFile
)
Write
(
d
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
...
...
fuse/fsops.go
View file @
c4df48de
...
...
@@ -350,7 +350,7 @@ func (c *FileSystemConnector) Write(header *raw.InHeader, input *raw.WriteIn, da
return
opened
.
WithFlags
.
File
.
Write
(
data
,
int64
(
input
.
Offset
))
}
func
(
c
*
FileSystemConnector
)
Read
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReadIn
,
buf
[]
byte
)
ReadResult
{
func
(
c
*
FileSystemConnector
)
Read
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReadIn
,
buf
[]
byte
)
(
ReadResult
,
Status
)
{
node
:=
c
.
toInode
(
header
.
NodeId
)
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
...
...
fuse/lockingfs.go
View file @
c4df48de
...
...
@@ -16,6 +16,8 @@ type LockingFileSystem struct {
lock
sync
.
Mutex
}
var
_
=
((
FileSystem
)((
*
LockingFileSystem
)(
nil
)))
func
NewLockingFileSystem
(
pfs
FileSystem
)
*
LockingFileSystem
{
l
:=
new
(
LockingFileSystem
)
l
.
FileSystem
=
pfs
...
...
@@ -276,7 +278,7 @@ func (fs *LockingRawFileSystem) ReleaseDir(header *raw.InHeader, h *raw.ReleaseI
fs
.
RawFileSystem
.
ReleaseDir
(
header
,
h
)
}
func
(
fs
*
LockingRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReadIn
,
buf
[]
byte
)
ReadResult
{
func
(
fs
*
LockingRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReadIn
,
buf
[]
byte
)
(
ReadResult
,
Status
)
{
defer
fs
.
locked
()()
return
fs
.
RawFileSystem
.
Read
(
header
,
input
,
buf
)
}
...
...
fuse/opcode.go
View file @
c4df48de
...
...
@@ -269,9 +269,7 @@ func doLink(state *MountState, req *request) {
func
doRead
(
state
*
MountState
,
req
*
request
)
{
in
:=
(
*
raw
.
ReadIn
)(
req
.
inData
)
buf
:=
state
.
AllocOut
(
req
,
in
.
Size
)
res
:=
state
.
fileSystem
.
Read
(
req
.
inHeader
,
in
,
buf
)
req
.
flatData
=
res
req
.
status
=
res
.
Status
req
.
flatData
,
req
.
status
=
state
.
fileSystem
.
Read
(
req
.
inHeader
,
in
,
buf
)
}
func
doFlush
(
state
*
MountState
,
req
*
request
)
{
...
...
fuse/read.go
View file @
c4df48de
...
...
@@ -14,9 +14,6 @@ import (
// If at any point, the raw data is needed, ReadResult.Read() will
// load the raw data into the Data member.
type
ReadResult
struct
{
// Errno code for the read.
Status
// Raw bytes for the read.
Data
[]
byte
...
...
@@ -46,11 +43,10 @@ func (r *ReadResult) Size() int {
// Reads raw bytes from file descriptor if necessary, using the passed
// buffer as storage.
func
(
r
*
ReadResult
)
Read
(
buf
[]
byte
)
Status
{
if
r
.
Data
!=
nil
||
!
r
.
Ok
()
{
return
r
.
Status
if
r
.
Data
!=
nil
{
return
OK
}
if
len
(
buf
)
<
r
.
FdSize
{
r
.
Status
=
ERANGE
return
ERANGE
}
...
...
@@ -58,13 +54,13 @@ func (r *ReadResult) Read(buf []byte) Status {
if
err
==
io
.
EOF
{
err
=
nil
}
r
.
Status
=
ToStatus
(
err
)
if
r
.
Ok
()
{
code
:
=
ToStatus
(
err
)
if
code
.
Ok
()
{
r
.
Data
=
buf
[
:
n
]
}
r
.
Fd
=
0
r
.
FdOff
=
0
r
.
FdSize
=
0
return
r
.
Status
return
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