Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fit for 32bit cpu #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/pcstats/mnt_ns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func SwitchMountNs(pid int) {
pidns := getMountNs(pid)

if myns != pidns {
setns(pidns)
setns(uint(pidns))
}
}

func getMountNs(pid int) int {
func getMountNs(pid int) int64 {
fname := fmt.Sprintf("/proc/%d/ns/mnt", pid)
nss, err := os.Readlink(fname)

Expand All @@ -52,7 +52,7 @@ func getMountNs(pid int) int {

nss = strings.TrimPrefix(nss, "mnt:[")
nss = strings.TrimSuffix(nss, "]")
ns, err := strconv.Atoi(nss)
ns, err := strconv.ParseInt(nss, 10, 64)

// not a number? weird ...
if err != nil {
Expand All @@ -62,7 +62,7 @@ func getMountNs(pid int) int {
return ns
}

func setns(fd int) error {
func setns(fd uint) error {
ret, _, err := unix.Syscall(unix.SYS_SETNS, uintptr(uint(fd)), uintptr(CLONE_NEWNS), 0)
if ret != 0 {
return fmt.Errorf("syscall SYS_SETNS failed: %v", err)
Expand Down