// ForceUnmount tries to forcibly unmount a directory
975883
func ForceUnmount(dir string, log Log) error {
	switch runtime.GOOS {
	case "darwin":
		log.Info("Force unmounting with diskutil")
		out, err := exec.Command("/usr/sbin/diskutil", "unmountDisk", "force", dir).CombinedOutput()
		log.Debug("Output: %s", string(out))
		return err
	case "linux":
		log.Info("Force unmounting with umount -l")
		out, err := exec.Command("umount", "-l", dir).CombinedOutput()
		log.Debug("Output: %s", string(out))
		return err
	default:
		return errors.New("Forced unmount is not supported on this platform yet")
	}
}
300509
func MakeMount(mnt string) error {
	mounted, err := Mounted(mnt)
	if err != nil {
		return err
	}
	if mounted {
		return nil
	}

	return Mount(mnt, mnt, "none", "bind")
}
998721
func Unmount(target string, flags int) error {
	if err := unmount(target, flags); err != nil && err != unix.EINVAL {
		return err
	}
	return nil
}
808177
func filterUnmountedVolumes(mountedVolumes sets.String, expectedVolumes []string) []string {
	unmountedVolumes := []string{}
	for _, expectedVolume := range expectedVolumes {
		if !mountedVolumes.Has(expectedVolume) {
			unmountedVolumes = append(unmountedVolumes, expectedVolume)
		}
	}
	return unmountedVolumes
}
935187
func (f *Folder) addMount(path []string, dest string) error {
	if len(path) < 1 {
		return errors.Errorf("Path must not be empty")
	}
	name := path[0]
	if len(path) == 1 {
		f.Folders[name] = newMount(name, dest)
		return nil
	}
	next := f.getFolder(name)
	return next.addMount(path[1:], dest)
}
56150
func (s *VolumeServer) Mount(
	ctx context.Context,
	req *api.SdkVolumeMountRequest,
) (*api.SdkVolumeMountResponse, error) {

	if s.cluster() == nil || s.driver(ctx) == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	if len(req.GetVolumeId()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Must supply volume id")
	}
	if len(req.GetMountPath()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Invalid Mount Path")
	}

	// Get access rights
	err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write)
	if err != nil {
		return nil, err
	}

	err = s.driver(ctx).Mount(req.GetVolumeId(), req.GetMountPath(), req.GetDriverOptions())
	if err != nil {
		return nil, status.Errorf(
			codes.Internal,
			"Failed to mount volume %s: %v",
			req.GetVolumeId(),
			err.Error())
	}
	return &api.SdkVolumeMountResponse{}, err
}
1068250
func Unmount(target string) error {
	if err := exec.Command("auplink", target, "flush").Run(); err != nil {
		logger.WithError(err).Warnf("Couldn't run auplink before unmount %s", target)
	}
	return unix.Unmount(target, 0)
}
577245
func Unmount(target string) error {
	if err := exec.Command("auplink", target, "flush").Run(); err != nil {
		logrus.Warnf("Couldn't run auplink before unmount %s: %s", target, err)
	}
	if err := unix.Unmount(target, 0); err != nil {
		return err
	}
	return nil
}
867632
func (mount *MountInfo) Unmount() error {
	ret := C.ceph_unmount(mount.mount)
	if ret != 0 {
		log.Errorf("Unmount: Failed to unmount")
		return cephError(ret)
	}
	return nil
}
830672
func (m *deletedMounter) Unmount(
	sourcePath string,
	path string,
	flags int,
	timeout int,
	opts map[string]string,
) error {
	if sourcePath != AllDevices {
		return fmt.Errorf("DeletedMounter accepts only %v as sourcePath",
			AllDevices)
	}

	m.Lock()
	defer m.Unlock()

	failedUnmounts := make(DeviceMap)
	for k, v := range m.mounts {
		for _, p := range v.Mountpoint {
			logrus.Warnf("Unmounting deleted mount path %v->%v", k, p)
			if err := m.mountImpl.Unmount(p.Path, flags, timeout); err != nil {
				logrus.Warnf("Failed to unmount mount path %v->%v", k, p)
				addMountpoint(failedUnmounts, k, p)
			}
		}
	}
	m.mounts = failedUnmounts
	if len(m.mounts) > 0 {
		return fmt.Errorf("Not all paths could be unmounted")
	}

	return nil
}
1045611
func Unmount(dir string, force bool, log Log) error {
	return fmt.Errorf("Unmount unsupported on this platform")
}
322471
func (container *Container) DetachAndUnmount(volumeEventLog func(name, action string, attributes map[string]string)) error {
	networkMounts := container.NetworkMounts()
	mountPaths := make([]string, 0, len(container.MountPoints)+len(networkMounts))

	for _, mntPoint := range container.MountPoints {
		dest, err := container.GetResourcePath(mntPoint.Destination)
		if err != nil {
			logrus.Warnf("Failed to get volume destination path for container '%s' at '%s' while lazily unmounting: %v", container.ID, mntPoint.Destination, err)
			continue
		}
		mountPaths = append(mountPaths, dest)
	}

	for _, m := range networkMounts {
		dest, err := container.GetResourcePath(m.Destination)
		if err != nil {
			logrus.Warnf("Failed to get volume destination path for container '%s' at '%s' while lazily unmounting: %v", container.ID, m.Destination, err)
			continue
		}
		mountPaths = append(mountPaths, dest)
	}

	for _, mountPath := range mountPaths {
		if err := mount.Unmount(mountPath); err != nil {
			logrus.WithError(err).WithField("container", container.ID).
				Warn("Unable to unmount")
		}
	}
	return container.UnmountVolumes(volumeEventLog)
}
751269
func mountUnmount(next, prev ComponentOrHTML) Mounter {
	if next == prev {
		return nil
	}
	if !sameType(next, prev) {
		if prev != nil {
			unmount(prev)
		}
		if m, ok := next.(Mounter); ok {
			return m
		}
		return nil
	}
	if prevHTML := extractHTML(prev); prevHTML != nil {
		if nextHTML := extractHTML(next); nextHTML == nil || prevHTML.node != nextHTML.node {
			for _, child := range prevHTML.children {
				unmount(child)
			}
		}
	}
	if u, ok := prev.(Unmounter); ok {
		u.Unmount()
	}
	if m, ok := next.(Mounter); ok {
		return m
	}
	return nil
}
1366153
func Unmount(point string) error {
	var cmd *exec.Cmd
	switch runtime.GOOS {
	case "darwin":
		cmd = exec.Command("/usr/sbin/diskutil", "umount", "force", point)
	case "linux":
		cmd = exec.Command("fusermount", "-u", point)
	default:
		return errors.New("unmount: unimplemented")
	}

	errc := make(chan error, 1)
	go func() {
		if err := exec.Command("umount", point).Run(); err == nil {
			errc <- err
		}
		// retry to unmount with the fallback cmd
		errc <- cmd.Run()
	}()
	select {
	case <-time.After(1 * time.Second):
		return errors.New("umount timeout")
	case err := <-errc:
		return err
	}
}
88529
func (daemon *Daemon) conditionalUnmountOnCleanup(container *container.Container) error {

	// Bail out now for Linux containers
	if system.LCOWSupported() && container.OS != "windows" {
		return nil
	}

	// We do not unmount if a Hyper-V container
	if !daemon.runAsHyperVContainer(container.HostConfig) {
		return daemon.Unmount(container)
	}
	return nil
}
1333547
func unlinkDir(dir string) error {
	if err := syscall.Unmount(dir, 0); err != nil {
		if err != syscall.EINVAL {
			return err
		}
	}
	return nil
}
1263240
func (c *Core) unmount(ctx context.Context, path string) error {
	// Ensure we end the path in a slash
	if !strings.HasSuffix(path, "/") {
		path += "/"
	}

	// Prevent protected paths from being unmounted
	for _, p := range protectedMounts {
		if strings.HasPrefix(path, p) {
			return fmt.Errorf("cannot unmount %q", path)
		}
	}
	return c.unmountInternal(ctx, path, MountTableUpdateStorage)
}