Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions db_mmap_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !plan9
// +build !plan9

package pogreb

import (
"github.com/akrylysov/pogreb/fs"
)

var testFileSystems = []fs.FileSystem{fs.Mem, fs.OSMMap, fs.OS}
10 changes: 10 additions & 0 deletions db_rpc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build plan9
// +build plan9

package pogreb

import (
"github.com/akrylysov/pogreb/fs"
)

var testFileSystems = []fs.FileSystem{fs.Mem, fs.OS}
2 changes: 1 addition & 1 deletion db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestMain(m *testing.M) {
SetLogger(log.New(io.Discard, "", 0))
}
// Run tests against all file systems.
for _, fsys := range []fs.FileSystem{fs.Mem, fs.OSMMap, fs.OS} {
for _, fsys := range testFileSystems {
var tmpDir string
if fsys == fs.Mem {
testFS = fsys
Expand Down
7 changes: 7 additions & 0 deletions fs/os_mmap.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !plan9

package fs

import (
Expand Down Expand Up @@ -161,3 +163,8 @@ func (f *osMMapFile) Close() error {
}
return f.File.Close()
}

// Return a default FileSystem for this platform.
func DefaultFileSystem() FileSystem {
return OSMMap
}
3 changes: 2 additions & 1 deletion fs/os_mmap_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//go:build !windows
//go:build !(plan9 || windows)
// +build !plan9,!windows

package fs

Expand Down
1 change: 1 addition & 0 deletions fs/os_mmap_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//go:build windows
// +build windows

package fs

Expand Down
26 changes: 26 additions & 0 deletions fs/os_plan9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//go:build plan9
// +build plan9

package fs

import (
"os"
"syscall"
)

func createLockFile(name string, perm os.FileMode) (LockFile, bool, error) {
acquiredExisting := false
if _, err := os.Stat(name); err == nil {
acquiredExisting = true
}
f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE, syscall.DMEXCL|perm)
if err != nil {
return nil, false, err
}
return &osLockFile{f, name}, acquiredExisting, nil
}

// Return a default FileSystem for this platform.
func DefaultFileSystem() FileSystem {
return OS
}
3 changes: 2 additions & 1 deletion fs/os_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//go:build !windows
//go:build !(plan9 || windows)
// +build !plan9,!windows

package fs

Expand Down
1 change: 1 addition & 0 deletions fs/os_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//go:build windows
// +build windows

package fs

Expand Down
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Options struct {
//
// Default: fs.OSMMap.
FileSystem fs.FileSystem
rootFS fs.FileSystem
rootFS fs.FileSystem

maxSegmentSize uint32
compactionMinSegmentSize uint32
Expand All @@ -39,7 +39,7 @@ func (src *Options) copyWithDefaults(path string) *Options {
opts = *src
}
if opts.FileSystem == nil {
opts.FileSystem = fs.OSMMap
opts.FileSystem = fs.DefaultFileSystem()
}
opts.rootFS = opts.FileSystem
opts.FileSystem = fs.Sub(opts.FileSystem, path)
Expand Down
Loading