podman

Форк
0
/
container_stat_linux.go 
40 строк · 1.3 Кб
1
//go:build !remote
2

3
package libpod
4

5
import (
6
	"github.com/containers/buildah/copier"
7
	"github.com/containers/podman/v5/libpod/define"
8
)
9

10
// statInsideMount stats the specified path *inside* the container's mount and PID
11
// namespace.  It returns the file info along with the resolved root ("/") and
12
// the resolved path (relative to the root).
13
func (c *Container) statInsideMount(containerPath string) (*copier.StatForItem, string, string, error) {
14
	resolvedRoot := "/"
15
	resolvedPath := c.pathAbs(containerPath)
16
	var statInfo *copier.StatForItem
17

18
	err := c.joinMountAndExec(
19
		func() error {
20
			var statErr error
21
			statInfo, statErr = secureStat(resolvedRoot, resolvedPath)
22
			return statErr
23
		},
24
	)
25

26
	return statInfo, resolvedRoot, resolvedPath, err
27
}
28

29
// Calls either statOnHost or statInsideMount depending on whether the
30
// container is running
31
func (c *Container) statInContainer(mountPoint string, containerPath string) (*copier.StatForItem, string, string, error) {
32
	if c.state.State == define.ContainerStateRunning {
33
		// If the container is running, we need to join it's mount namespace
34
		// and stat there.
35
		return c.statInsideMount(containerPath)
36
	}
37
	// If the container is NOT running, we need to resolve the path
38
	// on the host.
39
	return c.statOnHost(mountPoint, containerPath)
40
}
41

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.