// UnmountAll repeatedly unmounts the given mount point until there
// are no mounts remaining (EINVAL is returned by mount), which is
// useful for undoing a stack of mounts on the same mount point.
546952
func UnmountAll(mount string, flags int) error {
	for {
		if err := unmount(mount, flags); err != nil {
			// EINVAL is returned if the target is not a
			// mount point, indicating that we are
			// done. It can also indicate a few other
			// things (such as invalid flags) which we
			// unfortunately end up squelching here too.
			if err == unix.EINVAL {
				return nil
			}
			return err
		}
	}
}
393279
func (m *LinuxMount) ListAll() (mounts []MountInfo, err error) {
	fh, err := os.Open(m.ProcMount)
	if err != nil {
		return nil, err
	}
	defer fh.Close()
	reader := bufio.NewReader(fh)
	for {
		line, err := reader.ReadString('\n')
		if line = strings.TrimSpace(line); line != "" {
			var fields []string
			if fields = strings.Fields(line); len(fields) != 6 {
				return nil, ErrParseMount
			}
			mount := MountInfo{}
			mount.Device = fields[0]
			mount.MountPoint = fields[1]
			mount.FSType = fields[2]
			mount.Options = strings.Split(fields[3], ",")
			if mount.Dump, err = strconv.Atoi(fields[4]); err != nil {
				return nil, ErrParseMount
			}
			if mount.Fsck, err = strconv.Atoi(fields[5]); err != nil {
				return nil, ErrParseMount
			}
			mounts = append(mounts, mount)
		}
		if err == io.EOF {
			return mounts, nil
		} else if err != nil {
			return nil, err
		}
	}
}
618116
func (r *Router) Unmount(ctx context.Context, prefix string) error {
	ns, err := namespace.FromContext(ctx)
	if err != nil {
		return err
	}
	prefix = ns.Path + prefix

	r.l.Lock()
	defer r.l.Unlock()

	// Fast-path out if the backend doesn't exist
	raw, ok := r.root.Get(prefix)
	if !ok {
		return nil
	}

	// Call backend's Cleanup routine
	re := raw.(*routeEntry)
	if re.backend != nil {
		re.backend.Cleanup(ctx)
	}

	// Purge from the radix trees
	r.root.Delete(prefix)
	r.storagePrefix.Delete(re.storagePrefix)
	r.mountUUIDCache.Delete(re.mountEntry.UUID)
	r.mountAccessorCache.Delete(re.mountEntry.Accessor)

	return nil
}
353563
func (s *Bitset) UnsetAll() *Bitset {
	return s.unitOp(func(s *Bitset, i int) {
		s.set[i] = 0
	})
}
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
}
1093875
func forceUnmount(target string) (err error) {
	// Simple retry logic for unmount
	for i := 0; i < 10; i++ {
		if err = sysUnmount(target, 0); err == nil {
			return nil
		}
		time.Sleep(100 * time.Millisecond)
	}
	return
}
1134685
func (m *DefaultMounter) Unmount(target string, flags int, timeout int) error {
	return syscall.Unmount(target, flags)
}
613012
func (m *MountPoint) Cleanup() error {
	if m.Volume == nil || m.ID == "" {
		return nil
	}

	if err := m.Volume.Unmount(m.ID); err != nil {
		return errors.Wrapf(err, "error unmounting volume %s", m.Volume.Name())
	}

	m.active--
	if m.active == 0 {
		m.ID = ""
	}
	return nil
}
340738
func (daemon *Daemon) Unmount(container *container.Container) error {
	if container.RWLayer == nil {
		return errors.New("RWLayer of container " + container.ID + " is unexpectedly nil")
	}
	if err := container.RWLayer.Unmount(); err != nil {
		logrus.Errorf("Error unmounting container %s: %s", container.ID, err)
		return err
	}

	return nil
}
1045611
func Unmount(dir string, force bool, log Log) error {
	return fmt.Errorf("Unmount unsupported on this platform")
}
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
}
1239159
func (rl *referencedRWLayer) Unmount() error {
	return rl.layerStore.driver.Put(rl.mountedLayer.mountID)
}
781866
func (m *Mounter) RemoveMountPath(mountPath string, opts map[string]string) error {
	if _, err := os.Stat(mountPath); err == nil {
		if options.IsBoolOptionSet(opts, options.OptionsWaitBeforeDelete) {
			hasher := md5.New()
			hasher.Write([]byte(mountPath))
			symlinkName := hex.EncodeToString(hasher.Sum(nil))
			symlinkPath := path.Join(m.trashLocation, symlinkName)

			if err = os.Symlink(mountPath, symlinkPath); err != nil {
				if !os.IsExist(err) {
					logrus.Errorf("Error creating sym link %s => %s. Err: %v", symlinkPath, mountPath, err)
				}
			}

			if _, err = sched.Instance().Schedule(
				func(sched.Interval) {
					if err = m.removeMountPath(mountPath); err != nil {
						return
					}

					if err = os.Remove(symlinkPath); err != nil {
						return
					}
				},
				sched.Periodic(time.Second),
				time.Now().Add(mountPathRemoveDelay),
				true /* run only once */); err != nil {
				logrus.Errorf("Failed to schedule task to remove path:%v. Err: %v", mountPath, err)
				return err
			}
		} else {
			return m.removeMountPath(mountPath)
		}
	}

	return nil
}
1006899
func unmount_with_name(clientID C.h, service, volumeName *C.char) C.result {
	return C.result{}
}
196205
func Unmount(mount string, flags int) error {
	var (
		home, layerID = filepath.Split(mount)
		di            = hcsshim.DriverInfo{
			HomeDir: home,
		}
	)

	if err := hcsshim.UnprepareLayer(di, layerID); err != nil {
		return errors.Wrapf(err, "failed to unprepare layer %s", mount)
	}
	if err := hcsshim.DeactivateLayer(di, layerID); err != nil {
		return errors.Wrapf(err, "failed to deactivate layer %s", mount)
	}

	return nil
}
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")
	}
}
732890
func (mounter *Mounter) Unmount(target string) error {
	klog.V(4).Infof("Unmounting %s", target)
	command := exec.Command("umount", target)
	output, err := command.CombinedOutput()
	if err != nil {
		return fmt.Errorf("Unmount failed: %v\nUnmounting arguments: %s\nOutput: %s\n", err, target, string(output))
	}
	return nil
}