FreeBSD's nullfs doesn't support file mount

FreeBSD doesn't have "bind" mount, but nullfs might be a similar feature.
However nullfs can mount only directories.

Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
This commit is contained in:
Kato Kazuyoshi 2014-03-22 12:03:09 +09:00
parent 8e163af55e
commit 243b3164c8

View file

@ -31,10 +31,15 @@ func TestMounted(t *testing.T) {
defer os.RemoveAll(tmp) defer os.RemoveAll(tmp)
var ( var (
sourcePath = path.Join(tmp, "sourcefile.txt") sourceDir = path.Join(tmp, "source")
targetPath = path.Join(tmp, "targetfile.txt") targetDir = path.Join(tmp, "target")
sourcePath = path.Join(sourceDir, "file.txt")
targetPath = path.Join(targetDir, "file.txt")
) )
os.Mkdir(sourceDir, 0777)
os.Mkdir(targetDir, 0777)
f, err := os.Create(sourcePath) f, err := os.Create(sourcePath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -48,23 +53,23 @@ func TestMounted(t *testing.T) {
} }
f.Close() f.Close()
if err := Mount(sourcePath, targetPath, "none", "bind,rw"); err != nil { if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer func() { defer func() {
if err := Unmount(targetPath); err != nil { if err := Unmount(targetDir); err != nil {
t.Fatal(err) t.Fatal(err)
} }
}() }()
mounted, err := Mounted(targetPath) mounted, err := Mounted(targetDir)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if !mounted { if !mounted {
t.Fatalf("Expected %s to be mounted", targetPath) t.Fatalf("Expected %s to be mounted", targetDir)
} }
if _, err := os.Stat(targetPath); err != nil { if _, err := os.Stat(targetDir); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
@ -77,10 +82,15 @@ func TestMountReadonly(t *testing.T) {
defer os.RemoveAll(tmp) defer os.RemoveAll(tmp)
var ( var (
sourcePath = path.Join(tmp, "sourcefile.txt") sourceDir = path.Join(tmp, "source")
targetPath = path.Join(tmp, "targetfile.txt") targetDir = path.Join(tmp, "target")
sourcePath = path.Join(sourceDir, "file.txt")
targetPath = path.Join(targetDir, "file.txt")
) )
os.Mkdir(sourceDir, 0777)
os.Mkdir(targetDir, 0777)
f, err := os.Create(sourcePath) f, err := os.Create(sourcePath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -94,7 +104,7 @@ func TestMountReadonly(t *testing.T) {
} }
f.Close() f.Close()
if err := Mount(sourcePath, targetPath, "none", "bind,ro"); err != nil { if err := Mount(sourceDir, targetDir, "none", "bind,ro"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer func() { defer func() {