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
aa771945
Commit
aa771945
authored
May 01, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move file implementations into files.go
parent
557780e1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
108 deletions
+114
-108
fuse/Makefile
fuse/Makefile
+1
-2
fuse/datafile.go
fuse/datafile.go
+0
-24
fuse/devnull.go
fuse/devnull.go
+0
-26
fuse/files.go
fuse/files.go
+113
-0
fuse/loopback.go
fuse/loopback.go
+0
-56
No files found.
fuse/Makefile
View file @
aa771945
...
...
@@ -12,13 +12,12 @@ GOFILES=misc.go\
pathfilesystem.go
\
bufferpool.go
\
default.go
\
datafile
.go
\
files
.go
\
lockingfs.go
\
loopback.go
\
timingfs.go
\
timingrawfs.go
\
xattr.go
\
devnull.go
\
pathdebug.go
\
opcode.go
\
pathops.go
\
...
...
fuse/datafile.go
deleted
100644 → 0
View file @
557780e1
package
fuse
// A FUSE file for read-only filesystems. This assumes we already have the data in memory.
type
ReadOnlyFile
struct
{
data
[]
byte
DefaultFile
}
func
NewReadOnlyFile
(
data
[]
byte
)
*
ReadOnlyFile
{
f
:=
new
(
ReadOnlyFile
)
f
.
data
=
data
return
f
}
func
(
me
*
ReadOnlyFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
end
:=
int
(
input
.
Offset
)
+
int
(
input
.
Size
)
if
end
>
len
(
me
.
data
)
{
end
=
len
(
me
.
data
)
}
return
me
.
data
[
input
.
Offset
:
end
],
OK
}
fuse/devnull.go
deleted
100644 → 0
View file @
557780e1
package
fuse
// A FUSE file that accepts any write, and always returns EOF.
type
DevNullFile
struct
{
DefaultFile
}
func
NewDevNullFile
()
*
DevNullFile
{
return
new
(
DevNullFile
)
}
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
{},
OK
}
func
(
me
*
DevNullFile
)
Write
(
input
*
WriteIn
,
content
[]
byte
)
(
uint32
,
Status
)
{
return
uint32
(
len
(
content
)),
OK
}
func
(
me
*
DevNullFile
)
Flush
()
Status
{
return
OK
}
func
(
me
*
DevNullFile
)
Fsync
(
*
FsyncIn
)
(
code
Status
)
{
return
OK
}
fuse/files.go
0 → 100644
View file @
aa771945
package
fuse
import
(
"os"
"syscall"
)
// ReadOnlyFile is for implementing read-only filesystems. This
// assumes we already have the data in memory.
type
ReadOnlyFile
struct
{
data
[]
byte
DefaultFile
}
func
NewReadOnlyFile
(
data
[]
byte
)
*
ReadOnlyFile
{
f
:=
new
(
ReadOnlyFile
)
f
.
data
=
data
return
f
}
func
(
me
*
ReadOnlyFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
end
:=
int
(
input
.
Offset
)
+
int
(
input
.
Size
)
if
end
>
len
(
me
.
data
)
{
end
=
len
(
me
.
data
)
}
return
me
.
data
[
input
.
Offset
:
end
],
OK
}
////////////////
// DevNullFile accepts any write, and always returns EOF.
type
DevNullFile
struct
{
DefaultFile
}
func
NewDevNullFile
()
*
DevNullFile
{
return
new
(
DevNullFile
)
}
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
{},
OK
}
func
(
me
*
DevNullFile
)
Write
(
input
*
WriteIn
,
content
[]
byte
)
(
uint32
,
Status
)
{
return
uint32
(
len
(
content
)),
OK
}
func
(
me
*
DevNullFile
)
Flush
()
Status
{
return
OK
}
func
(
me
*
DevNullFile
)
Fsync
(
*
FsyncIn
)
(
code
Status
)
{
return
OK
}
////////////////
// LoopbackFile delegates all operations back to an underlying os.File.
type
LoopbackFile
struct
{
file
*
os
.
File
DefaultFile
}
func
(
me
*
LoopbackFile
)
Read
(
input
*
ReadIn
,
buffers
*
BufferPool
)
([]
byte
,
Status
)
{
slice
:=
buffers
.
AllocBuffer
(
input
.
Size
)
n
,
err
:=
me
.
file
.
ReadAt
(
slice
,
int64
(
input
.
Offset
))
if
err
==
os
.
EOF
{
return
slice
[
:
n
],
OK
}
return
slice
[
:
n
],
OsErrorToErrno
(
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
)
}
func
(
me
*
LoopbackFile
)
Release
()
{
me
.
file
.
Close
()
}
func
(
me
*
LoopbackFile
)
Fsync
(
*
FsyncIn
)
(
code
Status
)
{
return
Status
(
syscall
.
Fsync
(
me
.
file
.
Fd
()))
}
func
(
me
*
LoopbackFile
)
Truncate
(
size
uint64
)
Status
{
return
Status
(
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
))
}
func
(
me
*
LoopbackFile
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
{
return
OsErrorToErrno
(
me
.
file
.
Chown
(
int
(
uid
),
int
(
gid
)))
}
func
(
me
*
LoopbackFile
)
GetAttr
()
(
*
Attr
,
Status
)
{
fi
,
err
:=
me
.
file
.
Stat
()
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
}
a
:=
&
Attr
{}
CopyFileInfo
(
fi
,
a
)
return
a
,
OK
}
fuse/loopback.go
View file @
aa771945
...
...
@@ -161,59 +161,3 @@ func (me *LoopbackFileSystem) ListXAttr(name string) ([]string, Status) {
func
(
me
*
LoopbackFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
return
Status
(
Removexattr
(
me
.
GetPath
(
name
),
attr
))
}
////////////////////////////////////////////////////////////////
type
LoopbackFile
struct
{
file
*
os
.
File
DefaultFile
}
func
(
me
*
LoopbackFile
)
Read
(
input
*
ReadIn
,
buffers
*
BufferPool
)
([]
byte
,
Status
)
{
slice
:=
buffers
.
AllocBuffer
(
input
.
Size
)
n
,
err
:=
me
.
file
.
ReadAt
(
slice
,
int64
(
input
.
Offset
))
if
err
==
os
.
EOF
{
return
slice
[
:
n
],
OK
}
return
slice
[
:
n
],
OsErrorToErrno
(
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
)
}
func
(
me
*
LoopbackFile
)
Release
()
{
me
.
file
.
Close
()
}
func
(
me
*
LoopbackFile
)
Fsync
(
*
FsyncIn
)
(
code
Status
)
{
return
Status
(
syscall
.
Fsync
(
me
.
file
.
Fd
()))
}
func
(
me
*
LoopbackFile
)
Truncate
(
size
uint64
)
Status
{
return
Status
(
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
))
}
func
(
me
*
LoopbackFile
)
Chown
(
uid
uint32
,
gid
uint32
)
Status
{
return
OsErrorToErrno
(
me
.
file
.
Chown
(
int
(
uid
),
int
(
gid
)))
}
func
(
me
*
LoopbackFile
)
GetAttr
()
(
*
Attr
,
Status
)
{
fi
,
err
:=
me
.
file
.
Stat
()
if
err
!=
nil
{
return
nil
,
OsErrorToErrno
(
err
)
}
a
:=
&
Attr
{}
CopyFileInfo
(
fi
,
a
)
return
a
,
OK
}
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