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
32303528
Commit
32303528
authored
Aug 03, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement StatFs.
parent
88b161f9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
0 deletions
+77
-0
fuse/api.go
fuse/api.go
+3
-0
fuse/default.go
fuse/default.go
+9
-0
fuse/loopback.go
fuse/loopback.go
+21
-0
fuse/loopback_test.go
fuse/loopback_test.go
+28
-0
fuse/opcode.go
fuse/opcode.go
+11
-0
fuse/pathops.go
fuse/pathops.go
+5
-0
No files found.
fuse/api.go
View file @
32303528
...
...
@@ -63,6 +63,8 @@ type FileSystem interface {
// Symlinks.
Symlink
(
value
string
,
linkName
string
)
(
code
Status
)
Readlink
(
name
string
)
(
string
,
Status
)
StatFs
()
*
StatfsOut
}
// A File object should be returned from FileSystem.Open and
...
...
@@ -163,6 +165,7 @@ type RawFileSystem interface {
//
Ioctl
(
header
*
InHeader
,
input
*
IoctlIn
)
(
output
*
IoctlOut
,
data
[]
byte
,
code
Status
)
StatFs
()
*
StatfsOut
// Provide callbacks for pushing notifications to the kernel.
Init
(
params
*
RawFsInit
)
...
...
fuse/default.go
View file @
32303528
...
...
@@ -12,6 +12,11 @@ var _ = fmt.Println
func
(
me
*
DefaultRawFileSystem
)
Init
(
init
*
RawFsInit
)
{
}
func
(
me
*
DefaultRawFileSystem
)
StatFs
()
*
StatfsOut
{
return
nil
}
func
(
me
*
DefaultRawFileSystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
...
...
@@ -280,3 +285,7 @@ func (me *DefaultFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64
func
(
me
*
DefaultFileSystem
)
Name
()
string
{
return
"DefaultFileSystem"
}
func
(
me
*
DefaultFileSystem
)
StatFs
()
*
StatfsOut
{
return
nil
}
fuse/loopback.go
View file @
32303528
...
...
@@ -163,3 +163,24 @@ func (me *LoopbackFileSystem) Name() string {
return
fmt
.
Sprintf
(
"LoopbackFileSystem(%s)"
,
me
.
Root
)
}
func
(
me
*
LoopbackFileSystem
)
StatFs
()
*
StatfsOut
{
s
:=
syscall
.
Statfs_t
{}
errNo
:=
syscall
.
Statfs
(
me
.
Root
,
&
s
)
if
errNo
==
0
{
return
&
StatfsOut
{
Kstatfs
{
Blocks
:
s
.
Blocks
,
Bsize
:
uint32
(
s
.
Bsize
),
Bfree
:
s
.
Bfree
,
Bavail
:
s
.
Bavail
,
Files
:
s
.
Files
,
Ffree
:
s
.
Ffree
,
Frsize
:
uint32
(
s
.
Frsize
),
NameLen
:
uint32
(
s
.
Namelen
),
},
}
}
return
nil
}
fuse/loopback_test.go
View file @
32303528
...
...
@@ -635,3 +635,31 @@ func TestIoctl(t *testing.T) {
v
,
e
:=
ioctl
(
f
.
Fd
(),
0x5401
,
42
)
fmt
.
Println
(
"ioctl"
,
v
,
e
)
}
func
TestStatFs
(
t
*
testing
.
T
)
{
ts
:=
NewTestCase
(
t
)
defer
ts
.
Cleanup
()
s1
:=
syscall
.
Statfs_t
{}
err
:=
syscall
.
Statfs
(
ts
.
orig
,
&
s1
)
if
err
!=
0
{
t
.
Fatal
(
"statfs orig"
,
err
)
}
s2
:=
syscall
.
Statfs_t
{}
err
=
syscall
.
Statfs
(
ts
.
mnt
,
&
s2
)
s1
.
Type
=
0
s2
.
Type
=
0
s1
.
Fsid
=
[
8
]
byte
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
s2
.
Fsid
=
[
8
]
byte
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
if
err
!=
0
{
t
.
Fatal
(
"statfs mnt"
,
err
)
}
if
fmt
.
Sprintf
(
"%v"
,
s2
)
!=
fmt
.
Sprintf
(
"%v"
,
s1
)
{
t
.
Error
(
"Mismatch"
,
s1
,
s2
)
}
}
fuse/opcode.go
View file @
32303528
...
...
@@ -279,6 +279,16 @@ func doRename(state *MountState, req *request) {
req
.
status
=
state
.
fileSystem
.
Rename
(
req
.
inHeader
,
(
*
RenameIn
)(
req
.
inData
),
req
.
filenames
[
0
],
req
.
filenames
[
1
])
}
func
doStatFs
(
state
*
MountState
,
req
*
request
)
{
stat
:=
state
.
fileSystem
.
StatFs
()
if
stat
!=
nil
{
req
.
outData
=
unsafe
.
Pointer
(
stat
)
req
.
status
=
OK
}
else
{
req
.
status
=
ENOSYS
}
}
func
doIoctl
(
state
*
MountState
,
req
*
request
)
{
out
,
data
,
stat
:=
state
.
fileSystem
.
Ioctl
(
req
.
inHeader
,
(
*
IoctlIn
)(
req
.
inData
))
req
.
outData
=
unsafe
.
Pointer
(
out
)
...
...
@@ -460,6 +470,7 @@ func init() {
_OP_ACCESS
:
doAccess
,
_OP_SYMLINK
:
doSymlink
,
_OP_RENAME
:
doRename
,
_OP_STATFS
:
doStatFs
,
}
{
operationHandlers
[
op
]
.
Func
=
v
}
...
...
fuse/pathops.go
View file @
32303528
...
...
@@ -519,3 +519,8 @@ func (me *FileSystemConnector) Ioctl(header *InHeader, input *IoctlIn) (out *Ioc
}
return
opened
.
file
.
Ioctl
(
input
)
}
func
(
me
*
FileSystemConnector
)
StatFs
()
*
StatfsOut
{
return
me
.
rootNode
.
mountPoint
.
fs
.
StatFs
()
}
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