Remove POSIX lock handling
This commit is contained in:
@@ -78,7 +78,7 @@ func (m *Main) Run(args []string) (err error) {
|
||||
}
|
||||
|
||||
// Mount FUSE filesystem.
|
||||
conn, err := fuse.Mount(m.Path, fuse.LockingPOSIX())
|
||||
conn, err := fuse.Mount(m.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
5
go.mod
5
go.mod
@@ -2,7 +2,4 @@ module github.com/benbjohnson/litestream
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05
|
||||
github.com/pelletier/go-toml v1.8.1
|
||||
)
|
||||
require bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05
|
||||
|
||||
4
go.sum
4
go.sum
@@ -2,16 +2,14 @@ bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05 h1:UrYe9YkT4Wpm6D+zByEyCJQzDqT
|
||||
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05/go.mod h1:h0h5FBYpXThbvSfTqthw+0I4nmHnhTHkO5BoOHsBWqg=
|
||||
github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
|
||||
github.com/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c h1:u6SKchux2yDvFQnDHS3lPnIRmfVJ5Sxy3ao2SIdysLQ=
|
||||
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
|
||||
36
handle.go
36
handle.go
@@ -12,22 +12,16 @@ import (
|
||||
"bazil.org/fuse/fs"
|
||||
)
|
||||
|
||||
const (
|
||||
F_OFD_GETLK = 0x24
|
||||
F_OFD_SETLK = 0x25
|
||||
F_OFD_SETLKW = 0x26
|
||||
)
|
||||
|
||||
var _ fs.HandleFlockLocker = (*Handle)(nil)
|
||||
var _ fs.HandleFlusher = (*Handle)(nil)
|
||||
var _ fs.HandleLocker = (*Handle)(nil)
|
||||
var _ fs.HandlePOSIXLocker = (*Handle)(nil)
|
||||
var _ fs.HandleReadDirAller = (*Handle)(nil)
|
||||
var _ fs.HandleReader = (*Handle)(nil)
|
||||
var _ fs.HandleReleaser = (*Handle)(nil)
|
||||
var _ fs.HandleWriter = (*Handle)(nil)
|
||||
|
||||
// var _ fs.HandleReadAller = (*Handle)(nil)
|
||||
// var _ fs.HandleFlockLocker = (*Handle)(nil)
|
||||
//var _ fs.HandleLocker = (*Handle)(nil)
|
||||
//var _ fs.HandlePOSIXLocker = (*Handle)(nil)
|
||||
|
||||
// Handle represents a FUSE file handle.
|
||||
type Handle struct {
|
||||
@@ -82,23 +76,28 @@ func (h *Handle) ReadDirAll(ctx context.Context) (ents []fuse.Dirent, err error)
|
||||
return ents, nil
|
||||
}
|
||||
|
||||
/*
|
||||
// Lock tries to acquire a lock on a byte range of the node. If a
|
||||
// conflicting lock is already held, returns syscall.EAGAIN.
|
||||
func (h *Handle) Lock(ctx context.Context, req *fuse.LockRequest) error {
|
||||
log.Printf("dbg/lock %s -- %#v", h.f.Name(), req.Lock)
|
||||
return syscall.FcntlFlock(h.f.Fd(), F_OFD_SETLK, &syscall.Flock_t{
|
||||
log.Printf("dbg/lock %p %s -- %#v", h, h.f.Name(), req.Lock)
|
||||
if err := syscall.FcntlFlock(h.f.Fd(), unix.F_OFD_SETLK, &syscall.Flock_t{
|
||||
Type: int16(req.Lock.Type),
|
||||
Whence: io.SeekStart,
|
||||
Start: int64(req.Lock.Start),
|
||||
Len: int64(req.Lock.End) - int64(req.Lock.Start),
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LockWait acquires a lock on a byte range of the node, waiting
|
||||
// until the lock can be obtained (or context is canceled).
|
||||
func (h *Handle) LockWait(ctx context.Context, req *fuse.LockWaitRequest) error {
|
||||
log.Printf("dbg/lockwait %s -- %#v", h.f.Name(), req.Lock)
|
||||
return syscall.FcntlFlock(h.f.Fd(), F_OFD_SETLKW, &syscall.Flock_t{
|
||||
log.Printf("dbg/lockwait %p %s -- %#v", h, h.f.Name(), req.Lock)
|
||||
return syscall.FcntlFlock(h.f.Fd(), unix.F_OFD_SETLKW, &syscall.Flock_t{
|
||||
Type: int16(req.Lock.Type),
|
||||
Whence: io.SeekStart,
|
||||
Start: int64(req.Lock.Start),
|
||||
@@ -110,8 +109,8 @@ func (h *Handle) LockWait(ctx context.Context, req *fuse.LockWaitRequest) error
|
||||
// be released also implicitly, see HandleFlockLocker and
|
||||
// HandlePOSIXLocker.
|
||||
func (h *Handle) Unlock(ctx context.Context, req *fuse.UnlockRequest) error {
|
||||
log.Printf("dbg/unlock %s -- %#v", h.f.Name(), req.Lock)
|
||||
return syscall.FcntlFlock(h.f.Fd(), F_OFD_SETLK, &syscall.Flock_t{
|
||||
log.Printf("dbg/unlk %p %s -- %#v", h, h.f.Name(), req.Lock)
|
||||
return syscall.FcntlFlock(h.f.Fd(), unix.F_OFD_SETLK, &syscall.Flock_t{
|
||||
Type: int16(req.Lock.Type),
|
||||
Whence: io.SeekStart,
|
||||
Start: int64(req.Lock.Start),
|
||||
@@ -129,13 +128,15 @@ func (h *Handle) Unlock(ctx context.Context, req *fuse.UnlockRequest) error {
|
||||
// have Lock.Type F_UNLCK, and the whole struct should be
|
||||
// overwritten for in case of conflicting locks.
|
||||
func (h *Handle) QueryLock(ctx context.Context, req *fuse.QueryLockRequest, resp *fuse.QueryLockResponse) error {
|
||||
log.Printf("dbg/querylock %p %s -- %#v", h, h.f.Name(), req.Lock)
|
||||
|
||||
flock_t := syscall.Flock_t{
|
||||
Type: int16(req.Lock.Type),
|
||||
Whence: io.SeekStart,
|
||||
Start: int64(req.Lock.Start),
|
||||
Len: int64(req.Lock.End) - int64(req.Lock.Start),
|
||||
}
|
||||
if err := syscall.FcntlFlock(h.f.Fd(), F_OFD_GETLK, &flock_t); err != nil {
|
||||
if err := syscall.FcntlFlock(h.f.Fd(), unix.F_OFD_GETLK, &flock_t); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -147,3 +148,4 @@ func (h *Handle) QueryLock(ctx context.Context, req *fuse.QueryLockRequest, resp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user