daemon: move sortMounts to a platform-agnostic file

The same code was used both on Linux and Windows; move it to a platform-
agnostic file so that both can use this function, which contains GoDoc
describing the functionality.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-07-26 13:12:01 +02:00
parent 50c3d19179
commit 39c79e08e4
4 changed files with 11 additions and 14 deletions

View File

@@ -6,7 +6,6 @@ import (
"context"
"fmt"
"os"
"sort"
"strconv"
"strings"
@@ -121,14 +120,6 @@ func (daemon *Daemon) setupMounts(ctx context.Context, c *container.Container) (
return append(mounts, netMounts...), cleanups.Release(), nil
}
// sortMounts sorts an array of mounts in lexicographic order. This ensure that
// when mounting, the mounts don't shadow other mounts. For example, if mounting
// /etc and /etc/resolv.conf, /etc/resolv.conf must not be mounted first.
func sortMounts(m []container.Mount) []container.Mount {
sort.Sort(mounts(m))
return m
}
// setBindModeIfNull is platform specific processing to ensure the
// shared mode is set to 'z' if it is null. This is called in the case
// of processing a named volume and not a typical bind.