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
f4c835e5
Commit
f4c835e5
authored
Nov 24, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test and fix truncate on open file.
parent
b189413a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
+28
-6
fuse/memnode.go
fuse/memnode.go
+10
-6
fuse/memnode_test.go
fuse/memnode_test.go
+18
-0
No files found.
fuse/memnode.go
View file @
f4c835e5
...
...
@@ -178,13 +178,17 @@ func (me *memNode) GetAttr(file File, context *Context) (fi *os.FileInfo, code S
func
(
me
*
memNode
)
Truncate
(
file
File
,
size
uint64
,
context
*
Context
)
(
code
Status
)
{
if
file
!=
nil
{
return
file
.
Truncate
(
size
)
code
=
file
.
Truncate
(
size
)
}
else
{
err
:=
os
.
Truncate
(
me
.
filename
(),
int64
(
size
))
code
=
ToStatus
(
err
)
}
me
.
info
.
Size
=
int64
(
size
)
err
:=
os
.
Truncate
(
me
.
filename
(),
int64
(
size
))
me
.
info
.
Ctime_ns
=
time
.
Nanoseconds
()
return
ToStatus
(
err
)
if
code
.
Ok
()
{
me
.
info
.
Ctime_ns
=
time
.
Nanoseconds
()
// TODO - should update mtime too?
me
.
info
.
Size
=
int64
(
size
)
}
return
code
}
func
(
me
*
memNode
)
Utimens
(
file
File
,
atime
uint64
,
mtime
uint64
,
context
*
Context
)
(
code
Status
)
{
...
...
fuse/memnode_test.go
View file @
f4c835e5
...
...
@@ -58,3 +58,21 @@ func TestMemNodeFs(t *testing.T) {
t
.
Fatalf
(
"Readdir got %v, expected 1 file named 'test'"
,
entries
)
}
}
func
TestMemNodeSetattr
(
t
*
testing
.
T
)
{
wd
,
_
,
clean
:=
setupMemNodeTest
(
t
)
defer
clean
()
f
,
err
:=
os
.
OpenFile
(
wd
+
"/test"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0644
)
CheckSuccess
(
err
)
defer
f
.
Close
()
err
=
f
.
Truncate
(
4096
)
CheckSuccess
(
err
)
fi
,
err
:=
f
.
Stat
()
CheckSuccess
(
err
)
if
fi
.
Size
!=
4096
{
t
.
Errorf
(
"Size should be 4096 after Truncate: %d"
,
fi
.
Size
)
}
}
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