Skip to content

Instantly share code, notes, and snippets.

@mrunalp
Created August 31, 2015 18:03
Show Gist options
  • Save mrunalp/4b83f573bb4c2e3a3640 to your computer and use it in GitHub Desktop.
Save mrunalp/4b83f573bb4c2e3a3640 to your computer and use it in GitHub Desktop.
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