当前位置: 首页>>代码示例>>Golang>>正文


Golang mount.Unmount函数代码示例

本文整理汇总了Golang中github.com/docker/docker/pkg/mount.Unmount函数的典型用法代码示例。如果您正苦于以下问题:Golang Unmount函数的具体用法?Golang Unmount怎么用?Golang Unmount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Unmount函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Put

// Put removes the existing mountpoint for the given id if it exists.
func (d *Driver) Put(id string) error {
	d.Lock()
	defer d.Unlock()

	mnt := d.active[id]
	if mnt == nil {
		logrus.Debugf("[zfs] Put on a non-mounted device %s", id)
		// but it might be still here
		if d.Exists(id) {
			err := mount.Unmount(d.mountPath(id))
			if err != nil {
				logrus.Debugf("[zfs] Failed to unmount %s zfs fs: %v", id, err)
			}
		}
		return nil
	}

	mnt.count--
	if mnt.count > 0 {
		return nil
	}

	defer delete(d.active, id)
	if mnt.mounted {
		logrus.Debugf(`[zfs] unmount("%s")`, mnt.path)

		if err := mount.Unmount(mnt.path); err != nil {
			return fmt.Errorf("error unmounting to %s: %v", mnt.path, err)
		}
	}
	return nil
}
开发者ID:docker,项目名称:v1.10-migrator,代码行数:33,代码来源:zfs.go

示例2: cleanupMounts

// cleanupMounts umounts shm/mqueue mounts for old containers
func (daemon *Daemon) cleanupMounts() error {
	logrus.Debugf("Cleaning up old shm/mqueue mounts: start.")
	f, err := os.Open("/proc/self/mountinfo")
	if err != nil {
		return err
	}
	defer f.Close()

	sc := bufio.NewScanner(f)
	for sc.Scan() {
		line := sc.Text()
		fields := strings.Split(line, " ")
		if strings.HasPrefix(fields[4], daemon.repository) {
			mnt := fields[4]
			mountBase := filepath.Base(mnt)
			if mountBase == "mqueue" || mountBase == "shm" {
				logrus.Debugf("Unmounting %+v", mnt)
				if err := mount.Unmount(mnt); err != nil {
					return err
				}
			}
		}
	}

	if err := sc.Err(); err != nil {
		return err
	}

	logrus.Debugf("Cleaning up old shm/mqueue mounts: done.")
	return nil
}
开发者ID:riseofthetigers,项目名称:docker,代码行数:32,代码来源:daemon_linux.go

示例3: StateChanged

// StateChanged updates plugin internals using libcontainerd events.
func (pm *Manager) StateChanged(id string, e libcontainerd.StateInfo) error {
	logrus.Debugf("plugin state changed %s %#v", id, e)

	switch e.State {
	case libcontainerd.StateExit:
		p, err := pm.pluginStore.GetByID(id)
		if err != nil {
			return err
		}

		pm.mu.RLock()
		c := pm.cMap[p]

		if c.exitChan != nil {
			close(c.exitChan)
		}
		restart := c.restart
		pm.mu.RUnlock()

		p.RemoveFromDisk()

		if p.PropagatedMount != "" {
			if err := mount.Unmount(p.PropagatedMount); err != nil {
				logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err)
			}
		}

		if restart {
			pm.enable(p, c, true)
		}
	}

	return nil
}
开发者ID:yuewko,项目名称:docker,代码行数:35,代码来源:manager.go

示例4: enable

func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error {
	p.Rootfs = filepath.Join(pm.libRoot, p.PluginObj.ID, "rootfs")
	if p.IsEnabled() && !force {
		return fmt.Errorf("plugin %s is already enabled", p.Name())
	}
	spec, err := p.InitSpec(oci.DefaultSpec())
	if err != nil {
		return err
	}

	c.restart = true
	c.exitChan = make(chan bool)

	pm.mu.Lock()
	pm.cMap[p] = c
	pm.mu.Unlock()

	if p.PropagatedMount != "" {
		if err := mount.MakeRShared(p.PropagatedMount); err != nil {
			return err
		}
	}

	if err := pm.containerdClient.Create(p.GetID(), "", "", specs.Spec(*spec), attachToLog(p.GetID())); err != nil {
		if p.PropagatedMount != "" {
			if err := mount.Unmount(p.PropagatedMount); err != nil {
				logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err)
			}
		}
		return err
	}

	return pm.pluginPostStart(p, c)
}
开发者ID:harche,项目名称:docker,代码行数:34,代码来源:manager_linux.go

示例5: New

// New instantiates a new Root instance with the provided scope. Scope
// is the base path that the Root instance uses to store its
// volumes. The base path is created here if it does not exist.
func New(scope string, rootUID, rootGID int) (*Root, error) {
	rootDirectory := filepath.Join(scope, volumesPathName)

	if err := idtools.MkdirAllAs(rootDirectory, 0700, rootUID, rootGID); err != nil {
		return nil, err
	}

	r := &Root{
		scope:   scope,
		path:    rootDirectory,
		volumes: make(map[string]*localVolume),
		rootUID: rootUID,
		rootGID: rootGID,
	}

	dirs, err := ioutil.ReadDir(rootDirectory)
	if err != nil {
		return nil, err
	}

	mountInfos, err := mount.GetMounts()
	if err != nil {
		logrus.Debugf("error looking up mounts for local volume cleanup: %v", err)
	}

	for _, d := range dirs {
		if !d.IsDir() {
			continue
		}

		name := filepath.Base(d.Name())
		v := &localVolume{
			driverName: r.Name(),
			name:       name,
			path:       r.DataPath(name),
		}
		r.volumes[name] = v
		optsFilePath := filepath.Join(rootDirectory, name, "opts.json")
		if b, err := ioutil.ReadFile(optsFilePath); err == nil {
			opts := optsConfig{}
			if err := json.Unmarshal(b, &opts); err != nil {
				return nil, err
			}
			if !reflect.DeepEqual(opts, optsConfig{}) {
				v.opts = &opts
			}

			// unmount anything that may still be mounted (for example, from an unclean shutdown)
			for _, info := range mountInfos {
				if info.Mountpoint == v.path {
					mount.Unmount(v.path)
					break
				}
			}
		}
	}

	return r, nil
}
开发者ID:maxim28,项目名称:docker,代码行数:62,代码来源:local.go

