Skip to content

Commit 8754687

Browse files
committed
libpod: move linux-specific code to _linux.go
This fixes a few "unused" linter warnings on freebsd. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent c1c963a commit 8754687

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

libpod/container_inspect.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/containers/podman/v5/libpod/driver"
1212
"github.com/containers/podman/v5/pkg/signal"
1313
"github.com/containers/podman/v5/pkg/util"
14-
"github.com/containers/storage/types"
1514
"github.com/docker/go-units"
1615
spec "github.com/opencontainers/runtime-spec/specs-go"
1716
"github.com/sirupsen/logrus"
@@ -491,17 +490,6 @@ func (c *Container) generateInspectContainerConfig(spec *spec.Spec) *define.Insp
491490
return ctrConfig
492491
}
493492

494-
func generateIDMappings(idMappings types.IDMappingOptions) *define.InspectIDMappings {
495-
var inspectMappings define.InspectIDMappings
496-
for _, uid := range idMappings.UIDMap {
497-
inspectMappings.UIDMap = append(inspectMappings.UIDMap, fmt.Sprintf("%d:%d:%d", uid.ContainerID, uid.HostID, uid.Size))
498-
}
499-
for _, gid := range idMappings.GIDMap {
500-
inspectMappings.GIDMap = append(inspectMappings.GIDMap, fmt.Sprintf("%d:%d:%d", gid.ContainerID, gid.HostID, gid.Size))
501-
}
502-
return &inspectMappings
503-
}
504-
505493
// Generate the InspectContainerHostConfig struct for the HostConfig field of
506494
// Inspect.
507495
func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, namedVolumes []*ContainerNamedVolume, mounts []spec.Mount) (*define.InspectContainerHostConfig, error) {
@@ -659,29 +647,6 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
659647
return hostConfig, nil
660648
}
661649

662-
// Return true if the container is running in the host's PID NS.
663-
func (c *Container) inHostPidNS() (bool, error) {
664-
if c.config.PIDNsCtr != "" {
665-
return false, nil
666-
}
667-
ctrSpec, err := c.specFromState()
668-
if err != nil {
669-
return false, err
670-
}
671-
if ctrSpec.Linux != nil {
672-
// Locate the spec's PID namespace.
673-
// If there is none, it's pid=host.
674-
// If there is one and it has a path, it's "ns:".
675-
// If there is no path, it's default - the empty string.
676-
for _, ns := range ctrSpec.Linux.Namespaces {
677-
if ns.Type == spec.PIDNamespace {
678-
return false, nil
679-
}
680-
}
681-
}
682-
return true, nil
683-
}
684-
685650
func (c *Container) GetDevices(priv bool, ctrSpec spec.Spec, deviceNodes map[string]string) ([]define.InspectDevice, error) {
686651
devices := []define.InspectDevice{}
687652
if ctrSpec.Linux != nil && !priv {

libpod/container_inspect_linux.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/containers/common/pkg/config"
1111
"github.com/containers/podman/v5/libpod/define"
1212
"github.com/containers/podman/v5/pkg/util"
13+
"github.com/containers/storage/types"
1314
"github.com/moby/sys/capability"
1415
spec "github.com/opencontainers/runtime-spec/specs-go"
1516
"github.com/sirupsen/logrus"
@@ -309,3 +310,37 @@ func (c *Container) platformInspectContainerHostConfig(ctrSpec *spec.Spec, hostC
309310

310311
return nil
311312
}
313+
314+
func generateIDMappings(idMappings types.IDMappingOptions) *define.InspectIDMappings {
315+
var inspectMappings define.InspectIDMappings
316+
for _, uid := range idMappings.UIDMap {
317+
inspectMappings.UIDMap = append(inspectMappings.UIDMap, fmt.Sprintf("%d:%d:%d", uid.ContainerID, uid.HostID, uid.Size))
318+
}
319+
for _, gid := range idMappings.GIDMap {
320+
inspectMappings.GIDMap = append(inspectMappings.GIDMap, fmt.Sprintf("%d:%d:%d", gid.ContainerID, gid.HostID, gid.Size))
321+
}
322+
return &inspectMappings
323+
}
324+
325+
// Return true if the container is running in the host's PID NS.
326+
func (c *Container) inHostPidNS() (bool, error) {
327+
if c.config.PIDNsCtr != "" {
328+
return false, nil
329+
}
330+
ctrSpec, err := c.specFromState()
331+
if err != nil {
332+
return false, err
333+
}
334+
if ctrSpec.Linux != nil {
335+
// Locate the spec's PID namespace.
336+
// If there is none, it's pid=host.
337+
// If there is one and it has a path, it's "ns:".
338+
// If there is no path, it's default - the empty string.
339+
for _, ns := range ctrSpec.Linux.Namespaces {
340+
if ns.Type == spec.PIDNamespace {
341+
return false, nil
342+
}
343+
}
344+
}
345+
return true, nil
346+
}

libpod/oci_conmon_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ func (r *ConmonOCIRuntime) withContainerSocketLabel(ctr *Container, closure func
164164
return err
165165
}
166166

167+
// Create systemd unit name for cgroup scopes.
168+
func createUnitName(prefix string, name string) string {
169+
return fmt.Sprintf("%s-%s.scope", prefix, name)
170+
}
171+
167172
// moveConmonToCgroupAndSignal gets a container's cgroupParent and moves the conmon process to that cgroup
168173
// it then signals for conmon to start by sending nonce data down the start fd
169174
func (r *ConmonOCIRuntime) moveConmonToCgroupAndSignal(ctr *Container, cmd *exec.Cmd, startFd *os.File) error {

libpod/oci_util.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ type ociError struct {
2727
Msg string `json:"msg,omitempty"`
2828
}
2929

30-
// Create systemd unit name for cgroup scopes
31-
func createUnitName(prefix string, name string) string {
32-
return fmt.Sprintf("%s-%s.scope", prefix, name)
33-
}
34-
3530
// Bind ports to keep them closed on the host
3631
func bindPorts(ports []types.PortMapping) ([]*os.File, error) {
3732
var files []*os.File

0 commit comments

Comments
 (0)