Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
miniliuke
V2EX  ›  Linux

Golang 系统调用 pivot_root 的问题

  •  
  •   miniliuke · Aug 24, 2018 · 3308 views
    This topic created in 2818 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   ·   3333 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 13:13 · PVG 21:13 · LAX 06:13 · JFK 09:13
    ♥ Do have faith in what you're doing.