Created
August 31, 2015 18:03
-
-
Save mrunalp/4b83f573bb4c2e3a3640 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"log" | |
"os" | |
"path/filepath" | |
"syscall" | |
) | |
func main() { | |
var rootFs string | |
flag.StringVar(&rootFs, "rootfs", "", "path to rootfs") | |
flag.Parse() | |
if rootFs == "" { | |
log.Fatalf("Rootfs value not specified") | |
} | |
runDir := filepath.Join(rootFs, "/run") | |
if _, err := os.Stat(runDir); os.IsNotExist(err) { | |
if err := os.Mkdir("/run", 0755); err != nil { | |
log.Fatalf("Failed to create /run directory: %q", err) | |
} | |
} | |
flags := syscall.MS_NOSUID | syscall.MS_NODEV | syscall.MS_NOEXEC | |
if err := syscall.Mount("tmpfs", runDir, "tmpfs", uintptr(flags), "mode=755,size=65000k"); err != nil { | |
log.Fatalf("Failed to mount tmpfs at %s: %q", runDir, err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment