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
6584ea29
Commit
6584ea29
authored
Apr 30, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UnionFs: Implement Truncate
parent
d4933eb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
unionfs/unionfs.go
unionfs/unionfs.go
+12
-0
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+17
-0
No files found.
unionfs/unionfs.go
View file @
6584ea29
...
...
@@ -321,6 +321,18 @@ func (me *UnionFs) Symlink(pointedTo string, linkName string) (code fuse.Status)
return
code
}
func
(
me
*
UnionFs
)
Truncate
(
path
string
,
offset
uint64
)
(
code
fuse
.
Status
)
{
branch
:=
me
.
getBranch
(
path
)
if
branch
>
0
{
code
:=
me
.
Promote
(
path
,
me
.
branches
[
branch
])
if
code
!=
fuse
.
OK
{
return
code
}
}
return
me
.
fileSystems
[
0
]
.
Truncate
(
path
,
offset
)
}
func
(
me
*
UnionFs
)
Chmod
(
name
string
,
mode
uint32
)
(
code
fuse
.
Status
)
{
r
:=
me
.
branchCache
.
Get
(
name
)
.
(
getBranchResult
)
if
r
.
attr
==
nil
||
r
.
code
!=
fuse
.
OK
{
...
...
unionfs/unionfs_test.go
View file @
6584ea29
...
...
@@ -333,3 +333,20 @@ func TestWritableDir(t *testing.T) {
t
.
Errorf
(
"unexpected permission %o"
,
fi
.
Permission
())
}
}
func
TestTruncate
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestTruncate"
)
wd
,
state
:=
setup
(
t
)
defer
state
.
Unmount
()
writeToFile
(
wd
+
"/ro/file"
,
"hello"
)
os
.
Truncate
(
wd
+
"/mount/file"
,
2
)
content
:=
readFromFile
(
wd
+
"/mount/file"
)
if
content
!=
"he"
{
t
.
Errorf
(
"unexpected content %v"
,
content
)
}
content2
:=
readFromFile
(
wd
+
"/rw/file"
)
if
content2
!=
content
{
t
.
Errorf
(
"unexpected rw content %v"
,
content2
)
}
}
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