fstab

package module
v0.0.0-...-eb4090f Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2014 License: BSD-3-Clause Imports: 7 Imported by: 16

README

go-fstab

Build Status

Simple fstab parser for Go

Documentation

Overview

Package fstab parses and serializes linux filesystem mounts information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceIdentifierType

type DeviceIdentifierType int

type Mount

type Mount struct {
	// The block special device or remote filesystem to be mounted
	Spec string

	// The mount point for the filesystem
	File string

	// The type of the filesystem
	VfsType string

	// Mount options associated with the filesystem
	MntOps map[string]string

	// Used by dump to determine which filesystems need to be dumped.
	Freq int

	// Used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time
	PassNo int
}

Mount represetnts the filesystem info

func ParseLine

func ParseLine(line string) (mount *Mount, err error)

ParseLine parses a single line (of an fstab). It will most frequently return a Mount; however, If a parsing error occurs, `err` will be non-nil and provide an error message. If the line is either empy or a comment line, `mount` will also be nil.

func (*Mount) Equals

func (mount *Mount) Equals(other *Mount) bool

Equals compares 2 Mount objects

func (*Mount) IsNFS

func (mount *Mount) IsNFS() bool

func (*Mount) IsSwap

func (mount *Mount) IsSwap() bool

func (*Mount) MntOpsString

func (mount *Mount) MntOpsString() (opsstring string)

MntOpsString returns the serialized MntOps value

func (*Mount) PaddedString

func (mount *Mount) PaddedString(paddings ...int) string

PaddedString serializes the objet into fstab format with configurable column width. Each positional argument specifies the width for the column in order. Up to 6 arguments are supported, outstanding arguments will be ignored.

func (*Mount) SpecType

func (mount *Mount) SpecType() (spectype DeviceIdentifierType)

SpecType returns the device identifier type

func (*Mount) SpecValue

func (mount *Mount) SpecValue() string

SpecType returns the device identifier value; that is if Spec is "UUID=vogons-ate-my-sandwich", it will return "vogons-ate-my-sandwich"

func (*Mount) String

func (mount *Mount) String() string

String serializes the object into fstab format

type Mounts

type Mounts []*Mount

func Parse

func Parse(source io.Reader) (mounts Mounts, err error)

func ParseFile

func ParseFile(filename string) (mounts Mounts, err error)

ParseFile parses the given file

func ParseProc

func ParseProc() (mounts Mounts, err error)

ParseProc parses procfs information

func ParseSystem

func ParseSystem() (mounts Mounts, err error)

ParseSystem parses your system fstab ("/etc/fstab")

func (Mounts) PaddedString

func (mounts Mounts) PaddedString(paddings ...int) (output string)

PaddedString serializes a list of mounts to the fstab format with padding.

func (Mounts) String

func (mounts Mounts) String() (output string)

String serializes a list of mounts to the fstab format

Jump to

Keyboard shortcuts

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