disk

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package disk contains helpers to interact with the disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropCaches

func DropCaches(ctx context.Context) error

DropCaches will write dirty pages to disk with 'sync' so that they are not available for freeing and thus helps drop_caches to free more memory from file system and IO operations. 'drop_caches' will clear clean page caches, dentries (directory caches), and inodes (file caches).

func Fill

func Fill(dir string, tofill uint64) (string, error)

Fill creates a temporary file in a directory that fills the disk by allocating it, but without performing any actual IO to write the content.

func FillUntil

func FillUntil(dir string, remaining uint64) (string, error)

FillUntil reates a temporary file in a directory that fills the disk until less than remaining bytes are available.

func FreeSpace

func FreeSpace(path string) (uint64, error)

FreeSpace returns the number of free bytes available at a specific path

Types

type Refiller

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

Refiller maintains the temporary fill file for you, so you can easily (re-)adjust the disk space.

func NewRefiller

func NewRefiller(dir string) Refiller

NewRefiller creates a new refiller. `dir` is the directory to put the temporary file in.

Example:

refiller := NewRefiller(...)
defer func() {
  if err := refiller.Close(); err != nil {
    s.Error(...)
  }
}()
refiller.RefillUntil(...)
...
refiller.RefillUntil(...)
...

func (*Refiller) Close

func (r *Refiller) Close() error

Close removes the temporary file if there is one. You can call it as many times as you want, and you should also call it at the end of your tast to clean things up.

func (*Refiller) Refill

func (r *Refiller) Refill(tofill uint64) error

Refill removes the temporary file previously created, and then fill the disk. See `Fill()`.

func (*Refiller) RefillUntil

func (r *Refiller) RefillUntil(remaining uint64) error

RefillUntil removes the temporary file previously created, and then fill the disk. See `FillUntil()`.

Jump to

Keyboard shortcuts

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