// WithMount adds an mount
978542
func WithMount(m mounttypes.Mount) func(*TestContainerConfig) {
	return func(c *TestContainerConfig) {
		c.HostConfig.Mounts = append(c.HostConfig.Mounts, m)
	}
}
909752
func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
	cfg, err := ipfs.Repo.Config()
	if err != nil {
		return nil, err
	}
	allow_other := cfg.Mounts.FuseAllowOther
	fsys := NewFileSystem(ipfs)
	return mount.NewMount(ipfs.Process, fsys, mountpoint, allow_other)
}
471659
func Unmount(dir string, force bool, log Log) error {
	if !force {
		mounted, err := IsMounted(dir, log)
		if err != nil {
			return err
		}
		if !mounted {
			return fmt.Errorf("Not mounted")
		}
	}

	log.Info("Trying to unmount: %s", dir)
	err := fuse.Unmount(dir)
	if err != nil {
		if !force {
			return err
		}
		// Unmount failed and we want to force it.
		log.Info("Unmount %s failed: %s; We will try to force it", dir, err)
		err = ForceUnmount(dir, log)
	}
	return err
}
755720
func Mount(driver Driver, remotePath, localPath string) error {
	// check if the driver is installed
	if err := driver.Installed(); err != nil {
		return err
	}

	// validate that the remote path
	if ok := func(remotePath string) bool {
		parts := strings.Split(remotePath, ":")
		if len(parts) != 2 {
			return false
		}

		ip := net.ParseIP(parts[0])
		if ip == nil {
			return false
		}

		dest := filepath.Clean(parts[1])
		return dest != "/" && filepath.IsAbs(dest)
	}(remotePath); !ok {
		return ErrMalformedNFSMountpoint
	}

	var mountInfo proc.NFSMountInfo
	mountError := driver.Info(localPath, &mountInfo)

	needsReMount := false

	if mountError == nil {
		// we need to check for a stale NFS mount
		if staleNFSCheck(localPath) {
			glog.Infof("Detected stale NFS mount, re-mounting %s", localPath)
			//unmount and re-mount
			needsReMount = true
			if err := driver.Unmount(localPath); err != nil {
				glog.Errorf("Error while unmounting %s: %s", localPath, err)
				return err
			}

		}
	}

	if mountError == proc.ErrMountPointNotFound || needsReMount {
		// the mountpoint is not found so try to mount
		glog.Infof("Creating new mount for %s -> %s", remotePath, localPath)
		if err := os.MkdirAll(localPath, 0775); err != nil {
			return err
		}
		if err := driver.Mount(remotePath, localPath, time.Second*30); err != nil {
			glog.Errorf("Error while creating mount point for %s -> %s: %s", remotePath, localPath, err)
			return err
		}

		// get the mount point
		mountError = driver.Info(localPath, &mountInfo)
	}

	if mountError != nil {
		// we should have a mount point by now or bust
		glog.Errorf("Could not get volume info for %s (mounting from %s): %s", localPath, remotePath, mountError)
		return mountError
	}

	// validate mount info
	glog.Infof("Mount Info: %+v", mountInfo)
	verr := validation.NewValidationError()
	verr.Add(validation.StringsEqual(remotePath, mountInfo.RemotePath, ""))
	verr.Add(validation.StringsEqual("nfs4", mountInfo.FSType, fmt.Sprintf("%s not mounted nfs4, %s instead", mountInfo.LocalPath, mountInfo.FSType)))

	if verr.HasError() {
		// the mountpoint is stale or wrong, so unmount
		glog.Warningf("Stale mount point at %s (mounting %s)", localPath, remotePath)
		if err := driver.Unmount(localPath); err != nil {
			glog.Errorf("Could not unmount %s: %s", localPath, err)
		}
		return verr
	}

	return nil
}
545731
func (c *Client) SSHHelperWithMountPoint(mountPoint string) *SSHHelper {
	return &SSHHelper{
		c:          c,
		MountPoint: mountPoint,
	}
}
1110760
func (m *Mount) Mount(target string) error {
	if m.Type != "windows-layer" {
		return errors.Errorf("invalid windows mount type: '%s'", m.Type)
	}

	home, layerID := filepath.Split(m.Source)

	parentLayerPaths, err := m.GetParentPaths()
	if err != nil {
		return err
	}

	var di = hcsshim.DriverInfo{
		HomeDir: home,
	}

	if err = hcsshim.ActivateLayer(di, layerID); err != nil {
		return errors.Wrapf(err, "failed to activate layer %s", m.Source)
	}
	defer func() {
		if err != nil {
			hcsshim.DeactivateLayer(di, layerID)
		}
	}()

	if err = hcsshim.PrepareLayer(di, layerID, parentLayerPaths); err != nil {
		return errors.Wrapf(err, "failed to prepare layer %s", m.Source)
	}
	return nil
}
1144477
func (c *Client) SSHWithMountPoint(mountPoint string) *SSH {
	return &SSH{
		c:          c,
		MountPoint: mountPoint,
	}
}
367562
func (v *localVolume) Mount(id string) (string, error) {
	v.m.Lock()
	defer v.m.Unlock()
	if v.opts != nil {
		if !v.active.mounted {
			if err := v.mount(); err != nil {
				return "", errdefs.System(err)
			}
			v.active.mounted = true
		}
		v.active.count++
	}
	return v.path, nil
}
981289
func (m *DefaultMounter) Mount(
	source string,
	target string,
	fstype string,
	flags uintptr,
	data string,
	timeout int,
) error {
	return syscall.Mount(source, target, fstype, flags, data)
}
1134685
func (m *DefaultMounter) Unmount(target string, flags int, timeout int) error {
	return syscall.Unmount(target, flags)
}
756857
func (m *mounter) Mount() (err error) {
	defer func() {
		if err != nil {
			msg := fmt.Sprintf("KBFS failed to FUSE mount at %s: %s", m.options.MountPoint, err)
			fmt.Println(msg)
			m.log.Warning(msg)
		}
	}()

	m.c, err = fuseMountDir(m.options.MountPoint, m.options.PlatformParams)
	// Exit if we were successful or we are not a force mounting on error.
	// Otherwise, try unmounting and mounting again.
	if err == nil || !m.options.ForceMount {
		return err
	}

	// Mount failed, let's try to unmount and then try mounting again, even
	// if unmounting errors here.
	m.Unmount()

	// In case we are on darwin, ask the installer to reinstall the mount dir
	// and try again as the last resort. This specifically fixes a situation
	// where /keybase gets created and owned by root after Keybase app is
	// started, and `kbfs` later fails to mount because of a permission error.
	m.reinstallMountDirIfPossible()
	m.c, err = fuseMountDir(m.options.MountPoint, m.options.PlatformParams)

	return err
}
147811
func (container *Container) NetworkMounts() []Mount {
	var mounts []Mount
	shared := container.HostConfig.NetworkMode.IsContainer()
	parser := volumemounts.NewParser(container.OS)
	if container.ResolvConfPath != "" {
		if _, err := os.Stat(container.ResolvConfPath); err != nil {
			logrus.Warnf("ResolvConfPath set to %q, but can't stat this filename (err = %v); skipping", container.ResolvConfPath, err)
		} else {
			writable := !container.HostConfig.ReadonlyRootfs
			if m, exists := container.MountPoints["/etc/resolv.conf"]; exists {
				writable = m.RW
			} else {
				label.Relabel(container.ResolvConfPath, container.MountLabel, shared)
			}
			mounts = append(mounts, Mount{
				Source:      container.ResolvConfPath,
				Destination: "/etc/resolv.conf",
				Writable:    writable,
				Propagation: string(parser.DefaultPropagationMode()),
			})
		}
	}
	if container.HostnamePath != "" {
		if _, err := os.Stat(container.HostnamePath); err != nil {
			logrus.Warnf("HostnamePath set to %q, but can't stat this filename (err = %v); skipping", container.HostnamePath, err)
		} else {
			writable := !container.HostConfig.ReadonlyRootfs
			if m, exists := container.MountPoints["/etc/hostname"]; exists {
				writable = m.RW
			} else {
				label.Relabel(container.HostnamePath, container.MountLabel, shared)
			}
			mounts = append(mounts, Mount{
				Source:      container.HostnamePath,
				Destination: "/etc/hostname",
				Writable:    writable,
				Propagation: string(parser.DefaultPropagationMode()),
			})
		}
	}
	if container.HostsPath != "" {
		if _, err := os.Stat(container.HostsPath); err != nil {
			logrus.Warnf("HostsPath set to %q, but can't stat this filename (err = %v); skipping", container.HostsPath, err)
		} else {
			writable := !container.HostConfig.ReadonlyRootfs
			if m, exists := container.MountPoints["/etc/hosts"]; exists {
				writable = m.RW
			} else {
				label.Relabel(container.HostsPath, container.MountLabel, shared)
			}
			mounts = append(mounts, Mount{
				Source:      container.HostsPath,
				Destination: "/etc/hosts",
				Writable:    writable,
				Propagation: string(parser.DefaultPropagationMode()),
			})
		}
	}
	return mounts
}
59815
func CreateMount() (*MountInfo, error) {
	mount := &MountInfo{}
	ret := C.ceph_create(&mount.mount, nil)
	if ret != 0 {
		log.Errorf("CreateMount: Failed to create mount")
		return nil, cephError(ret)
	}
	return mount, nil
}
556177
func (r *Store) Mounts() map[string]string {
	m := make(map[string]string, len(r.mounts))
	for alias, sub := range r.mounts {
		m[alias] = sub.Path()
	}
	return m
}
625663
func Unmount(target string) error {
	if mounted, err := Mounted(target); err != nil || !mounted {
		return err
	}
	return ForceUnmount(target)
}
388539
func Unmount(driver Driver, localPath string) error {
	// check if the driver is installed
	if err := driver.Installed(); err != nil {
		return err
	}

	// verify mount
	var mountInfo proc.NFSMountInfo
	if err := driver.Info(localPath, &mountInfo); err != nil {
		glog.Errorf("Could not get volume info for %s: %s", localPath, err)
		return err
	}

	if err := driver.Unmount(localPath); err != nil {
		glog.Errorf("Could not unmount %s: %s", localPath, err)
		return err
	}

	return nil
}
1279010
func (r *Store) AddMount(ctx context.Context, alias, path string, keys ...string) error {
	if err := r.addMount(ctx, alias, path, nil, keys...); err != nil {
		return errors.Wrapf(err, "failed to add mount")
	}

	// check for duplicate mounts
	return r.checkMounts()
}