(m *configs.Mount)
| 791 | } |
| 792 | |
| 793 | func getCgroupMounts(m *configs.Mount) ([]*configs.Mount, error) { |
| 794 | mounts, err := cgroups.GetCgroupMounts(false) |
| 795 | if err != nil { |
| 796 | return nil, err |
| 797 | } |
| 798 | |
| 799 | // We don't need to use /proc/thread-self here because runc always runs |
| 800 | // with every thread in the same cgroup. This lets us avoid having to do |
| 801 | // runtime.LockOSThread. |
| 802 | cgroupPaths, err := cgroups.ParseCgroupFile("/proc/self/cgroup") |
| 803 | if err != nil { |
| 804 | return nil, err |
| 805 | } |
| 806 | |
| 807 | var binds []*configs.Mount |
| 808 | |
| 809 | for _, mm := range mounts { |
| 810 | dir, err := mm.GetOwnCgroup(cgroupPaths) |
| 811 | if err != nil { |
| 812 | return nil, err |
| 813 | } |
| 814 | relDir, err := filepath.Rel(mm.Root, dir) |
| 815 | if err != nil { |
| 816 | return nil, err |
| 817 | } |
| 818 | binds = append(binds, &configs.Mount{ |
| 819 | Device: "bind", |
| 820 | Source: filepath.Join(mm.Mountpoint, relDir), |
| 821 | Destination: filepath.Join(m.Destination, filepath.Base(mm.Mountpoint)), |
| 822 | Flags: unix.MS_BIND | unix.MS_REC | m.Flags, |
| 823 | PropagationFlags: m.PropagationFlags, |
| 824 | }) |
| 825 | } |
| 826 | |
| 827 | return binds, nil |
| 828 | } |
| 829 | |
| 830 | // Taken from <include/linux/proc_ns.h>. If a file is on a filesystem of type |
| 831 | // PROC_SUPER_MAGIC, we're guaranteed that only the root of the superblock will |
no outgoing calls
no test coverage detected
searching dependent graphs…