Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
2f23b2ca
Commit
2f23b2ca
authored
May 19, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Plain Diff
Implemented CreateSymlink for memfs.
parents
5aacfb08
9b36fa15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
samples/memfs/fs.go
samples/memfs/fs.go
+45
-0
samples/memfs/memfs_test.go
samples/memfs/memfs_test.go
+1
-1
No files found.
samples/memfs/fs.go
View file @
2f23b2ca
...
...
@@ -376,6 +376,51 @@ func (fs *memFS) CreateFile(
return
}
func
(
fs
*
memFS
)
CreateSymlink
(
op
*
fuseops
.
CreateSymlinkOp
)
{
var
err
error
defer
fuseutil
.
RespondToOp
(
op
,
&
err
)
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
// Grab the parent, which we will update shortly.
parent
:=
fs
.
getInodeForModifyingOrDie
(
op
.
Parent
)
defer
parent
.
mu
.
Unlock
()
// Set up attributes from the child, using the credentials of the calling
// process as owner (matching inode_init_owner, cf. http://goo.gl/5qavg8).
now
:=
fs
.
clock
.
Now
()
childAttrs
:=
fuseops
.
InodeAttributes
{
Nlink
:
1
,
Mode
:
0444
|
os
.
ModeSymlink
,
Atime
:
now
,
Mtime
:
now
,
Ctime
:
now
,
Crtime
:
now
,
Uid
:
op
.
Header
()
.
Uid
,
Gid
:
op
.
Header
()
.
Gid
,
}
// Allocate a child.
childID
,
child
:=
fs
.
allocateInode
(
childAttrs
)
defer
child
.
mu
.
Unlock
()
// Add an entry in the parent.
parent
.
AddChild
(
childID
,
op
.
Name
,
fuseutil
.
DT_Link
)
// Fill in the response entry.
op
.
Entry
.
Child
=
childID
op
.
Entry
.
Attributes
=
child
.
attrs
// We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation).
op
.
Entry
.
AttributesExpiration
=
fs
.
clock
.
Now
()
.
Add
(
365
*
24
*
time
.
Hour
)
op
.
Entry
.
EntryExpiration
=
op
.
Entry
.
EntryExpiration
return
}
func
(
fs
*
memFS
)
RmDir
(
op
*
fuseops
.
RmDirOp
)
{
var
err
error
...
...
samples/memfs/memfs_test.go
View file @
2f23b2ca
...
...
@@ -1177,7 +1177,7 @@ func (t *MemFSTest) CreateSymlink_AlreadyExists() {
for
_
,
n
:=
range
names
{
err
=
os
.
Symlink
(
"blah"
,
n
)
ExpectThat
(
err
,
Error
(
HasSubstr
(
"
TODO
"
)))
ExpectThat
(
err
,
Error
(
HasSubstr
(
"
exists
"
)))
}
}
...
...
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