Documentation ¶
Overview ¶
Package file implements the block.Device interface backed by a traditional file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a block device backed by a file on a traditional file system.
func New ¶
New creates and returns a new File, using f as the backing store. The size of the block device represented by the returned File will be the size of f. New will not close f if any errors occur. New will also attempt to detect the block size for f and will use defaultBlockSize if it is unable to do so. If there is an error, it will be of type *os.PathError.
func NewRange ¶
NewRange creates and returns a new File, using a subset of f as the backing store. The blockSize, offset and size must be provided.
func (*File) BlockSize ¶
BlockSize returns the size in bytes of the smallest block that can be written by the File. The return value is undefined after Close() is called.
func (*File) Close ¶
Close calls Flush() and then closes the device, rendering it unusable for I/O. It returns an error, if any.
func (*File) Discard ¶
Discard marks the address range [off, off+size) as being unused, allowing it to be reclaimed by the device for other purposes. Both off and size must be multiples of Blocksize(). Returns an error, if any.
func (*File) Flush ¶
Flush forces any writes that have been cached in memory to be committed to persistent storage. Returns an error, if any.
func (*File) ReadAt ¶
ReadAt reads len(p) bytes from the device starting at offset off. Both off and len(p) must be multiples of BlockSize(). It returns the number of bytes read and the error, if any. ReadAt always returns a non-nil error when n < len(p).
func (*File) Size ¶
Size returns the fixed size of the File in bytes. The return value is undefined after Close() is called.