Documentation
¶
Overview ¶
Package powerloss builds the files a power loss could leave in a directory, for the tests that play one. A Disk follows what a program does to the files of the directory, one call for each change, in the order the program made them. Crash then gives files a power loss at that moment could leave: what was synced is there, and of what was not, any part.
Index ¶
- Constants
- Variables
- type Disk
- func (d *Disk) Apply(seq int, c vfs.Change) (err error)
- func (d *Disk) Crash(kind int, garbage bool, rng *rand.Rand) map[string][]byte
- func (d *Disk) Create(name string)
- func (d *Disk) Delete(name string) error
- func (d *Disk) Rename(from, to string) error
- func (d *Disk) Sync(name string) error
- func (d *Disk) SyncDir()
- func (d *Disk) Truncate(seq int, name string, size int64) error
- func (d *Disk) Write(seq int, name string, off int64, data []byte) error
Constants ¶
const ( None = iota // none of it arrived All // all of it did, as when the process is killed First // what was done before some moment did Some // any part: of each write all its sectors, none, the first ones or any of them Kinds )
How a power loss treats what was not synced.
const NoDirSync = runtime.GOOS == "windows"
NoDirSync says the system has no directory to sync (Windows). A file made, deleted or renamed then counts as on disk at once: the tests check the syncs of the files there, not what the file system does with names.
Variables ¶
var KindNames = [...]string{"nothing unsynced arrived", "all arrived", "the first part arrived", "some writes arrived"}
KindNames says each kind in words.
Functions ¶
This section is empty.
Types ¶
type Disk ¶
type Disk struct {
// contains filtered or unexported fields
}
Disk is the files of one directory, and the ones it held when it was last synced.
func Start ¶
Start is the disk before the program runs: the files of dir, all of them synced. The directories in dir are left out.
func (*Disk) Apply ¶
Apply does c, a change the VFS told of (vfs.SetTrace), to the file of that name. seq is the place of c in the log. The VFS tells of no directory sync where the system has none (NoDirSync).
func (*Disk) Crash ¶
Crash gives the files a power loss now could leave, by name. kind says what arrived of what was not synced. With garbage, where a write that makes a file longer did not arrive, the file may be longer all the same and hold anything there: SQLite assumes a file system may set the size of a file before it writes the data.