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
5f92e2f1
Commit
5f92e2f1
authored
Sep 17, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make autounionfs debug runtime switchable.
parent
13019c9b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
unionfs/autounion.go
unionfs/autounion.go
+38
-1
No files found.
unionfs/autounion.go
View file @
5f92e2f1
...
...
@@ -56,6 +56,7 @@ const (
_STATUS
=
"status"
_CONFIG
=
"config"
_DEBUG
=
"debug"
_DEBUG_SETTING
=
"debug_setting"
_ROOT
=
"root"
_VERSION
=
"gounionfs_version"
_SCAN_CONFIG
=
".scan_config"
...
...
@@ -215,10 +216,16 @@ func (fs *AutoUnionFs) Readlink(path string, context *fuse.Context) (out string,
return
fs
.
root
,
fuse
.
OK
}
if
comps
[
0
]
==
_STATUS
&&
comps
[
1
]
==
_DEBUG_SETTING
&&
fs
.
hasDebug
()
{
return
"1"
,
fuse
.
OK
}
if
comps
[
0
]
!=
_CONFIG
{
return
""
,
fuse
.
ENOENT
}
name
:=
comps
[
1
]
fs
.
lock
.
RLock
()
defer
fs
.
lock
.
RUnlock
()
...
...
@@ -241,6 +248,11 @@ func (fs *AutoUnionFs) Symlink(pointedTo string, linkName string, context *fuse.
return
fuse
.
EPERM
}
if
comps
[
0
]
==
_STATUS
&&
comps
[
1
]
==
_DEBUG_SETTING
{
fs
.
SetDebug
(
true
)
return
fuse
.
OK
}
if
comps
[
0
]
==
_CONFIG
{
roots
:=
fs
.
getRoots
(
pointedTo
)
if
roots
==
nil
{
...
...
@@ -253,12 +265,29 @@ func (fs *AutoUnionFs) Symlink(pointedTo string, linkName string, context *fuse.
return
fuse
.
EPERM
}
func
(
fs
*
AutoUnionFs
)
SetDebug
(
b
bool
)
{
// Officially, this should use locking, but we don't care
// about race conditions here.
fs
.
nodeFs
.
Debug
=
b
fs
.
connector
.
Debug
=
b
fs
.
mountState
.
Debug
=
b
}
func
(
fs
*
AutoUnionFs
)
hasDebug
()
bool
{
return
fs
.
nodeFs
.
Debug
}
func
(
fs
*
AutoUnionFs
)
Unlink
(
path
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
comps
:=
strings
.
Split
(
path
,
"/"
)
if
len
(
comps
)
!=
2
{
return
fuse
.
EPERM
}
if
comps
[
0
]
==
_STATUS
&&
comps
[
1
]
==
_DEBUG_SETTING
{
fs
.
SetDebug
(
false
)
return
fuse
.
OK
}
if
comps
[
0
]
==
_CONFIG
&&
comps
[
1
]
!=
_SCAN_CONFIG
{
code
=
fs
.
rmFs
(
comps
[
1
])
}
else
{
...
...
@@ -280,6 +309,12 @@ func (fs *AutoUnionFs) GetAttr(path string, context *fuse.Context) (*fuse.Attr,
return
a
,
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_STATUS
,
_DEBUG_SETTING
)
&&
fs
.
hasDebug
()
{
return
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFLNK
|
0644
,
},
fuse
.
OK
}
if
path
==
filepath
.
Join
(
_STATUS
,
_VERSION
)
{
a
:=
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFREG
|
0644
,
...
...
@@ -334,7 +369,9 @@ func (fs *AutoUnionFs) StatusDir() (stream []fuse.DirEntry, status fuse.Status)
{
Name
:
_DEBUG
,
Mode
:
fuse
.
S_IFREG
|
0644
},
{
Name
:
_ROOT
,
Mode
:
syscall
.
S_IFLNK
|
0644
},
}
if
fs
.
hasDebug
()
{
stream
=
append
(
stream
,
fuse
.
DirEntry
{
Name
:
_DEBUG_SETTING
,
Mode
:
fuse
.
S_IFLNK
|
0644
})
}
return
stream
,
fuse
.
OK
}
...
...
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