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
13e7ad2c
Commit
13e7ad2c
authored
May 18, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NewUnionFsFromRoots(), which automatically mounts zip/tar archives.
parent
ef9991c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
15 deletions
+48
-15
example/unionfs/main.go
example/unionfs/main.go
+6
-7
unionfs/Makefile
unionfs/Makefile
+2
-1
unionfs/autounion.go
unionfs/autounion.go
+5
-7
unionfs/create.go
unionfs/create.go
+35
-0
No files found.
example/unionfs/main.go
View file @
13e7ad2c
...
...
@@ -3,6 +3,7 @@ package main
import
(
"flag"
"fmt"
"log"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/unionfs"
"os"
...
...
@@ -28,16 +29,14 @@ func main() {
DeletionDirName
:
*
deldirname
,
}
fses
:=
make
([]
fuse
.
FileSystem
,
0
)
for
_
,
r
:=
range
flag
.
Args
()[
1
:
]
{
fses
=
append
(
fses
,
fuse
.
NewLoopbackFileSystem
(
r
))
ufs
,
err
:=
unionfs
.
NewUnionFsFromRoots
(
flag
.
Args
()[
1
:
],
&
ufsOptions
)
if
err
!=
nil
{
log
.
Fatal
(
"Cannot create UnionFs"
,
err
)
os
.
Exit
(
1
)
}
ufs
:=
unionfs
.
NewUnionFs
(
"unionfs"
,
fses
,
ufsOptions
)
mountState
,
_
,
err
:=
fuse
.
MountFileSystem
(
flag
.
Arg
(
0
),
ufs
,
nil
)
if
err
!=
nil
{
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
os
.
Exit
(
1
)
log
.
Fatal
(
"Mount fail:"
,
err
)
}
mountState
.
Debug
=
*
debug
...
...
unionfs/Makefile
View file @
13e7ad2c
...
...
@@ -7,7 +7,8 @@ GOFILES=unionfs.go \
timedcache.go
\
cachingfs.go
\
autounion.go
\
create.go
DEPS
=
../fuse
DEPS
=
../fuse
../zipfs
include
$(GOROOT)/src/Make.pkg
unionfs/autounion.go
View file @
13e7ad2c
...
...
@@ -93,15 +93,13 @@ func (me *AutoUnionFs) createFs(name string, roots []string) (*UnionFs, fuse.Sta
return
gofs
,
fuse
.
OK
}
fses
:=
make
([]
fuse
.
FileSystem
,
0
)
for
_
,
r
:=
range
roots
{
fses
=
append
(
fses
,
fuse
.
NewLoopbackFileSystem
(
r
))
ufs
,
err
:=
NewUnionFsFromRoots
(
roots
,
&
me
.
options
.
UnionFsOptions
)
if
err
!=
nil
{
log
.
Println
(
"Could not create UnionFs:"
,
err
)
return
nil
,
fuse
.
EPERM
}
identifier
:=
fmt
.
Sprintf
(
"%v"
,
roots
)
log
.
Println
(
"Adding UnionFs for"
,
identifier
)
gofs
=
NewUnionFs
(
identifier
,
fses
,
me
.
options
.
UnionFsOptions
)
me
.
knownFileSystems
[
name
]
=
go
fs
me
.
knownFileSystems
[
name
]
=
u
fs
me
.
nameRootMap
[
name
]
=
roots
[
0
]
return
gofs
,
fuse
.
OK
...
...
unionfs/create.go
0 → 100644
View file @
13e7ad2c
package
unionfs
import
(
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/zipfs"
"log"
"os"
)
func
NewUnionFsFromRoots
(
roots
[]
string
,
opts
*
UnionFsOptions
)
(
*
UnionFs
,
os
.
Error
)
{
fses
:=
make
([]
fuse
.
FileSystem
,
0
)
for
_
,
r
:=
range
roots
{
var
fs
fuse
.
FileSystem
fi
,
err
:=
os
.
Stat
(
r
)
if
err
!=
nil
{
return
nil
,
err
}
if
fi
.
IsDirectory
()
{
fs
=
fuse
.
NewLoopbackFileSystem
(
r
)
}
if
fs
==
nil
{
fs
,
err
=
zipfs
.
NewArchiveFileSystem
(
r
)
}
if
fs
==
nil
{
return
nil
,
err
}
fses
=
append
(
fses
,
fs
)
}
identifier
:=
fmt
.
Sprintf
(
"%v"
,
roots
)
log
.
Println
(
"Adding UnionFs for"
,
identifier
)
return
NewUnionFs
(
identifier
,
fses
,
*
opts
),
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