示例6: Cleanup

// Cleanup aufs and unmount all mountpoints
func (a *Driver) Cleanup() error {
	for id, m := range a.active {
		if err := a.unmount(m); err != nil {
			logrus.Errorf("Unmounting %s: %s", stringid.TruncateID(id), err)
		}
	}
	return mountpk.Unmount(a.root)
}
开发者ID:leobcn,项目名称:docker,代码行数:9,代码来源:aufs.go

示例7: Cleanup

// Cleanup unmounts a device.
func (d *Driver) Cleanup() error {
	err := d.DeviceSet.Shutdown()

	if err2 := mount.Unmount(d.home); err == nil {
		err = err2
	}

	return err
}
开发者ID:jasonamyers,项目名称:docker,代码行数:10,代码来源:driver.go

示例8: Cleanup

// Cleanup unmounts the home directory.
func (d *Driver) Cleanup() error {
	if quotaEnabled {
		if err := subvolDisableQuota(d.home); err != nil {
			return err
		}
	}

	return mount.Unmount(d.home)
}
开发者ID:harche,项目名称:docker,代码行数:10,代码来源:btrfs.go

示例9: Put

// Put removes the existing mountpoint for the given id if it exists.
func (d *Driver) Put(id string) error {
	mountpoint := d.MountPath(id)
	logrus.Debugf(`[zfs] unmount("%s")`, mountpoint)

	if err := mount.Unmount(mountpoint); err != nil {
		return fmt.Errorf("error unmounting to %s: %v", mountpoint, err)
	}
	return nil
}
开发者ID:nilsotto,项目名称:docker,代码行数:10,代码来源:zfs.go

示例10: Put

// Put removes the existing mountpoint for the given id if it exists.
func (d *Driver) Put(id string) error {
	mountpoint := d.mountPath(id)
	mounted, err := graphdriver.Mounted(graphdriver.FsMagicZfs, mountpoint)
	if err != nil || !mounted {
		return err
	}

	logrus.Debugf(`[zfs] unmount("%s")`, mountpoint)

	if err := mount.Unmount(mountpoint); err != nil {
		return fmt.Errorf("error unmounting to %s: %v", mountpoint, err)
	}
	return nil
}
开发者ID:vmware,项目名称:vic,代码行数:15,代码来源:zfs.go

示例11: Cleanup

// During cleanup aufs needs to unmount all mountpoints
func (a *Driver) Cleanup() error {
	ids, err := loadIds(path.Join(a.rootPath(), "layers"))
	if err != nil {
		return err
	}

	for _, id := range ids {
		if err := a.unmount(id); err != nil {
			log.Errorf("Unmounting %s: %s", utils.TruncateID(id), err)
		}
	}

	return mountpk.Unmount(a.root)
}
开发者ID:Crispy1975,项目名称:deis,代码行数:15,代码来源:aufs.go

示例12: UmountRoot

func (m *Mounter) UmountRoot() error {
	mounts, err := m.GetMountsRoot()
	if err != nil {
		return err
	}

	for _, mo := range mounts {
		if err := mount.Unmount(mo.Mountpoint); err != nil {
			return err
		}
		log.Debug("umount:", mo.Mountpoint)
	}

	return nil
}
开发者ID:yuuki,项目名称:droot,代码行数:15,代码来源:mount.go

示例13: Unmount

// Umount is for satisfying the localVolume interface and does not do anything in this driver.
func (v *localVolume) Unmount(id string) error {
	v.m.Lock()
	defer v.m.Unlock()
	if v.opts != nil {
		v.active.count--
		if v.active.count == 0 {
			if err := mount.Unmount(v.path); err != nil {
				v.active.count++
				return err
			}
			v.active.mounted = false
		}
	}
	return nil
}
开发者ID:Chandra-TechPassionate,项目名称:docker,代码行数:16,代码来源:local.go

示例14: Unmount

// Umount is for satisfying the localVolume interface and does not do anything in this driver.
func (v *localVolume) Unmount(id string) error {
	v.m.Lock()
	defer v.m.Unlock()
	if v.opts != nil {
		v.active.count--
		if v.active.count == 0 {
			if err := mount.Unmount(v.path); err != nil {
				v.active.count++
				return errors.Wrapf(err, "error while unmounting volume path '%s'", v.path)
			}
			v.active.mounted = false
		}
	}
	return nil
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:16,代码来源:local.go

示例15: Cleanup

// Cleanup aufs and unmount all mountpoints
func (a *Driver) Cleanup() error {
	var dirs []string
	if err := filepath.Walk(a.mntPath(), func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if !info.IsDir() {
			return nil
		}
		dirs = append(dirs, path)
		return nil
	}); err != nil {
		return err
	}

	for _, m := range dirs {
		if err := a.unmount(m); err != nil {
			logrus.Debugf("aufs error unmounting %s: %s", stringid.TruncateID(m), err)
		}
	}
	return mountpk.Unmount(a.root)
}
开发者ID:ungureanuvladvictor,项目名称:docker,代码行数:23,代码来源:aufs.go


注:本文中的github.com/docker/docker/pkg/mount.Unmount函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。