Example #1
0
func main() {
	mountType := flag.String("type", "", "Mount type")
	sourcePath := flag.String("sourcePath", "", "Source path")
	targetPath := flag.String("targetPath", "", "Destination path")
	flags := flag.Int("flags", -1, "Mount options")
	data := flag.String("data", "", "Data options")

	flag.Parse()

	mnt := system.Mount{
		Type:       system.MountType(*mountType),
		SourcePath: *sourcePath,
		TargetPath: *targetPath,
		Flags:      *flags,
		Data:       *data,
	}

	if err := mnt.Mount(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s", err)
		panic("mount failed!")
	}

	args := flag.Args()
	cmd := exec.Command(args[0], args[1:]...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	if err := cmd.Run(); err != nil {
		panic(err)
	}
}
Example #2
0
func main() {
	flags, err := strconv.Atoi(os.Args[3])
	if err != nil {
		panic(err)
	}

	mnt := system.Mount{
		Type:  system.MountType(os.Args[1]),
		Path:  os.Args[2],
		Flags: flags,
		Data:  os.Args[4],
	}

	if err := mnt.Mount(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s", err)
		panic("mount failed!")
	}

	cmd := exec.Command(os.Args[5], os.Args[6:]...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	if err := cmd.Run(); err != nil {
		panic(err)
	}
}