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
ec5217de
Commit
ec5217de
authored
Apr 29, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Rmdir and Mkdir to UnionFs.
parent
8b62c828
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
4 deletions
+56
-4
unionfs/unionfs.go
unionfs/unionfs.go
+43
-3
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+13
-1
No files found.
unionfs/unionfs.go
View file @
ec5217de
...
@@ -257,11 +257,51 @@ func (me *UnionFs) Promote(name string, src *fuse.LoopbackFileSystem) fuse.Statu
...
@@ -257,11 +257,51 @@ func (me *UnionFs) Promote(name string, src *fuse.LoopbackFileSystem) fuse.Statu
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Below: implement interface for a FileSystem.
// Below: implement interface for a FileSystem.
func
(
me
*
UnionFs
)
Rmdir
(
path
string
)
(
code
fuse
.
Status
)
{
r
:=
me
.
branchCache
.
Get
(
path
)
.
(
getBranchResult
)
if
r
.
code
!=
fuse
.
OK
{
return
r
.
code
}
if
r
.
attr
.
Mode
&
fuse
.
S_IFDIR
==
0
{
return
syscall
.
ENOTDIR
}
if
r
.
branch
>
0
{
stream
,
code
:=
me
.
fileSystems
[
r
.
branch
]
.
OpenDir
(
path
)
if
code
==
fuse
.
OK
{
_
,
ok
:=
<-
stream
if
ok
{
// TODO - should consume stream.
return
syscall
.
ENOTEMPTY
}
}
me
.
putDeletion
(
path
)
return
fuse
.
OK
}
code
=
me
.
fileSystems
[
0
]
.
Rmdir
(
path
)
if
code
!=
fuse
.
OK
{
return
code
}
r
=
me
.
branchCache
.
getDataNoCache
(
path
)
.
(
getBranchResult
)
if
r
.
branch
>
0
{
code
=
me
.
putDeletion
(
path
)
}
return
code
}
func
(
me
*
UnionFs
)
Mkdir
(
path
string
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
me
*
UnionFs
)
Mkdir
(
path
string
,
mode
uint32
)
(
code
fuse
.
Status
)
{
r
:=
me
.
branchCache
.
Get
(
path
)
.
(
getBranchResult
)
if
r
.
code
!=
fuse
.
ENOENT
{
return
syscall
.
EEXIST
}
code
=
me
.
fileSystems
[
0
]
.
Mkdir
(
path
,
mode
)
code
=
me
.
fileSystems
[
0
]
.
Mkdir
(
path
,
mode
)
if
code
==
fuse
.
OK
{
if
code
==
fuse
.
OK
{
go
me
.
removeDeletion
(
path
)
me
.
removeDeletion
(
path
)
me
.
branchCache
.
Set
(
path
,
getBranchResult
{
nil
,
fuse
.
OK
,
0
})
attr
:=
&
fuse
.
Attr
{
Mode
:
fuse
.
S_IFDIR
|
mode
,
}
me
.
branchCache
.
Set
(
path
,
getBranchResult
{
attr
,
fuse
.
OK
,
0
})
}
}
return
code
return
code
}
}
...
@@ -269,7 +309,7 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
...
@@ -269,7 +309,7 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
func
(
me
*
UnionFs
)
Symlink
(
pointedTo
string
,
linkName
string
)
(
code
fuse
.
Status
)
{
func
(
me
*
UnionFs
)
Symlink
(
pointedTo
string
,
linkName
string
)
(
code
fuse
.
Status
)
{
code
=
me
.
fileSystems
[
0
]
.
Symlink
(
pointedTo
,
linkName
)
code
=
me
.
fileSystems
[
0
]
.
Symlink
(
pointedTo
,
linkName
)
if
code
==
fuse
.
OK
{
if
code
==
fuse
.
OK
{
go
me
.
removeDeletion
(
linkName
)
me
.
removeDeletion
(
linkName
)
me
.
branchCache
.
Set
(
linkName
,
getBranchResult
{
nil
,
fuse
.
OK
,
0
})
me
.
branchCache
.
Set
(
linkName
,
getBranchResult
{
nil
,
fuse
.
OK
,
0
})
}
}
return
code
return
code
...
...
unionfs/unionfs_test.go
View file @
ec5217de
...
@@ -43,7 +43,7 @@ func setup(t *testing.T) (workdir string, state *fuse.MountState) {
...
@@ -43,7 +43,7 @@ func setup(t *testing.T) (workdir string, state *fuse.MountState) {
connector
:=
fuse
.
NewFileSystemConnector
(
ufs
,
nil
)
connector
:=
fuse
.
NewFileSystemConnector
(
ufs
,
nil
)
state
=
fuse
.
NewMountState
(
connector
)
state
=
fuse
.
NewMountState
(
connector
)
state
.
Mount
(
wd
+
"/mount"
)
state
.
Mount
(
wd
+
"/mount"
)
//
state.Debug = true
state
.
Debug
=
true
go
state
.
Loop
(
false
)
go
state
.
Loop
(
false
)
return
wd
,
state
return
wd
,
state
...
@@ -237,6 +237,18 @@ func TestPromote(t *testing.T) {
...
@@ -237,6 +237,18 @@ func TestPromote(t *testing.T) {
writeToFile
(
wd
+
"/mount/subdir/file"
,
"other-content"
,
false
)
writeToFile
(
wd
+
"/mount/subdir/file"
,
"other-content"
,
false
)
}
}
func
TestMkdir
(
t
*
testing
.
T
)
{
wd
,
state
:=
setup
(
t
)
defer
state
.
Unmount
()
dirname
:=
wd
+
"/mount/subdir"
err
:=
os
.
Mkdir
(
dirname
,
0755
)
CheckSuccess
(
err
)
err
=
os
.
Remove
(
dirname
)
CheckSuccess
(
err
)
}
func
TestRename
(
t
*
testing
.
T
)
{
func
TestRename
(
t
*
testing
.
T
)
{
type
Config
struct
{
type
Config
struct
{
f1_ro
bool
f1_ro
bool
...
...
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