Add a mounter that uses google's safe_format_and_mount.

This commit is contained in:
Brendan Burns
2015-01-15 21:30:13 -08:00
parent 6ba8b7dfb2
commit ac21ac24fa
4 changed files with 97 additions and 5 deletions

View File

@@ -34,23 +34,23 @@ import (
const FlagBind = syscall.MS_BIND
const FlagReadOnly = syscall.MS_RDONLY
type mounter struct{}
type Mounter struct{}
// Wraps syscall.Mount()
func (mounter *mounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
func (mounter *Mounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
glog.V(5).Infof("Mounting %s %s %s %d %s", source, target, fstype, flags, data)
return syscall.Mount(source, target, fstype, flags, data)
}
// Wraps syscall.Unmount()
func (mounter *mounter) Unmount(target string, flags int) error {
func (mounter *Mounter) Unmount(target string, flags int) error {
return syscall.Unmount(target, flags)
}
// How many times to retry for a consistent read of /proc/mounts.
const maxListTries = 3
func (mounter *mounter) List() ([]MountPoint, error) {
func (*Mounter) List() ([]MountPoint, error) {
hash1, err := readProcMounts(nil)
if err != nil {
return nil, err

View File

@@ -37,7 +37,7 @@ type Interface interface {
// New returns a mount.Interface for the current system.
func New() Interface {
return &mounter{}
return &Mounter{}
}
// This represents a single line in /proc/mounts or /etc/fstab.