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
fdcdc774
Commit
fdcdc774
authored
May 26, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file to allow explicitly rescans: /config/.scan_config.
parent
129d3141
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
4 deletions
+55
-4
unionfs/autounion.go
unionfs/autounion.go
+24
-4
unionfs/autounion_test.go
unionfs/autounion_test.go
+31
-0
No files found.
unionfs/autounion.go
View file @
fdcdc774
...
...
@@ -44,6 +44,7 @@ const (
_CONFIG
=
"config"
_ROOT
=
"root"
_VERSION
=
"gounionfs_version"
_SCAN_CONFIG
=
".scan_config"
)
func
NewAutoUnionFs
(
directory
string
,
options
AutoUnionFsOptions
)
*
AutoUnionFs
{
...
...
@@ -129,7 +130,7 @@ func (me *AutoUnionFs) rmFs(name string) (code fuse.Status) {
}
func
(
me
*
AutoUnionFs
)
addFs
(
name
string
,
roots
[]
string
)
(
code
fuse
.
Status
)
{
if
name
==
_CONFIG
||
name
==
_STATUS
{
if
name
==
_CONFIG
||
name
==
_STATUS
||
name
==
_SCAN_CONFIG
{
log
.
Println
(
"Illegal name for overlay"
,
roots
)
return
fuse
.
EINVAL
}
...
...
@@ -222,7 +223,7 @@ func (me *AutoUnionFs) Unlink(path string) (code fuse.Status) {
return
fuse
.
EPERM
}
if
comps
[
0
]
==
_CONFIG
{
if
comps
[
0
]
==
_CONFIG
&&
comps
[
1
]
!=
_SCAN_CONFIG
{
code
=
me
.
rmFs
(
comps
[
1
])
}
else
{
code
=
fuse
.
ENOENT
...
...
@@ -257,7 +258,13 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
}
return
a
,
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_CONFIG
,
_SCAN_CONFIG
)
{
a
:=
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFREG
|
0644
,
}
return
a
,
fuse
.
OK
}
comps
:=
strings
.
Split
(
path
,
filepath
.
SeparatorString
,
-
1
)
if
len
(
comps
)
>
1
&&
comps
[
0
]
==
_CONFIG
{
...
...
@@ -298,14 +305,27 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
}
func
(
me
*
AutoUnionFs
)
Open
(
path
string
,
flags
uint32
)
(
fuse
.
File
,
fuse
.
Status
)
{
if
path
==
_STATUS
+
"/"
+
_VERSION
{
if
path
==
filepath
.
Join
(
_STATUS
,
_VERSION
)
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
return
nil
,
fuse
.
EPERM
}
return
fuse
.
NewReadOnlyFile
([]
byte
(
fuse
.
Version
())),
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_CONFIG
,
_SCAN_CONFIG
)
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
me
.
updateKnownFses
()
}
return
fuse
.
NewDevNullFile
(),
fuse
.
OK
}
return
nil
,
fuse
.
ENOENT
}
func
(
me
*
AutoUnionFs
)
Truncate
(
name
string
,
offset
uint64
)
(
code
fuse
.
Status
)
{
if
name
!=
filepath
.
Join
(
_CONFIG
,
_SCAN_CONFIG
)
{
log
.
Println
(
"Huh? Truncating unsupported write file"
,
name
)
return
fuse
.
EPERM
}
return
fuse
.
OK
}
func
(
me
*
AutoUnionFs
)
OpenDir
(
name
string
)
(
stream
chan
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
switch
name
{
...
...
unionfs/autounion_test.go
View file @
fdcdc774
...
...
@@ -102,6 +102,37 @@ func TestAutoFsSymlink(t *testing.T) {
CheckSuccess
(
err
)
}
func
TestExplicitScan
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setup
(
t
)
defer
clean
()
err
:=
os
.
Mkdir
(
wd
+
"/store/backing1"
,
0755
)
CheckSuccess
(
err
)
os
.
Symlink
(
wd
+
"/ro"
,
wd
+
"/store/backing1/READONLY"
)
CheckSuccess
(
err
)
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/backing1"
)
if
fi
!=
nil
{
t
.
Error
(
"Should not have file:"
,
fi
)
}
scan
:=
wd
+
"/mount/config/"
+
_SCAN_CONFIG
_
,
err
=
os
.
Lstat
(
scan
)
if
err
!=
nil
{
t
.
Error
(
".scan_config missing:"
,
err
)
}
err
=
ioutil
.
WriteFile
(
scan
,
[]
byte
(
"something"
),
0644
)
if
err
!=
nil
{
t
.
Error
(
"error writing:"
,
err
)
}
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/backing1"
)
if
err
!=
nil
{
t
.
Error
(
"Should have workspace backing1:"
,
err
)
}
}
func
TestCreationChecks
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setup
(
t
)
defer
clean
()
...
...
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