1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #14716 from LK4D4/update_libcontainer

Update libcontainer to v0.0.2
This commit is contained in:
Tibor Vass 2015-07-20 11:33:19 -04:00
commit 77bbee3d00
3 changed files with 31 additions and 5 deletions

View file

@ -36,7 +36,7 @@ clone git github.com/hashicorp/consul v0.5.2
# get distribution packages # get distribution packages
clone git github.com/docker/distribution 419bbc2da637d9b2a812be78ef8436df7caac70d clone git github.com/docker/distribution 419bbc2da637d9b2a812be78ef8436df7caac70d
clone git github.com/opencontainers/runc v0.0.1 # libcontainer clone git github.com/opencontainers/runc v0.0.2 # libcontainer
# libcontainer deps (see src/github.com/docker/libcontainer/update-vendor.sh) # libcontainer deps (see src/github.com/docker/libcontainer/update-vendor.sh)
clone git github.com/coreos/go-systemd v2 clone git github.com/coreos/go-systemd v2
clone git github.com/godbus/dbus v2 clone git github.com/godbus/dbus v2

View file

@ -235,16 +235,20 @@ func getCgroupData(c *configs.Cgroup, pid int) (*data, error) {
}, nil }, nil
} }
func (raw *data) parent(subsystem, mountpoint string) (string, error) { func (raw *data) parent(subsystem, mountpoint, src string) (string, error) {
initPath, err := cgroups.GetInitCgroupDir(subsystem) initPath, err := cgroups.GetInitCgroupDir(subsystem)
if err != nil { if err != nil {
return "", err return "", err
} }
return filepath.Join(mountpoint, initPath), nil relDir, err := filepath.Rel(src, initPath)
if err != nil {
return "", err
}
return filepath.Join(mountpoint, relDir), nil
} }
func (raw *data) path(subsystem string) (string, error) { func (raw *data) path(subsystem string) (string, error) {
mnt, err := cgroups.FindCgroupMountpoint(subsystem) mnt, src, err := cgroups.FindCgroupMountpointAndSource(subsystem)
// If we didn't mount the subsystem, there is no point we make the path. // If we didn't mount the subsystem, there is no point we make the path.
if err != nil { if err != nil {
return "", err return "", err
@ -255,7 +259,7 @@ func (raw *data) path(subsystem string) (string, error) {
return filepath.Join(raw.root, subsystem, raw.cgroup), nil return filepath.Join(raw.root, subsystem, raw.cgroup), nil
} }
parent, err := raw.parent(subsystem, mnt) parent, err := raw.parent(subsystem, mnt, src)
if err != nil { if err != nil {
return "", err return "", err
} }

View file

@ -42,6 +42,28 @@ func FindCgroupMountpoint(subsystem string) (string, error) {
return "", NewNotFoundError(subsystem) return "", NewNotFoundError(subsystem)
} }
func FindCgroupMountpointAndSource(subsystem string) (string, string, error) {
f, err := os.Open("/proc/self/mountinfo")
if err != nil {
return "", "", err
}
scanner := bufio.NewScanner(f)
for scanner.Scan() {
txt := scanner.Text()
fields := strings.Split(txt, " ")
for _, opt := range strings.Split(fields[len(fields)-1], ",") {
if opt == subsystem {
return fields[4], fields[3], nil
}
}
}
if err := scanner.Err(); err != nil {
return "", "", err
}
return "", "", NewNotFoundError(subsystem)
}
func FindCgroupMountpointDir() (string, error) { func FindCgroupMountpointDir() (string, error) {
mounts, err := mount.GetMounts() mounts, err := mount.GetMounts()
if err != nil { if err != nil {