V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
miniliuke
V2EX  ›  Linux

Golang 系统调用 pivot_root 的问题

  •  
  •   miniliuke · Aug 24, 2018 · 3292 views
    This topic created in 2813 days ago, the information mentioned may be changed or developed.
    在 golang 系统调用中出现了一个问题......

    linux 命令行运行成功:
    mkdir dir1

    mkdir dir1/old

    mount --bind dir1 dir1

    unshare -m //这句是禁止共享 Mount NameSpace,把这句去了就和 golang 一样报错

    pivot_root dir1 dir1/old

    但是 golang 运行不成功:
    os.MkdirAll("dir1/old", 0700)

    syscall.Mount("dir1", "dir1", "", syscall.MS_BIND, "")

    syscall.Unshare(syscall.CLONE_NEWNS)

    syscall.PivotRoot("dir1", "dir1/old") //这句报错 invalid argument,预计是因为文件系统的处于同一个树的问题,但是才疏学浅......望各位指点迷津
    1 replies    2018-08-24 15:37:47 +08:00
    miniliuke
        1
    miniliuke  
    OP
       Aug 24, 2018
    是不是该换标题了:震惊! Linux 与 Golang 无人问津!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   930 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:11 · PVG 04:11 · LAX 13:11 · JFK 16:11
    ♥ Do have faith in what you're doing.