Commit 830461e3 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop fuse.MakeTempDir()

parent ce03e525
...@@ -27,7 +27,8 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F ...@@ -27,7 +27,8 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F
} }
func setupCacheTest() (string, *PathNodeFs, func()) { func setupCacheTest() (string, *PathNodeFs, func()) {
dir := MakeTempDir() dir, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
os.Mkdir(dir+"/mnt", 0755) os.Mkdir(dir+"/mnt", 0755)
os.Mkdir(dir+"/orig", 0755) os.Mkdir(dir+"/orig", 0755)
...@@ -117,7 +118,8 @@ func TestNonseekable(t *testing.T) { ...@@ -117,7 +118,8 @@ func TestNonseekable(t *testing.T) {
fs := &nonseekFs{} fs := &nonseekFs{}
fs.Length = 200 * 1024 fs.Length = 200 * 1024
dir := MakeTempDir() dir, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
state, _, err := MountPathFileSystem(dir, fs, nil) state, _, err := MountPathFileSystem(dir, fs, nil)
CheckSuccess(err) CheckSuccess(err)
......
...@@ -6,15 +6,17 @@ import ( ...@@ -6,15 +6,17 @@ import (
) )
func TestCopyFile(t *testing.T) { func TestCopyFile(t *testing.T) {
d1 := MakeTempDir() d1, err := ioutil.TempDir("", "go-fuse")
d2 := MakeTempDir() CheckSuccess(err)
d2, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
fs1 := NewLoopbackFileSystem(d1) fs1 := NewLoopbackFileSystem(d1)
fs2 := NewLoopbackFileSystem(d2) fs2 := NewLoopbackFileSystem(d2)
content1 := "blabla" content1 := "blabla"
err := ioutil.WriteFile(d1+"/file", []byte(content1), 0644) err = ioutil.WriteFile(d1+"/file", []byte(content1), 0644)
CheckSuccess(err) CheckSuccess(err)
code := CopyFile(fs1, fs2, "file", "file", nil) code := CopyFile(fs1, fs2, "file", "file", nil)
......
...@@ -2,6 +2,7 @@ package fuse ...@@ -2,6 +2,7 @@ package fuse
import ( import (
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"syscall" "syscall"
...@@ -121,7 +122,8 @@ func NewFile() *MutableDataFile { ...@@ -121,7 +122,8 @@ func NewFile() *MutableDataFile {
} }
func setupFAttrTest(fs FileSystem) (dir string, clean func()) { func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
dir = MakeTempDir() dir, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
state, _, err := MountPathFileSystem(dir, fs, nil) state, _, err := MountPathFileSystem(dir, fs, nil)
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = true
......
...@@ -52,7 +52,9 @@ func NewTestCase(t *testing.T) *testCase { ...@@ -52,7 +52,9 @@ func NewTestCase(t *testing.T) *testCase {
const name string = "hello.txt" const name string = "hello.txt"
const subdir string = "subdir" const subdir string = "subdir"
me.tmpDir = MakeTempDir() var err os.Error
me.tmpDir, err = ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
me.orig = me.tmpDir + "/orig" me.orig = me.tmpDir + "/orig"
me.mnt = me.tmpDir + "/mnt" me.mnt = me.tmpDir + "/mnt"
...@@ -689,10 +691,11 @@ func TestStatFs(t *testing.T) { ...@@ -689,10 +691,11 @@ func TestStatFs(t *testing.T) {
} }
func TestOriginalIsSymlink(t *testing.T) { func TestOriginalIsSymlink(t *testing.T) {
tmpDir := MakeTempDir() tmpDir, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
orig := tmpDir + "/orig" orig := tmpDir + "/orig"
err := os.Mkdir(orig, 0755) err = os.Mkdir(orig, 0755)
CheckSuccess(err) CheckSuccess(err)
link := tmpDir + "/link" link := tmpDir + "/link"
mnt := tmpDir + "/mnt" mnt := tmpDir + "/mnt"
......
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
"strings" "strings"
"syscall" "syscall"
"unsafe" "unsafe"
"io/ioutil"
) )
func (code Status) String() string { func (code Status) String() string {
...@@ -30,15 +29,6 @@ func (code Status) Ok() bool { ...@@ -30,15 +29,6 @@ func (code Status) Ok() bool {
return code == OK return code == OK
} }
// Make a temporary directory securely.
func MakeTempDir() string {
nm, err := ioutil.TempDir("", "go-fuse")
if err != nil {
panic("TempDir() failed: " + err.String())
}
return nm
}
// Convert os.Error back to Errno based errors. // Convert os.Error back to Errno based errors.
func OsErrorToErrno(err os.Error) Status { func OsErrorToErrno(err os.Error) Status {
if err != nil { if err != nil {
......
package fuse package fuse
import ( import (
"io/ioutil"
"log" "log"
"os" "os"
"testing" "testing"
...@@ -42,7 +43,9 @@ type NotifyTest struct { ...@@ -42,7 +43,9 @@ type NotifyTest struct {
func NewNotifyTest() *NotifyTest { func NewNotifyTest() *NotifyTest {
me := &NotifyTest{} me := &NotifyTest{}
me.fs = &NotifyFs{} me.fs = &NotifyFs{}
me.dir = MakeTempDir() var err os.Error
me.dir, err = ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
entryTtl := 0.1 entryTtl := 0.1
opts := &FileSystemOptions{ opts := &FileSystemOptions{
EntryTimeout: entryTtl, EntryTimeout: entryTtl,
...@@ -50,7 +53,6 @@ func NewNotifyTest() *NotifyTest { ...@@ -50,7 +53,6 @@ func NewNotifyTest() *NotifyTest {
NegativeTimeout: entryTtl, NegativeTimeout: entryTtl,
} }
var err os.Error
me.pathfs = NewPathNodeFs(me.fs) me.pathfs = NewPathNodeFs(me.fs)
me.state, me.connector, err = MountNodeFileSystem(me.dir, me.pathfs, opts) me.state, me.connector, err = MountNodeFileSystem(me.dir, me.pathfs, opts)
CheckSuccess(err) CheckSuccess(err)
......
package fuse package fuse
import ( import (
"io/ioutil"
"os" "os"
"testing" "testing"
) )
...@@ -25,7 +26,7 @@ func (me *ownerFs) GetAttr(name string, context *Context) (*os.FileInfo, Status) ...@@ -25,7 +26,7 @@ func (me *ownerFs) GetAttr(name string, context *Context) (*os.FileInfo, Status)
} }
func setupOwnerTest(opts *FileSystemOptions) (workdir string, cleanup func()) { func setupOwnerTest(opts *FileSystemOptions) (workdir string, cleanup func()) {
wd := MakeTempDir() wd, err := ioutil.TempDir("", "go-fuse")
fs := &ownerFs{} fs := &ownerFs{}
state, _, err := MountPathFileSystem(wd, fs, opts) state, _, err := MountPathFileSystem(wd, fs, opts)
......
...@@ -2,6 +2,7 @@ package fuse ...@@ -2,6 +2,7 @@ package fuse
import ( import (
"bytes" "bytes"
"io/ioutil"
"testing" "testing"
"log" "log"
"path/filepath" "path/filepath"
...@@ -91,7 +92,8 @@ func TestXAttrRead(t *testing.T) { ...@@ -91,7 +92,8 @@ func TestXAttrRead(t *testing.T) {
"user.attr1": []byte("val1"), "user.attr1": []byte("val1"),
"user.attr2": []byte("val2")} "user.attr2": []byte("val2")}
xfs := NewXAttrFs(nm, golden) xfs := NewXAttrFs(nm, golden)
mountPoint := MakeTempDir() mountPoint, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
defer os.RemoveAll(mountPoint) defer os.RemoveAll(mountPoint)
state, _, err := MountPathFileSystem(mountPoint, xfs, nil) state, _, err := MountPathFileSystem(mountPoint, xfs, nil)
......
...@@ -29,7 +29,7 @@ func WriteFile(name string, contents string) { ...@@ -29,7 +29,7 @@ func WriteFile(name string, contents string) {
} }
func setup(t *testing.T) (workdir string, cleanup func()) { func setup(t *testing.T) (workdir string, cleanup func()) {
wd := fuse.MakeTempDir() wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mount", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
......
...@@ -3,6 +3,7 @@ package unionfs ...@@ -3,6 +3,7 @@ package unionfs
import ( import (
"os" "os"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"io/ioutil"
"fmt" "fmt"
"log" "log"
"syscall" "syscall"
...@@ -27,7 +28,7 @@ func modeMapEq(m1, m2 map[string]uint32) bool { ...@@ -27,7 +28,7 @@ func modeMapEq(m1, m2 map[string]uint32) bool {
} }
func TestCachingFs(t *testing.T) { func TestCachingFs(t *testing.T) {
wd := fuse.MakeTempDir() wd, _ := ioutil.TempDir("", "")
defer os.RemoveAll(wd) defer os.RemoveAll(wd)
fs := fuse.NewLoopbackFileSystem(wd) fs := fuse.NewLoopbackFileSystem(wd)
......
...@@ -30,7 +30,7 @@ var testOpts = UnionFsOptions{ ...@@ -30,7 +30,7 @@ var testOpts = UnionFsOptions{
} }
func setupUfs(t *testing.T) (workdir string, cleanup func()) { func setupUfs(t *testing.T) (workdir string, cleanup func()) {
wd := fuse.MakeTempDir() wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mount", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
...@@ -843,7 +843,7 @@ func TestDropCache(t *testing.T) { ...@@ -843,7 +843,7 @@ func TestDropCache(t *testing.T) {
func TestDisappearing(t *testing.T) { func TestDisappearing(t *testing.T) {
// This init is like setupUfs, but we want access to the // This init is like setupUfs, but we want access to the
// writable Fs. // writable Fs.
wd := fuse.MakeTempDir() wd, _ := ioutil.TempDir("", "")
defer os.RemoveAll(wd) defer os.RemoveAll(wd)
err := os.Mkdir(wd+"/mount", 0700) err := os.Mkdir(wd+"/mount", 0700)
fuse.CheckSuccess(err) fuse.CheckSuccess(err)
......
...@@ -15,7 +15,7 @@ const testTtl = 0.1 ...@@ -15,7 +15,7 @@ const testTtl = 0.1
func setupMzfs() (mountPoint string, cleanup func()) { func setupMzfs() (mountPoint string, cleanup func()) {
fs := NewMultiZipFs() fs := NewMultiZipFs()
mountPoint = fuse.MakeTempDir() mountPoint, _ = ioutil.TempDir("", "")
state, _, err := fuse.MountPathFileSystem(mountPoint, fs, &fuse.FileSystemOptions{ state, _, err := fuse.MountPathFileSystem(mountPoint, fs, &fuse.FileSystemOptions{
EntryTimeout: testTtl, EntryTimeout: testTtl,
AttrTimeout: testTtl, AttrTimeout: testTtl,
......
...@@ -22,8 +22,7 @@ func setupZipfs() (mountPoint string, cleanup func()) { ...@@ -22,8 +22,7 @@ func setupZipfs() (mountPoint string, cleanup func()) {
zfs, err := NewArchiveFileSystem(testZipFile()) zfs, err := NewArchiveFileSystem(testZipFile())
CheckSuccess(err) CheckSuccess(err)
mountPoint = fuse.MakeTempDir() mountPoint, _ = ioutil.TempDir("", "")
state, _, err := fuse.MountNodeFileSystem(mountPoint, zfs, nil) state, _, err := fuse.MountNodeFileSystem(mountPoint, zfs, nil)
state.Debug = true state.Debug = true
......
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