From 073775e461da4447b6831b054e79a303a7e5afc9 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 25 Jul 2014 15:26:23 +0200 Subject: [PATCH] Build Solaris again --- Godeps/Godeps.json | 2 +- .../leveldb/storage/file_storage_solaris.go | 68 +++++++++++++++++++ .../leveldb/storage/file_storage_unix.go | 2 +- build.sh | 2 +- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 83cd8d0cb..3e2c9af6a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -54,7 +54,7 @@ }, { "ImportPath": "github.com/syndtr/goleveldb/leveldb", - "Rev": "ba4481e4cb1d45f586e32be2ab663f173b08b207" + "Rev": "c5955912e3287376475731c5bc59c79a5a799105" }, { "ImportPath": "github.com/vitrun/qart/coding", diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go new file mode 100644 index 000000000..102031bfd --- /dev/null +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go @@ -0,0 +1,68 @@ +// Copyright (c) 2012, Suryandaru Triandana +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// +build solaris + +package storage + +import ( + "os" + "syscall" +) + +type unixFileLock struct { + f *os.File +} + +func (fl *unixFileLock) release() error { + if err := setFileLock(fl.f, false); err != nil { + return err + } + return fl.f.Close() +} + +func newFileLock(path string) (fl fileLock, err error) { + f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + return + } + err = setFileLock(f, true) + if err != nil { + f.Close() + return + } + fl = &unixFileLock{f: f} + return +} + +func setFileLock(f *os.File, lock bool) error { + flock := syscall.Flock_t{ + Type: syscall.F_UNLCK, + Start: 0, + Len: 0, + Whence: 1, + } + if lock { + flock.Type = syscall.F_WRLCK + } + return syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &flock) +} + +func rename(oldpath, newpath string) error { + return os.Rename(oldpath, newpath) +} + +func syncDir(name string) error { + f, err := os.Open(name) + if err != nil { + return err + } + defer f.Close() + if err := f.Sync(); err != nil { + return err + } + return nil +} diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go index 73499afc8..d0a604b7a 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// +build darwin freebsd linux netbsd openbsd +// +build darwin dragonfly freebsd linux netbsd openbsd package storage diff --git a/build.sh b/build.sh index 1abc3d38d..b30d259f0 100755 --- a/build.sh +++ b/build.sh @@ -143,7 +143,7 @@ case "$1" in test || exit 1 assets - for os in darwin-amd64 linux-386 linux-amd64 freebsd-amd64 windows-amd64 windows-386 ; do + for os in darwin-amd64 linux-386 linux-amd64 freebsd-amd64 windows-amd64 windows-386 solaris-amd64 ; do export GOOS=${os%-*} export GOARCH=${os#*-}