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
5a4cfdc9
Commit
5a4cfdc9
authored
Apr 27, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UnionFs: Also create directories leading up to the file promoted.
parent
e15c2db5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
unionfs/unionfs.go
unionfs/unionfs.go
+26
-9
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+10
-0
No files found.
unionfs/unionfs.go
View file @
5a4cfdc9
...
...
@@ -219,6 +219,20 @@ func CopyFile(dstName, srcName string) (written int64, err os.Error) {
}
defer
src
.
Close
()
dir
,
_
:=
filepath
.
Split
(
dstName
)
fi
,
err
:=
os
.
Stat
(
dir
)
if
fi
!=
nil
&&
!
fi
.
IsDirectory
()
{
return
0
,
os
.
NewError
(
"Destination is not a directory."
)
}
if
err
!=
nil
{
// TODO - umask support.
err
=
os
.
MkdirAll
(
dir
,
0755
)
}
if
err
!=
nil
{
return
0
,
err
}
dst
,
err
:=
os
.
Create
(
dstName
)
if
err
!=
nil
{
return
...
...
@@ -228,13 +242,16 @@ func CopyFile(dstName, srcName string) (written int64, err os.Error) {
return
io
.
Copy
(
dst
,
src
)
}
func
(
me
*
UnionFs
)
Promote
(
name
string
,
src
*
fuse
.
LoopbackFileSystem
)
os
.
Error
{
func
(
me
*
UnionFs
)
Promote
(
name
string
,
src
*
fuse
.
LoopbackFileSystem
)
fuse
.
Status
{
writable
:=
me
.
branches
[
0
]
_
,
err
:=
CopyFile
(
writable
.
GetPath
(
name
),
src
.
GetPath
(
name
))
me
.
branchCache
.
Set
(
name
,
getBranchResult
{
nil
,
fuse
.
OK
,
0
})
if
err
!=
nil
{
log
.
Println
(
"promote error: "
,
name
,
err
.
String
())
return
fuse
.
EPERM
}
return
err
return
fuse
.
OK
}
////////////////////////////////////////////////////////////////
...
...
@@ -273,9 +290,9 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
if
oldMode
!=
mode
{
if
r
.
branch
>
0
{
err
:=
me
.
Promote
(
name
,
me
.
branches
[
r
.
branch
])
if
err
!=
nil
{
panic
(
"copy: "
+
err
.
String
())
code
:=
me
.
Promote
(
name
,
me
.
branches
[
r
.
branch
])
if
code
!=
fuse
.
OK
{
return
code
}
}
me
.
fileSystems
[
0
]
.
Chmod
(
name
,
mode
)
...
...
@@ -454,9 +471,9 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
branch
:=
me
.
getBranch
(
name
)
if
flags
&
fuse
.
O_ANYWRITE
!=
0
&&
branch
>
0
{
err
:=
me
.
Promote
(
name
,
me
.
branches
[
branch
])
if
err
!=
nil
{
panic
(
"copy: "
+
err
.
String
())
code
:=
me
.
Promote
(
name
,
me
.
branches
[
branch
])
if
code
!=
fuse
.
OK
{
return
nil
,
code
}
branch
=
0
}
...
...
unionfs/unionfs_test.go
View file @
5a4cfdc9
...
...
@@ -226,3 +226,13 @@ func TestBasic(t *testing.T) {
t
.
Errorf
(
"Expected 1 entry in %v"
,
names
)
}
}
func
TestPromote
(
t
*
testing
.
T
)
{
wd
,
state
:=
setup
(
t
)
defer
state
.
Unmount
()
err
:=
os
.
Mkdir
(
wd
+
"/ro/subdir"
,
0755
)
CheckSuccess
(
err
)
writeToFile
(
wd
+
"/ro/subdir/file"
,
"content"
,
true
)
writeToFile
(
wd
+
"/mount/subdir/file"
,
"other-content"
,
false
)
}
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