Andrew Rynhard 31a00ef73a
feat: install bootloader to block device (#455)
Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2019-03-18 14:01:58 -07:00

35 lines
729 B
Go

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package vfat
import (
"os/exec"
)
// MakeFS creates a VFAT filesystem on the specified partition.
func MakeFS(partname string, setters ...Option) error {
opts := NewDefaultOptions(setters...)
args := []string{}
if opts.Label != "" {
args = append(args, "-F", "32", "-n", opts.Label)
}
args = append(args, partname)
return cmd("mkfs.vfat", args...)
}
func cmd(name string, args ...string) error {
cmd := exec.Command(name, args...)
err := cmd.Start()
if err != nil {
return err
}
return cmd.Wait()
}