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
444f87ef
Commit
444f87ef
authored
Sep 05, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Link.
parent
d0dbfc98
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
25 deletions
+49
-25
fuse/fsinode.go
fuse/fsinode.go
+17
-2
fuse/fsmount.go
fuse/fsmount.go
+5
-5
fuse/fsops.go
fuse/fsops.go
+20
-17
fuse/loopback_test.go
fuse/loopback_test.go
+7
-1
No files found.
fuse/fsinode.go
View file @
444f87ef
...
...
@@ -92,6 +92,10 @@ func (me *fsInode) SetInode(node *inode) {
me
.
inode
=
node
}
func
(
me
*
fsInode
)
Inode
()
*
inode
{
return
me
.
inode
}
////////////////////////////////////////////////////////////////
func
(
me
*
fsInode
)
Readlink
(
c
*
Context
)
([]
byte
,
Status
)
{
...
...
@@ -188,8 +192,19 @@ func (me *fsInode) Rename(oldName string, newParent *fsInode, newName string, co
return
me
.
fs
.
Rename
(
oldPath
,
newPath
,
context
)
}
func
(
me
*
fsInode
)
Link
(
name
string
,
existing
*
fsInode
,
context
*
Context
)
(
code
Status
)
{
return
me
.
fs
.
Link
(
existing
.
GetPath
(),
filepath
.
Join
(
me
.
GetPath
(),
name
),
context
)
func
(
me
*
fsInode
)
Link
(
name
string
,
existing
*
fsInode
,
context
*
Context
)
(
fi
*
os
.
FileInfo
,
newNode
*
fsInode
,
code
Status
)
{
newPath
:=
filepath
.
Join
(
me
.
GetPath
(),
name
)
oldPath
:=
existing
.
GetPath
()
code
=
me
.
fs
.
Link
(
oldPath
,
newPath
,
context
)
if
code
.
Ok
()
{
oldFi
,
_
:=
me
.
fs
.
GetAttr
(
oldPath
,
context
)
fi
,
_
=
me
.
fs
.
GetAttr
(
newPath
,
context
)
if
oldFi
!=
nil
&&
fi
!=
nil
&&
oldFi
.
Ino
!=
0
&&
oldFi
.
Ino
==
fi
.
Ino
{
return
fi
,
existing
,
OK
}
newNode
=
me
.
createChild
(
name
)
}
return
}
func
(
me
*
fsInode
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
,
context
*
Context
)
(
file
File
,
fi
*
os
.
FileInfo
,
newNode
*
fsInode
,
code
Status
)
{
...
...
fuse/fsmount.go
View file @
444f87ef
...
...
@@ -47,17 +47,17 @@ func (me *fileSystemMount) setOwner(attr *Attr) {
attr
.
Owner
=
*
me
.
options
.
Owner
}
}
func
(
me
*
fileSystemMount
)
fileInfoToEntry
(
fi
*
os
.
FileInfo
,
out
*
EntryOut
)
{
func
(
me
*
fileSystemMount
)
fileInfoToEntry
(
fi
*
os
.
FileInfo
)
(
out
*
EntryOut
)
{
out
=
&
EntryOut
{}
SplitNs
(
me
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
SplitNs
(
me
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
CopyFileInfo
(
fi
,
&
out
.
Attr
)
me
.
setOwner
(
&
out
.
Attr
)
if
!
fi
.
IsDirectory
()
{
fi
.
Nlink
=
1
}
CopyFileInfo
(
fi
,
&
out
.
Attr
)
me
.
setOwner
(
&
out
.
Attr
)
return
out
}
func
(
me
*
fileSystemMount
)
fileInfoToAttr
(
fi
*
os
.
FileInfo
,
out
*
AttrOut
)
{
CopyFileInfo
(
fi
,
&
out
.
Attr
)
...
...
fuse/fsops.go
View file @
444f87ef
...
...
@@ -33,11 +33,11 @@ func (me *FileSystemConnector) internalMountLookup(mount *fileSystemMount, looku
mount
.
treeLock
.
Lock
()
defer
mount
.
treeLock
.
Unlock
()
mount
.
mountInode
.
lookupCount
+=
lookupCount
out
=
&
EntryOut
{
NodeId
:
mount
.
mountInode
.
nodeId
,
Generation
:
1
,
// where to get the generation?
}
mount
.
fileInfoToEntry
(
fi
,
out
)
out
=
mount
.
fileInfoToEntry
(
fi
)
out
.
NodeId
=
mount
.
mountInode
.
nodeId
// We don't do NFS.
out
.
Generation
=
1
return
out
,
OK
,
mount
.
mountInode
}
...
...
@@ -60,11 +60,9 @@ func (me *FileSystemConnector) internalLookup(parent *inode, name string, lookup
}
if
child
!=
nil
&&
code
.
Ok
()
{
out
=
&
EntryOut
{
NodeId
:
child
.
nodeId
,
Generation
:
1
,
// where to get the generation?
}
parent
.
mount
.
fileInfoToEntry
(
fi
,
out
)
out
=
parent
.
mount
.
fileInfoToEntry
(
fi
)
out
.
NodeId
=
child
.
nodeId
out
.
Generation
=
1
return
out
,
OK
,
child
}
...
...
@@ -203,8 +201,7 @@ func (me *FileSystemConnector) Mknod(header *InHeader, input *MknodIn, name stri
func
(
me
*
FileSystemConnector
)
createChild
(
parent
*
inode
,
name
string
,
fi
*
os
.
FileInfo
,
fsi
*
fsInode
)
(
out
*
EntryOut
,
child
*
inode
)
{
child
=
parent
.
createChild
(
name
,
fi
.
IsDirectory
(),
fsi
,
me
)
out
=
&
EntryOut
{}
parent
.
mount
.
fileInfoToEntry
(
fi
,
out
)
out
=
parent
.
mount
.
fileInfoToEntry
(
fi
)
out
.
Ino
=
child
.
nodeId
out
.
NodeId
=
child
.
nodeId
return
out
,
child
...
...
@@ -270,20 +267,26 @@ func (me *FileSystemConnector) Rename(header *InHeader, input *RenameIn, oldName
return
code
}
func
(
me
*
FileSystemConnector
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
file
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
Link
(
header
*
InHeader
,
input
*
LinkIn
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
existing
:=
me
.
getInodeData
(
input
.
Oldnodeid
)
parent
:=
me
.
getInodeData
(
header
.
NodeId
)
if
existing
.
mount
!=
parent
.
mount
{
return
nil
,
EXDEV
}
code
=
parent
.
fsInode
.
Link
(
file
name
,
existing
.
fsInode
,
&
header
.
Context
)
fi
,
fsInode
,
code
:=
parent
.
fsInode
.
Link
(
name
,
existing
.
fsInode
,
&
header
.
Context
)
if
!
code
.
Ok
()
{
return
nil
,
code
}
// TODO - revise this for real hardlinks?
out
,
code
,
_
=
me
.
internalLookup
(
parent
,
filename
,
1
,
&
header
.
Context
)
if
fsInode
.
Inode
()
==
nil
{
out
,
_
=
me
.
createChild
(
parent
,
name
,
fi
,
fsInode
)
}
else
{
out
=
parent
.
mount
.
fileInfoToEntry
(
fi
)
out
.
Ino
=
fsInode
.
Inode
()
.
nodeId
out
.
NodeId
=
out
.
Ino
}
return
out
,
code
}
...
...
fuse/loopback_test.go
View file @
444f87ef
...
...
@@ -243,11 +243,17 @@ func TestLink(t *testing.T) {
err
=
os
.
Link
(
me
.
mountFile
,
mountSubfile
)
CheckSuccess
(
err
)
subfi
,
err
:=
os
.
Lstat
(
mountSubfile
)
CheckSuccess
(
err
)
fi
,
err
:=
os
.
Lstat
(
me
.
origFile
)
CheckSuccess
(
err
)
if
fi
.
Nlink
!=
2
{
t
.
Errorf
(
"Expect 2 links: %v"
,
fi
)
}
if
fi
.
Ino
!=
subfi
.
Ino
{
t
.
Errorf
(
"Link succeeded, but inode numbers different: %v %v"
,
fi
.
Ino
,
subfi
.
Ino
)
}
f
,
err
:=
os
.
Open
(
mountSubfile
)
var
buf
[
1024
]
byte
...
...
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