fnc

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: MIT Imports: 2 Imported by: 1

README

fnc

Some useful functions about File and (Page) Cache

Documentation

Index

Constants

View Source
const O_NOATIME = syscall.O_NOATIME

Disable all File access time(atime) updates.

Variables

This section is empty.

Functions

func DisableReadAhead

func DisableReadAhead(f *os.File) (err error)

DisableReadAhead disables file readahead entirely.

func DropCache

func DropCache(f *os.File, offset, size int64) (err error)

DropCache drops page_cache in range.

func Exist

func Exist(path string) bool

Exist returns a file existed or not. Ignore error.

func Flush

func Flush(f *os.File, offset, size int64) (err error)

Flush flushes page_cache to disk in sync mode.

OS may create a burst of write I/O when dirty pages hit a threshold, so flush it under users' control maybe a better choice in sometime.

func FlushHint

func FlushHint(f *os.File, offset, size int64) (err error)

FlushHint flushes in async mode.

Warn: it can be stalled too in some situations.

func OpenFile

func OpenFile(path string, flag int, perm os.FileMode) (f *os.File, err error)

OpenFile opens a file with O_NOATIME flag.

func PreAllocate

func PreAllocate(f *os.File, size int64) (err error)

Preallocate allocates space for a new file. Avoid modify metadata & allocating space in future writing.

func ReadDirNames

func ReadDirNames(dir string) ([]string, error)

ReadDirNames returns the files names in the given directory.

func SyncDir

func SyncDir(dir string) (err error)

SyncDir syncs the given directory. Call it after rename, create new file etc if you want persist fs metadata. e.g. XFS uses delayed logging, may need SyncDir.

Types

This section is empty.

Jump to

Keyboard shortcuts

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