nbd

package
v0.1.1-fish Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2016 License: Apache-2.0, MIT Imports: 12 Imported by: 0

README

nbd

Golang Linux Network Block Device as a local block device in user space.

Documentation

Overview

Package nbd uses the Linux NBD layer to emulate a block device in user space

Index

Constants

View Source
const (
	// Defined in <linux/fs.h>:
	BLKROSET = 4701
)

Variables

This section is empty.

Functions

func FindDevice

func FindDevice() (string, error)

Types

type Device

type Device interface {
	ReadAt(b []byte, off int64) (n int, err error)
	WriteAt(b []byte, off int64) (n int, err error)
	Sync() error
	Trim(off, len int64) error
	Size() uint64
	Close() error
}

Device interface is a subset of os.File.

type DeviceFinder added in v0.1.1

type DeviceFinder interface {
	FindDevice(name string) (Device, error)
	ListDevices() ([]string, error)
}

type NBD

type NBD struct {
	// contains filtered or unexported fields
}

func Create

func Create(device Device, size int64, blocksize int64) *NBD

func (*NBD) Close

func (nbd *NBD) Close() error

func (*NBD) Disconnect added in v0.1.0

func (nbd *NBD) Disconnect() error

func (*NBD) IsConnected

func (nbd *NBD) IsConnected() bool

return true if connected

func (*NBD) OpenDevice added in v0.1.0

func (nbd *NBD) OpenDevice(dev string) (string, error)

func (*NBD) Serve

func (nbd *NBD) Serve() error

func (*NBD) SetBlockSize added in v0.1.0

func (nbd *NBD) SetBlockSize(blocksize int64) error

func (*NBD) SetSize added in v0.1.0

func (nbd *NBD) SetSize(size int64) error

func (*NBD) Size

func (nbd *NBD) Size() int64

type NBDConn added in v0.1.1

type NBDConn struct {
	// contains filtered or unexported fields
}

func (*NBDConn) Close added in v0.1.1

func (c *NBDConn) Close() error

type NBDServer added in v0.1.1

type NBDServer struct {
	// contains filtered or unexported fields
}

func NewNBDServer added in v0.1.1

func NewNBDServer(addr string, finder DeviceFinder) (*NBDServer, error)

func (*NBDServer) Close added in v0.1.1

func (s *NBDServer) Close() error

func (*NBDServer) Serve added in v0.1.1

func (s *NBDServer) Serve() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL