Revert "Add MountTempFromSource and RemoveTemp interfaces"

This reverts commit e9695564db.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh 2019-05-02 10:42:04 -04:00
parent 91cf837e44
commit ef42340c2e
No known key found for this signature in database
GPG Key ID: A2DF901DABE2C028
9 changed files with 0 additions and 172 deletions

View File

@ -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,
})
}

View File

@ -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")
}

View File

@ -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")
}

View File

@ -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")
}

View File

@ -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

View File

@ -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.

View File

@ -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")
}

View File

@ -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")
}

View File

@ -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 {