MCPcopy Index your code
hub / github.com/containerd/containerd / GetUsernsForNamespace

Function GetUsernsForNamespace

pkg/sys/namespace_linux.go:31–38  ·  view source on GitHub ↗

GetUsernsForNamespace returns a file descriptor that refers to the owning user namespace for the namespace referred to by fd. REF: https://man7.org/linux/man-pages/man2/ioctl_ns.2.html

(fd uintptr)

Source from the content-addressed store, hash-verified

29//
30// REF: https://man7.org/linux/man-pages/man2/ioctl_ns.2.html
31func GetUsernsForNamespace(fd uintptr) (*os.File, error) {
32 fd, _, errno := unix.Syscall(syscall.SYS_IOCTL, fd, uintptr(unix.NS_GET_USERNS), 0)
33 if errno != 0 {
34 return nil, fmt.Errorf("failed to get user namespace fd: %w", errno)
35 }
36
37 return os.NewFile(fd, fmt.Sprintf("/proc/%d/fd/%d", os.Getpid(), fd)), nil
38}

Callers 2

pinUserNamespaceMethod · 0.92

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…