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
b094739d
Commit
b094739d
authored
Apr 25, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameterize autounion.go; use "root" rather than "autobase".
parent
7fa96673
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
unionfs/autounion.go
unionfs/autounion.go
+23
-15
No files found.
unionfs/autounion.go
View file @
b094739d
...
@@ -33,6 +33,14 @@ type AutoUnionFsOptions struct {
...
@@ -33,6 +33,14 @@ type AutoUnionFsOptions struct {
UnionFsOptions
UnionFsOptions
}
}
const
(
_READONLY
=
"READONLY"
_STATUS
=
"status"
_CONFIG
=
"config"
_ROOT
=
"root"
_VERSION
=
"gounionfs_version"
)
func
NewAutoUnionFs
(
directory
string
,
options
AutoUnionFsOptions
)
*
AutoUnionFs
{
func
NewAutoUnionFs
(
directory
string
,
options
AutoUnionFsOptions
)
*
AutoUnionFs
{
a
:=
new
(
AutoUnionFs
)
a
:=
new
(
AutoUnionFs
)
a
.
knownFileSystems
=
make
(
map
[
string
]
*
UnionFs
)
a
.
knownFileSystems
=
make
(
map
[
string
]
*
UnionFs
)
...
@@ -51,7 +59,7 @@ func (me *AutoUnionFs) addFs(roots []string) {
...
@@ -51,7 +59,7 @@ func (me *AutoUnionFs) addFs(roots []string) {
relative
:=
strings
.
TrimLeft
(
strings
.
Replace
(
roots
[
0
],
me
.
root
,
""
,
-
1
),
"/"
)
relative
:=
strings
.
TrimLeft
(
strings
.
Replace
(
roots
[
0
],
me
.
root
,
""
,
-
1
),
"/"
)
name
:=
strings
.
Replace
(
relative
,
"/"
,
"-"
,
-
1
)
name
:=
strings
.
Replace
(
relative
,
"/"
,
"-"
,
-
1
)
if
name
==
"config"
||
name
==
"status"
{
if
name
==
_CONFIG
||
name
==
_STATUS
{
log
.
Println
(
"Illegal name for overlay"
,
roots
)
log
.
Println
(
"Illegal name for overlay"
,
roots
)
return
return
}
}
...
@@ -72,7 +80,7 @@ func (me *AutoUnionFs) addFs(roots []string) {
...
@@ -72,7 +80,7 @@ func (me *AutoUnionFs) addFs(roots []string) {
// TODO - should hide these methods.
// TODO - should hide these methods.
func
(
me
*
AutoUnionFs
)
VisitDir
(
path
string
,
f
*
os
.
FileInfo
)
bool
{
func
(
me
*
AutoUnionFs
)
VisitDir
(
path
string
,
f
*
os
.
FileInfo
)
bool
{
ro
:=
filepath
.
Join
(
path
,
"READONLY"
)
ro
:=
filepath
.
Join
(
path
,
_READONLY
)
fi
,
err
:=
os
.
Lstat
(
ro
)
fi
,
err
:=
os
.
Lstat
(
ro
)
if
err
==
nil
&&
fi
.
IsSymlink
()
{
if
err
==
nil
&&
fi
.
IsSymlink
()
{
// TODO - should recurse and chain all READONLYs
// TODO - should recurse and chain all READONLYs
...
@@ -93,11 +101,11 @@ func (me *AutoUnionFs) updateKnownFses() {
...
@@ -93,11 +101,11 @@ func (me *AutoUnionFs) updateKnownFses() {
func
(
me
*
AutoUnionFs
)
Readlink
(
path
string
)
(
out
string
,
code
fuse
.
Status
)
{
func
(
me
*
AutoUnionFs
)
Readlink
(
path
string
)
(
out
string
,
code
fuse
.
Status
)
{
comps
:=
strings
.
Split
(
path
,
filepath
.
SeparatorString
,
-
1
)
comps
:=
strings
.
Split
(
path
,
filepath
.
SeparatorString
,
-
1
)
if
comps
[
0
]
==
"status"
&&
comps
[
1
]
==
"autobase"
{
if
comps
[
0
]
==
_STATUS
&&
comps
[
1
]
==
_ROOT
{
return
me
.
root
,
fuse
.
OK
return
me
.
root
,
fuse
.
OK
}
}
if
comps
[
0
]
!=
"config"
{
if
comps
[
0
]
!=
_CONFIG
{
return
""
,
fuse
.
ENOENT
return
""
,
fuse
.
ENOENT
}
}
name
:=
comps
[
1
]
name
:=
comps
[
1
]
...
@@ -111,21 +119,21 @@ func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
...
@@ -111,21 +119,21 @@ func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
}
}
func
(
me
*
AutoUnionFs
)
GetAttr
(
path
string
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
func
(
me
*
AutoUnionFs
)
GetAttr
(
path
string
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
if
path
==
""
||
path
==
"config"
||
path
==
"status"
{
if
path
==
""
||
path
==
_CONFIG
||
path
==
_STATUS
{
a
:=
&
fuse
.
Attr
{
a
:=
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
0755
,
Mode
:
fuse
.
S_IFDIR
|
0755
,
}
}
return
a
,
fuse
.
OK
return
a
,
fuse
.
OK
}
}
if
path
==
"status/gounionfs_version"
{
if
path
==
filepath
.
Join
(
_STATUS
,
_VERSION
)
{
a
:=
&
fuse
.
Attr
{
a
:=
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFREG
|
0644
,
Mode
:
fuse
.
S_IFREG
|
0644
,
}
}
return
a
,
fuse
.
OK
return
a
,
fuse
.
OK
}
}
if
path
==
"status/autobase"
{
if
path
==
filepath
.
Join
(
_STATUS
,
_ROOT
)
{
a
:=
&
fuse
.
Attr
{
a
:=
&
fuse
.
Attr
{
Mode
:
syscall
.
S_IFLNK
|
0644
,
Mode
:
syscall
.
S_IFLNK
|
0644
,
}
}
...
@@ -136,7 +144,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
...
@@ -136,7 +144,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
me
.
lock
.
RLock
()
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
defer
me
.
lock
.
RUnlock
()
if
len
(
comps
)
>
1
&&
comps
[
0
]
==
"config"
{
if
len
(
comps
)
>
1
&&
comps
[
0
]
==
_CONFIG
{
fs
:=
me
.
knownFileSystems
[
comps
[
1
]]
fs
:=
me
.
knownFileSystems
[
comps
[
1
]]
if
fs
==
nil
{
if
fs
==
nil
{
...
@@ -161,11 +169,11 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
...
@@ -161,11 +169,11 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
func
(
me
*
AutoUnionFs
)
StatusDir
()
(
stream
chan
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
func
(
me
*
AutoUnionFs
)
StatusDir
()
(
stream
chan
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
stream
=
make
(
chan
fuse
.
DirEntry
,
10
)
stream
=
make
(
chan
fuse
.
DirEntry
,
10
)
stream
<-
fuse
.
DirEntry
{
stream
<-
fuse
.
DirEntry
{
Name
:
"gounionfs_version"
,
Name
:
_VERSION
,
Mode
:
fuse
.
S_IFREG
|
0644
,
Mode
:
fuse
.
S_IFREG
|
0644
,
}
}
stream
<-
fuse
.
DirEntry
{
stream
<-
fuse
.
DirEntry
{
Name
:
"autobase"
,
Name
:
_ROOT
,
Mode
:
syscall
.
S_IFLNK
|
0644
,
Mode
:
syscall
.
S_IFLNK
|
0644
,
}
}
...
@@ -175,9 +183,9 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
...
@@ -175,9 +183,9 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
func
(
me
*
AutoUnionFs
)
OpenDir
(
name
string
)
(
stream
chan
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
func
(
me
*
AutoUnionFs
)
OpenDir
(
name
string
)
(
stream
chan
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
switch
name
{
switch
name
{
case
"status"
:
case
_STATUS
:
return
me
.
StatusDir
()
return
me
.
StatusDir
()
case
"config"
:
case
_CONFIG
:
me
.
updateKnownFses
()
me
.
updateKnownFses
()
case
"/"
:
case
"/"
:
name
=
""
name
=
""
...
@@ -192,7 +200,7 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
...
@@ -192,7 +200,7 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
stream
=
make
(
chan
fuse
.
DirEntry
,
len
(
me
.
knownFileSystems
)
+
5
)
stream
=
make
(
chan
fuse
.
DirEntry
,
len
(
me
.
knownFileSystems
)
+
5
)
for
k
,
_
:=
range
me
.
knownFileSystems
{
for
k
,
_
:=
range
me
.
knownFileSystems
{
mode
:=
fuse
.
S_IFDIR
|
0755
mode
:=
fuse
.
S_IFDIR
|
0755
if
name
==
"config"
{
if
name
==
_CONFIG
{
mode
=
syscall
.
S_IFLNK
|
0644
mode
=
syscall
.
S_IFLNK
|
0644
}
}
...
@@ -204,11 +212,11 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
...
@@ -204,11 +212,11 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
if
name
==
""
{
if
name
==
""
{
stream
<-
fuse
.
DirEntry
{
stream
<-
fuse
.
DirEntry
{
Name
:
"config"
,
Name
:
_CONFIG
,
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
}
}
stream
<-
fuse
.
DirEntry
{
stream
<-
fuse
.
DirEntry
{
Name
:
"status"
,
Name
:
_STATUS
,
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
}
}
}
}
...
...
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