Commit 62094b64 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Set Nlink = 1 if not set by lookup method. This fixes hardlink on

newer kernels.
parent 76730696
...@@ -83,6 +83,11 @@ func (me *FileSystemConnector) childLookup(fi *os.FileInfo, fsi FsNode) (out *En ...@@ -83,6 +83,11 @@ func (me *FileSystemConnector) childLookup(fi *os.FileInfo, fsi FsNode) (out *En
out = n.mount.fileInfoToEntry(fi) out = n.mount.fileInfoToEntry(fi)
out.Ino = me.lookupUpdate(n) out.Ino = me.lookupUpdate(n)
out.NodeId = out.Ino out.NodeId = out.Ino
if out.Nlink == 0 {
// With Nlink == 0, newer kernels will refuse link
// operations.
out.Nlink = 1
}
return out return out
} }
......
...@@ -338,6 +338,19 @@ func TestMemUnionFsLink(t *testing.T) { ...@@ -338,6 +338,19 @@ func TestMemUnionFsLink(t *testing.T) {
} }
} }
func TestMemUnionFsCreateLink(t *testing.T) {
wd, _, clean := setupMemUfs(t)
defer clean()
content := "blabla"
fn := wd + "/mnt/file"
err := ioutil.WriteFile(fn, []byte(content), 0666)
CheckSuccess(err)
err = os.Link(wd+"/mount/file", wd+"/mount/linked")
CheckSuccess(err)
}
func TestMemUnionFsTruncate(t *testing.T) { func TestMemUnionFsTruncate(t *testing.T) {
wd, _, clean := setupMemUfs(t) wd, _, clean := setupMemUfs(t)
defer clean() defer clean()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment