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
Kirill Smelkov
go-fuse
Commits
bcc0741a
Commit
bcc0741a
authored
Sep 07, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement and test hardlinks in UnionFs.
parent
1643d64c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
unionfs/unionfs.go
unionfs/unionfs.go
+33
-0
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+26
-0
No files found.
unionfs/unionfs.go
View file @
bcc0741a
...
...
@@ -178,6 +178,10 @@ func (me *UnionFs) getBranchAttrNoCache(name string) branchResult {
a
,
s
:=
fs
.
GetAttr
(
name
,
nil
)
if
s
.
Ok
()
{
if
i
>
0
{
// Needed to make hardlinks work.
a
.
Ino
=
0
}
// Make all files appear writable
a
.
Mode
|=
0222
return
branchResult
{
...
...
@@ -306,6 +310,35 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
////////////////////////////////////////////////////////////////
// Below: implement interface for a FileSystem.
func
(
me
*
UnionFs
)
Link
(
orig
string
,
newName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
origResult
:=
me
.
getBranch
(
orig
)
code
=
origResult
.
code
if
code
.
Ok
()
&&
origResult
.
branch
>
0
{
code
=
me
.
Promote
(
orig
,
origResult
,
context
)
}
if
code
.
Ok
()
&&
origResult
.
branch
>
0
{
// Hairy: for the link to be hooked up to the existing
// inode, PathNodeFs must see a client inode for the
// original. We force a refresh of the attribute (so
// the Ino is filled in.), and then force PathNodeFs
// to see the Inode number.
me
.
branchCache
.
GetFresh
(
orig
)
inode
:=
me
.
nodeFs
.
Node
(
orig
)
inode
.
FsNode
()
.
GetAttr
(
nil
,
nil
)
}
if
code
.
Ok
()
{
code
=
me
.
promoteDirsTo
(
newName
)
}
if
code
.
Ok
()
{
code
=
me
.
fileSystems
[
0
]
.
Link
(
orig
,
newName
,
context
)
}
if
code
.
Ok
()
{
me
.
removeDeletion
(
newName
)
me
.
branchCache
.
GetFresh
(
newName
)
}
return
code
}
func
(
me
*
UnionFs
)
Rmdir
(
path
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
r
:=
me
.
getBranch
(
path
)
if
r
.
code
!=
fuse
.
OK
{
...
...
unionfs/unionfs_test.go
View file @
bcc0741a
...
...
@@ -579,6 +579,32 @@ func TestWriteAccess(t *testing.T) {
}
}
func
TestLink
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
content
:=
"blabla"
fn
:=
wd
+
"/ro/file"
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
content
),
0666
)
CheckSuccess
(
err
)
err
=
os
.
Link
(
wd
+
"/mount/file"
,
wd
+
"/mount/linked"
)
CheckSuccess
(
err
)
fi2
,
err
:=
os
.
Lstat
(
wd
+
"/mount/linked"
)
CheckSuccess
(
err
)
fi1
,
err
:=
os
.
Lstat
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
if
fi1
.
Ino
!=
fi2
.
Ino
{
t
.
Errorf
(
"inode numbers should be equal for linked files %v, %v"
,
fi1
.
Ino
,
fi2
.
Ino
)
}
c
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mount/linked"
)
if
string
(
c
)
!=
content
{
t
.
Errorf
(
"content mismatch got %q want %q"
,
string
(
c
),
content
)
}
}
func
TestTruncate
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestTruncate"
)
wd
,
clean
:=
setupUfs
(
t
)
...
...
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