diff --git a/cmd/containers-storage/container.go b/cmd/containers-storage/container.go index b9b5063c2..b93bda85f 100644 --- a/cmd/containers-storage/container.go +++ b/cmd/containers-storage/container.go @@ -165,24 +165,6 @@ func setContainerBigData(flags *mflag.FlagSet, action string, m storage.Store, a return 0 } -func MountTempContainerSource(flags *mflag.FlagSet, action string, m storage.Store, args []string) int { - mountpoint, err := m.MountTempFromSource(args[0], args[1]) - if err != nil { - fmt.Fprintf(os.Stderr, "%+v\n", err) - return 1 - } - fmt.Fprintf(os.Stdout, "%s\n", mountpoint) - return 0 -} - -func RemoveTempContainerSource(flags *mflag.FlagSet, action string, m storage.Store, args []string) int { - if err := m.RemoveTemp(args[0]); err != nil { - fmt.Fprintf(os.Stderr, "%+v\n", err) - return 1 - } - return 0 -} - func getContainerDir(flags *mflag.FlagSet, action string, m storage.Store, args []string) int { path, err := m.ContainerDirectory(args[0]) if err != nil { @@ -323,19 +305,5 @@ func init() { addFlags: func(flags *mflag.FlagSet, cmd *command) { flags.BoolVar(&jsonOutput, []string{"-json", "j"}, jsonOutput, "Prefer JSON output") }, - }, - command{ - names: []string{"mount-temp"}, - optionsHelp: "[options [...]] containerNameOrID srcdir", - usage: "Mount srcdir for use by the container", - action: MountTempContainerSource, - minArgs: 2, - }, - command{ - names: []string{"remove-temp"}, - optionsHelp: "[options [...]] mountdir", - usage: "Remove mount from use by the container", - action: RemoveTempContainerSource, - minArgs: 1, }) } diff --git a/drivers/aufs/aufs.go b/drivers/aufs/aufs.go index 9e8254f92..e821bc0c5 100644 --- a/drivers/aufs/aufs.go +++ b/drivers/aufs/aufs.go @@ -742,14 +742,3 @@ func (a *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMapp func (a *Driver) SupportsShifting() bool { return false } - -// MountTempFromSource mounts a source directory from the host using -// graphdriver and returns the mountpoint -func (a *Driver) MountTempFromSource(sourcedir, source, mountLabel string) (string, error) { - return "", fmt.Errorf("aufs driver does not support mount temp options") -} - -// RemoveTemp removes temporary mountpoint from host using graphdriver -func (a *Driver) RemoveTemp(mountpoint string) error { - return fmt.Errorf("aufs driver does not support mount temp options") -} diff --git a/drivers/btrfs/btrfs.go b/drivers/btrfs/btrfs.go index 386a4d65f..30254d9fb 100644 --- a/drivers/btrfs/btrfs.go +++ b/drivers/btrfs/btrfs.go @@ -685,14 +685,3 @@ func (d *Driver) Exists(id string) bool { func (d *Driver) AdditionalImageStores() []string { return nil } - -// MountTempFromSource mounts a source directory from the host using -// graphdriver and returns the mountpoint -func (d *Driver) MountTempFromSource(sourcedir, source, mountLabel string) (string, error) { - return "", fmt.Errorf("btrfs driver does not support mount temp options") -} - -// RemoveTemp removes temporary mountpoint from host using graphdriver -func (d *Driver) RemoveTemp(source string) error { - return fmt.Errorf("btrfs driver does not support mount temp options") -} diff --git a/drivers/devmapper/driver.go b/drivers/devmapper/driver.go index 96de07ec1..13677c93a 100644 --- a/drivers/devmapper/driver.go +++ b/drivers/devmapper/driver.go @@ -242,14 +242,3 @@ func (d *Driver) Exists(id string) bool { func (d *Driver) AdditionalImageStores() []string { return nil } - -// MountTempFromSource mounts a source directory from the host using -// graphdriver and returns the mountpoint -func (d *Driver) MountTempFromSource(sourcedir, source, mountLabel string) (string, error) { - return "", fmt.Errorf("devmapper driver does not support mount temp options") -} - -// RemoveTemp removes temporary mountpoint from host using graphdriver -func (d *Driver) RemoveTemp(mountpoint string) error { - return fmt.Errorf("devmapper driver does not support mount temp options") -} diff --git a/drivers/driver.go b/drivers/driver.go index 545a23ca3..e8f8bd5a7 100644 --- a/drivers/driver.go +++ b/drivers/driver.go @@ -101,13 +101,6 @@ type ProtoDriver interface { Cleanup() error // AdditionalImageStores returns additional image stores supported by the driver AdditionalImageStores() []string - - // MountTempFromSource mounts a source directory from the host using - // graphdriver and returns the mountpoint - MountTempFromSource(sourcedir, source, mountLabel string) (string, error) - - // RemoveTemp removes temporary mountpoint from host using graphdriver - RemoveTemp(mountpoint string) error } // DiffDriver is the interface to use to implement graph diffs diff --git a/drivers/overlay/overlay.go b/drivers/overlay/overlay.go index bb1680dd6..ef83b6c87 100644 --- a/drivers/overlay/overlay.go +++ b/drivers/overlay/overlay.go @@ -1129,41 +1129,6 @@ func (d *Driver) SupportsShifting() bool { return d.options.mountProgram != "" } -// MountTempFromSource mounts a source directory from the host using -// graphdriver and returns the mountpoint -func (d *Driver) MountTempFromSource(sourceDir, source, mountLabel string) (string, error) { - rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps) - if err != nil { - return "", err - } - - upperDir := filepath.Join(sourceDir, "upper") - workDir := filepath.Join(sourceDir, "work") - mergeDir := filepath.Join(sourceDir, "merge") - if err := idtools.MkdirAllAs(upperDir, 0700, rootUID, rootGID); err != nil { - return "", errors.Wrapf(err, "failed to create the overlay %s directory", upperDir) - } - if err := idtools.MkdirAllAs(workDir, 0700, rootUID, rootGID); err != nil { - return "", errors.Wrapf(err, "failed to create the overlay %s directory", workDir) - } - if err := idtools.MkdirAllAs(mergeDir, 0700, rootUID, rootGID); err != nil { - return "", errors.Wrapf(err, "failed to create the overlay %s directory", mergeDir) - } - - opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s,private", source, upperDir, workDir) - mountData := label.FormatMountLabel(opts, mountLabel) - if err := mount.Mount("none", mergeDir, "overlay", mountData); err != nil { - return "", errors.Wrapf(err, "failed to mount overlay %s directory", mergeDir) - } - return mergeDir, nil -} - -// RemoveTemp removes temporary mountpoint from host using graphdriver -func (d *Driver) RemoveTemp(mountpoint string) error { - mount.Unmount(mountpoint) //Attempt to umount source - return os.RemoveAll(path.Dir(mountpoint)) -} - // dumbJoin is more or less a dumber version of filepath.Join, but one which // won't Clean() the path, allowing us to append ".." as a component and trust // pathname resolution to do some non-obvious work. diff --git a/drivers/vfs/driver.go b/drivers/vfs/driver.go index 93508bc19..9e256858c 100644 --- a/drivers/vfs/driver.go +++ b/drivers/vfs/driver.go @@ -224,14 +224,3 @@ func (d *Driver) AdditionalImageStores() []string { } return nil } - -// MountTempFromSource mounts a source directory from the host using -// graphdriver and returns the mountpoint -func (d *Driver) MountTempFromSource(id, source, mountLabel string) (string, error) { - return "", fmt.Errorf("vfs driver does not support mount temp options") -} - -// RemoveTemp removes temporary mountpoint from host using graphdriver -func (d *Driver) RemoveTemp(mountpoint string) error { - return fmt.Errorf("vfs driver does not support mount temp options") -} diff --git a/drivers/zfs/zfs.go b/drivers/zfs/zfs.go index 36be46197..eaa9e8bc5 100644 --- a/drivers/zfs/zfs.go +++ b/drivers/zfs/zfs.go @@ -447,14 +447,3 @@ func (d *Driver) Exists(id string) bool { func (d *Driver) AdditionalImageStores() []string { return nil } - -// MountTempFromSource mounts a source directory from the host using -// graphdriver and returns the mountpoint -func (d *Driver) MountTempFromSource(sourcedir, source, mountLabel string) (string, error) { - return "", fmt.Errorf("zfs driver does not support mount temp options") -} - -// RemoveTemp removes temporary mountpoint from host using graphdriver -func (d *Driver) RemoveTemp(mountpoint string) error { - return fmt.Errorf("zfs driver does not support mount temp options") -} diff --git a/store.go b/store.go index bbd8841cb..27b00f6fe 100644 --- a/store.go +++ b/store.go @@ -446,13 +446,6 @@ type Store interface { // GID maps (if any are defined) don't contain corresponding IDs. ContainerParentOwners(id string) ([]int, []int, error) - // MountTempFromSource mounts a source directory from the host using - // graphdriver and returns the mountpoint - MountTempFromSource(id, source string) (string, error) - - // RemoveTemp removes temporary mountpoint from host using graphdriver - RemoveTemp(mountpoint string) error - // Lookup returns the ID of a layer, image, or container with the specified // name or ID. Lookup(name string) (string, error) @@ -1462,42 +1455,6 @@ func (s *store) ImageBigDataSize(id, key string) (int64, error) { return -1, ErrSizeUnknown } -func (s *store) MountTempFromSource(id, source string) (string, error) { - rcstore, err := s.ContainerStore() - if err != nil { - return "", err - } - rcstore.RLock() - defer rcstore.Unlock() - container, err := rcstore.Get(id) - if err != nil { - return "", err - } - driver, err := s.GraphDriver() - if err != nil { - return "", err - } - middleDir := s.graphDriverName + "-containers" - sourcedir := filepath.Join(s.GraphRoot(), middleDir, id, strings.Replace(source, "/", "_", -1)) - - return driver.MountTempFromSource(sourcedir, source, container.MountLabel()) -} - -func (s *store) RemoveTemp(source string) error { - rcstore, err := s.ContainerStore() - if err != nil { - return err - } - rcstore.RLock() - defer rcstore.Unlock() - driver, err := s.GraphDriver() - if err != nil { - return err - } - - return driver.RemoveTemp(source) -} - func (s *store) ImageBigDataDigest(id, key string) (digest.Digest, error) { ristore, err := s.ImageStore() if err != nil {