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
eb06cb23
Commit
eb06cb23
authored
Nov 03, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update for weekly.2011-11-02
parent
3881211d
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
49 additions
and
46 deletions
+49
-46
example/bulkstat/bulkstat.go
example/bulkstat/bulkstat.go
+2
-1
fuse/cache_test.go
fuse/cache_test.go
+1
-1
fuse/files.go
fuse/files.go
+2
-1
fuse/fuse.go
fuse/fuse.go
+3
-6
fuse/loopback.go
fuse/loopback.go
+3
-2
fuse/loopback_test.go
fuse/loopback_test.go
+4
-3
fuse/misc.go
fuse/misc.go
+5
-5
fuse/mount.go
fuse/mount.go
+13
-12
fuse/mountstate.go
fuse/mountstate.go
+4
-4
fuse/notify_test.go
fuse/notify_test.go
+1
-1
unionfs/autounion.go
unionfs/autounion.go
+2
-2
unionfs/create.go
unionfs/create.go
+1
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+2
-2
zipfs/tarfs.go
zipfs/tarfs.go
+2
-2
zipfs/zipfs.go
zipfs/zipfs.go
+4
-3
No files found.
example/bulkstat/bulkstat.go
View file @
eb06cb23
...
...
@@ -7,6 +7,7 @@ import (
"bufio"
"flag"
"github.com/hanwen/go-fuse/benchmark"
"log"
"os"
"runtime"
)
...
...
@@ -24,7 +25,7 @@ func main() {
filename
:=
flag
.
Args
()[
0
]
f
,
err
:=
os
.
Open
(
filename
)
if
err
!=
nil
{
panic
(
"err"
+
err
.
String
()
)
log
.
Panicf
(
"Open: %v"
,
err
)
}
reader
:=
bufio
.
NewReader
(
f
)
...
...
fuse/cache_test.go
View file @
eb06cb23
...
...
@@ -163,7 +163,7 @@ func TestGetAttrRace(t *testing.T) {
n
:=
100
wg
.
Add
(
n
)
var
statErr
os
.
E
rror
var
statErr
e
rror
for
i
:=
0
;
i
<
n
;
i
++
{
go
func
()
{
defer
wg
.
Done
()
...
...
fuse/files.go
View file @
eb06cb23
...
...
@@ -2,6 +2,7 @@ package fuse
import
(
"fmt"
"io"
"os"
"syscall"
)
...
...
@@ -97,7 +98,7 @@ func (me *LoopbackFile) Read(input *ReadIn, buffers BufferPool) ([]byte, Status)
n
,
err
:=
me
.
File
.
ReadAt
(
slice
,
int64
(
input
.
Offset
))
// TODO - fix Go ndocumentation.
if
err
==
os
.
EOF
{
if
err
==
io
.
EOF
{
err
=
nil
}
return
slice
[
:
n
],
OsErrorToErrno
(
err
)
...
...
fuse/fuse.go
View file @
eb06cb23
package
fuse
import
(
"log"
"os"
)
import
"log"
var
_
=
log
.
Println
func
MountNodeFileSystem
(
mountpoint
string
,
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
(
*
MountState
,
*
FileSystemConnector
,
os
.
E
rror
)
{
func
MountNodeFileSystem
(
mountpoint
string
,
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
(
*
MountState
,
*
FileSystemConnector
,
e
rror
)
{
conn
:=
NewFileSystemConnector
(
nodeFs
,
opts
)
mountState
:=
NewMountState
(
conn
)
err
:=
mountState
.
Mount
(
mountpoint
,
nil
)
...
...
@@ -17,7 +14,7 @@ func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSys
return
mountState
,
conn
,
nil
}
func
MountPathFileSystem
(
mountpoint
string
,
pathFs
FileSystem
,
opts
*
FileSystemOptions
)
(
*
MountState
,
*
FileSystemConnector
,
os
.
E
rror
)
{
func
MountPathFileSystem
(
mountpoint
string
,
pathFs
FileSystem
,
opts
*
FileSystemOptions
)
(
*
MountState
,
*
FileSystemConnector
,
e
rror
)
{
nfs
:=
NewPathNodeFs
(
pathFs
,
nil
)
return
MountNodeFileSystem
(
mountpoint
,
nfs
,
opts
)
}
fuse/loopback.go
View file @
eb06cb23
...
...
@@ -6,6 +6,7 @@ package fuse
import
(
"fmt"
"io"
"log"
"os"
"path/filepath"
...
...
@@ -34,7 +35,7 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string {
func
(
me
*
LoopbackFileSystem
)
GetAttr
(
name
string
,
context
*
Context
)
(
fi
*
os
.
FileInfo
,
code
Status
)
{
fullPath
:=
me
.
GetPath
(
name
)
var
err
os
.
E
rror
=
nil
var
err
e
rror
=
nil
if
name
==
""
{
// When GetAttr is called for the toplevel directory, we always want
// to look through symlinks.
...
...
@@ -66,7 +67,7 @@ func (me *LoopbackFileSystem) OpenDir(name string, context *Context) (stream cha
Mode
:
infos
[
i
]
.
Mode
,
}
}
if
len
(
infos
)
<
want
||
err
==
os
.
EOF
{
if
len
(
infos
)
<
want
||
err
==
io
.
EOF
{
break
}
if
err
!=
nil
{
...
...
fuse/loopback_test.go
View file @
eb06cb23
...
...
@@ -4,6 +4,7 @@ import (
"bytes"
"exec"
"fmt"
"io"
"io/ioutil"
"log"
"os"
...
...
@@ -52,7 +53,7 @@ func NewTestCase(t *testing.T) *testCase {
const
name
string
=
"hello.txt"
const
subdir
string
=
"subdir"
var
err
os
.
E
rror
var
err
e
rror
me
.
tmpDir
,
err
=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
CheckSuccess
(
err
)
me
.
orig
=
me
.
tmpDir
+
"/orig"
...
...
@@ -567,7 +568,7 @@ func TestLargeRead(t *testing.T) {
total
:=
0
for
{
m
,
err
:=
g
.
Read
(
readSlice
)
if
m
==
0
&&
err
==
os
.
EOF
{
if
m
==
0
&&
err
==
io
.
EOF
{
break
}
CheckSuccess
(
err
)
...
...
@@ -629,7 +630,7 @@ func TestLargeDirRead(t *testing.T) {
readSet
:=
make
(
map
[
string
]
bool
)
for
{
namesRead
,
err
:=
dir
.
Readdirnames
(
200
)
if
len
(
namesRead
)
==
0
||
err
==
os
.
EOF
{
if
len
(
namesRead
)
==
0
||
err
==
io
.
EOF
{
break
}
CheckSuccess
(
err
)
...
...
fuse/misc.go
View file @
eb06cb23
...
...
@@ -31,7 +31,7 @@ func (code Status) Ok() bool {
}
// Convert os.Error back to Errno based errors.
func
OsErrorToErrno
(
err
os
.
E
rror
)
Status
{
func
OsErrorToErrno
(
err
e
rror
)
Status
{
if
err
!=
nil
{
switch
t
:=
err
.
(
type
)
{
case
os
.
Errno
:
...
...
@@ -39,9 +39,9 @@ func OsErrorToErrno(err os.Error) Status {
case
*
os
.
SyscallError
:
return
Status
(
t
.
Errno
)
case
*
os
.
PathError
:
return
OsErrorToErrno
(
t
.
Err
or
)
return
OsErrorToErrno
(
t
.
Err
)
case
*
os
.
LinkError
:
return
OsErrorToErrno
(
t
.
Err
or
)
return
OsErrorToErrno
(
t
.
Err
)
default
:
log
.
Println
(
"can't convert error type:"
,
err
)
return
ENOSYS
...
...
@@ -84,7 +84,7 @@ func writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, errno int) {
return
int
(
n1
),
int
(
e1
)
}
func
Writev
(
fd
int
,
packet
[][]
byte
)
(
n
int
,
err
os
.
E
rror
)
{
func
Writev
(
fd
int
,
packet
[][]
byte
)
(
n
int
,
err
e
rror
)
{
iovecs
:=
make
([]
syscall
.
Iovec
,
0
,
len
(
packet
))
for
_
,
v
:=
range
packet
{
...
...
@@ -113,7 +113,7 @@ func ModeToType(mode uint32) uint32 {
return
(
mode
&
0170000
)
>>
12
}
func
CheckSuccess
(
e
os
.
E
rror
)
{
func
CheckSuccess
(
e
e
rror
)
{
if
e
!=
nil
{
panic
(
fmt
.
Sprintf
(
"Unexpected error: %v"
,
e
))
}
...
...
fuse/mount.go
View file @
eb06cb23
...
...
@@ -2,6 +2,7 @@ package fuse
// Written with a look to http://ptspts.blogspot.com/2009/11/fuse-protocol-tutorial-for-linux-26.html
import
(
"errors"
"exec"
"fmt"
"log"
...
...
@@ -14,7 +15,7 @@ import (
var
fusermountBinary
string
var
umountBinary
string
func
Socketpair
(
network
string
)
(
l
,
r
*
os
.
File
,
err
os
.
E
rror
)
{
func
Socketpair
(
network
string
)
(
l
,
r
*
os
.
File
,
err
e
rror
)
{
var
domain
int
var
typ
int
switch
network
{
...
...
@@ -38,7 +39,7 @@ func Socketpair(network string) (l, r *os.File, err os.Error) {
// Create a FUSE FS on the specified mount point. The returned
// mount point is always absolute.
func
mount
(
mountPoint
string
,
options
string
)
(
f
*
os
.
File
,
finalMountPoint
string
,
err
os
.
E
rror
)
{
func
mount
(
mountPoint
string
,
options
string
)
(
f
*
os
.
File
,
finalMountPoint
string
,
err
e
rror
)
{
local
,
remote
,
err
:=
Socketpair
(
"unixgram"
)
if
err
!=
nil
{
return
...
...
@@ -77,7 +78,7 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
return
}
if
w
.
ExitStatus
()
!=
0
{
err
=
os
.
NewError
(
fmt
.
Sprintf
(
"fusermount exited with code %d
\n
"
,
w
.
ExitStatus
()))
err
=
errors
.
New
(
fmt
.
Sprintf
(
"fusermount exited with code %d
\n
"
,
w
.
ExitStatus
()))
return
}
...
...
@@ -86,7 +87,7 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
return
}
func
privilegedUnmount
(
mountPoint
string
)
os
.
E
rror
{
func
privilegedUnmount
(
mountPoint
string
)
e
rror
{
dir
,
_
:=
filepath
.
Split
(
mountPoint
)
proc
,
err
:=
os
.
StartProcess
(
umountBinary
,
[]
string
{
umountBinary
,
mountPoint
},
...
...
@@ -96,12 +97,12 @@ func privilegedUnmount(mountPoint string) os.Error {
}
w
,
err
:=
os
.
Wait
(
proc
.
Pid
,
0
)
if
w
.
ExitStatus
()
!=
0
{
return
os
.
NewError
(
fmt
.
Sprintf
(
"umount exited with code %d
\n
"
,
w
.
ExitStatus
()))
return
errors
.
New
(
fmt
.
Sprintf
(
"umount exited with code %d
\n
"
,
w
.
ExitStatus
()))
}
return
err
}
func
unmount
(
mountPoint
string
)
(
err
os
.
E
rror
)
{
func
unmount
(
mountPoint
string
)
(
err
e
rror
)
{
if
os
.
Geteuid
()
==
0
{
return
privilegedUnmount
(
mountPoint
)
}
...
...
@@ -117,12 +118,12 @@ func unmount(mountPoint string) (err os.Error) {
return
}
if
w
.
ExitStatus
()
!=
0
{
return
os
.
NewError
(
fmt
.
Sprintf
(
"fusermount -u exited with code %d
\n
"
,
w
.
ExitStatus
()))
return
errors
.
New
(
fmt
.
Sprintf
(
"fusermount -u exited with code %d
\n
"
,
w
.
ExitStatus
()))
}
return
}
func
getConnection
(
local
*
os
.
File
)
(
f
*
os
.
File
,
err
os
.
E
rror
)
{
func
getConnection
(
local
*
os
.
File
)
(
f
*
os
.
File
,
err
e
rror
)
{
var
data
[
4
]
byte
control
:=
make
([]
byte
,
4
*
256
)
...
...
@@ -138,15 +139,15 @@ func getConnection(local *os.File) (f *os.File, err os.Error) {
fd
:=
*
(
*
int32
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
control
[
0
]))
+
syscall
.
SizeofCmsghdr
))
if
message
.
Type
!=
1
{
err
=
os
.
NewError
(
fmt
.
Sprintf
(
"getConnection: recvmsg returned wrong control type: %d"
,
message
.
Type
))
err
=
errors
.
New
(
fmt
.
Sprintf
(
"getConnection: recvmsg returned wrong control type: %d"
,
message
.
Type
))
return
}
if
oobn
<=
syscall
.
SizeofCmsghdr
{
err
=
os
.
NewError
(
fmt
.
Sprintf
(
"getConnection: too short control message. Length: %d"
,
oobn
))
err
=
errors
.
New
(
fmt
.
Sprintf
(
"getConnection: too short control message. Length: %d"
,
oobn
))
return
}
if
fd
<
0
{
err
=
os
.
NewError
(
fmt
.
Sprintf
(
"getConnection: fd < 0: %d"
,
fd
))
err
=
errors
.
New
(
fmt
.
Sprintf
(
"getConnection: fd < 0: %d"
,
fd
))
return
}
f
=
os
.
NewFile
(
int
(
fd
),
"<fuseConnection>"
)
...
...
@@ -154,7 +155,7 @@ func getConnection(local *os.File) (f *os.File, err os.Error) {
}
func
init
()
{
var
err
os
.
E
rror
var
err
e
rror
fusermountBinary
,
err
=
exec
.
LookPath
(
"fusermount"
)
if
err
!=
nil
{
log
.
Fatal
(
"Could not find fusermount binary: %v"
,
err
)
...
...
fuse/mountstate.go
View file @
eb06cb23
...
...
@@ -48,7 +48,7 @@ func (me *MountState) MountPoint() string {
}
// Mount filesystem on mountPoint.
func
(
me
*
MountState
)
Mount
(
mountPoint
string
,
opts
*
MountOptions
)
os
.
E
rror
{
func
(
me
*
MountState
)
Mount
(
mountPoint
string
,
opts
*
MountOptions
)
e
rror
{
if
opts
==
nil
{
opts
=
&
MountOptions
{
MaxBackground
:
_DEFAULT_BACKGROUND_TASKS
,
...
...
@@ -87,7 +87,7 @@ func (me *MountState) SetRecordStatistics(record bool) {
}
}
func
(
me
*
MountState
)
Unmount
()
os
.
E
rror
{
func
(
me
*
MountState
)
Unmount
()
e
rror
{
// Todo: flush/release all files/dirs?
err
:=
unmount
(
me
.
mountPoint
)
if
err
==
nil
{
...
...
@@ -125,7 +125,7 @@ func (me *MountState) newRequest() *request {
}
}
func
(
me
*
MountState
)
readRequest
(
req
*
request
)
os
.
E
rror
{
func
(
me
*
MountState
)
readRequest
(
req
*
request
)
e
rror
{
n
,
err
:=
me
.
mountFile
.
Read
(
req
.
inputBuf
)
// If we start timing before the read, we may take into
// account waiting for input into the timing.
...
...
@@ -246,7 +246,7 @@ func (me *MountState) write(req *request) Status {
return
OK
}
var
err
os
.
E
rror
var
err
e
rror
if
req
.
flatData
==
nil
{
_
,
err
=
me
.
mountFile
.
Write
(
req
.
outHeaderBytes
)
}
else
{
...
...
fuse/notify_test.go
View file @
eb06cb23
...
...
@@ -43,7 +43,7 @@ type NotifyTest struct {
func
NewNotifyTest
()
*
NotifyTest
{
me
:=
&
NotifyTest
{}
me
.
fs
=
&
NotifyFs
{}
var
err
os
.
E
rror
var
err
e
rror
me
.
dir
,
err
=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
CheckSuccess
(
err
)
entryTtl
:=
0.1
...
...
unionfs/autounion.go
View file @
eb06cb23
...
...
@@ -163,7 +163,7 @@ func (me *AutoUnionFs) getRoots(path string) []string {
return
nil
}
func
(
me
*
AutoUnionFs
)
visit
(
path
string
,
fi
*
os
.
FileInfo
,
err
os
.
Error
)
os
.
E
rror
{
func
(
me
*
AutoUnionFs
)
visit
(
path
string
,
fi
*
os
.
FileInfo
,
err
error
)
e
rror
{
if
fi
.
IsDirectory
()
{
roots
:=
me
.
getRoots
(
path
)
if
roots
!=
nil
{
...
...
@@ -185,7 +185,7 @@ func (me *AutoUnionFs) updateKnownFses() {
dir
,
_
=
os
.
Stat
(
path
)
me
.
visit
(
path
,
dir
,
nil
)
filepath
.
Walk
(
path
,
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
os
.
Error
)
os
.
E
rror
{
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
error
)
e
rror
{
return
me
.
visit
(
path
,
fi
,
err
)
})
}
...
...
unionfs/create.go
View file @
eb06cb23
...
...
@@ -5,7 +5,7 @@ import (
"os"
)
func
NewUnionFsFromRoots
(
roots
[]
string
,
opts
*
UnionFsOptions
,
roCaching
bool
)
(
*
UnionFs
,
os
.
E
rror
)
{
func
NewUnionFsFromRoots
(
roots
[]
string
,
opts
*
UnionFsOptions
,
roCaching
bool
)
(
*
UnionFs
,
e
rror
)
{
fses
:=
make
([]
fuse
.
FileSystem
,
0
)
for
i
,
r
:=
range
roots
{
var
fs
fuse
.
FileSystem
...
...
unionfs/unionfs_test.go
View file @
eb06cb23
...
...
@@ -30,7 +30,7 @@ var testOpts = UnionFsOptions{
func
freezeRo
(
dir
string
)
{
err
:=
filepath
.
Walk
(
dir
,
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
os
.
Error
)
os
.
E
rror
{
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
error
)
e
rror
{
return
os
.
Chmod
(
path
,
(
fi
.
Mode
&
0777
)
&^
0222
)
})
CheckSuccess
(
err
)
...
...
@@ -772,7 +772,7 @@ func TestUnionFsRmRf(t *testing.T) {
}
}
func
Readdirnames
(
dir
string
)
([]
string
,
os
.
E
rror
)
{
func
Readdirnames
(
dir
string
)
([]
string
,
e
rror
)
{
f
,
err
:=
os
.
Open
(
dir
)
if
err
!=
nil
{
return
nil
,
err
...
...
zipfs/tarfs.go
View file @
eb06cb23
...
...
@@ -51,7 +51,7 @@ func NewTarTree(r io.Reader) map[string]MemFile {
var
longName
*
string
for
{
hdr
,
err
:=
tr
.
Next
()
if
err
==
os
.
EOF
{
if
err
==
io
.
EOF
{
// end of tar archive
break
}
...
...
@@ -87,7 +87,7 @@ func NewTarTree(r io.Reader) map[string]MemFile {
return
files
}
func
NewTarCompressedTree
(
name
string
,
format
string
)
(
map
[
string
]
MemFile
,
os
.
E
rror
)
{
func
NewTarCompressedTree
(
name
string
,
format
string
)
(
map
[
string
]
MemFile
,
e
rror
)
{
f
,
err
:=
os
.
Open
(
name
)
if
err
!=
nil
{
return
nil
,
err
...
...
zipfs/zipfs.go
View file @
eb06cb23
...
...
@@ -3,6 +3,7 @@ package zipfs
import
(
"archive/zip"
"bytes"
"errors"
"fmt"
"github.com/hanwen/go-fuse/fuse"
"io"
...
...
@@ -42,7 +43,7 @@ func (me *ZipFile) Data() []byte {
}
// NewZipTree creates a new file-system for the zip file named name.
func
NewZipTree
(
name
string
)
(
map
[
string
]
MemFile
,
os
.
E
rror
)
{
func
NewZipTree
(
name
string
)
(
map
[
string
]
MemFile
,
e
rror
)
{
r
,
err
:=
zip
.
OpenReader
(
name
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -61,7 +62,7 @@ func NewZipTree(name string) (map[string]MemFile, os.Error) {
return
out
,
nil
}
func
NewArchiveFileSystem
(
name
string
)
(
mfs
*
MemTreeFs
,
err
os
.
E
rror
)
{
func
NewArchiveFileSystem
(
name
string
)
(
mfs
*
MemTreeFs
,
err
e
rror
)
{
mfs
=
&
MemTreeFs
{}
if
strings
.
HasSuffix
(
name
,
".zip"
)
{
mfs
.
files
,
err
=
NewZipTree
(
name
)
...
...
@@ -84,7 +85,7 @@ func NewArchiveFileSystem(name string) (mfs *MemTreeFs, err os.Error) {
}
if
mfs
.
files
==
nil
{
return
nil
,
os
.
NewError
(
fmt
.
Sprintf
(
"Unknown type for %v"
,
name
))
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"Unknown type for %v"
,
name
))
}
return
mfs
,
nil
...
...
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