mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-06 06:21:10 +02:00
This adds a command runner function that can be used everywhere we need to exec a binary. It adds addtional logic around error handling that will allow for viewing errors in the case of a failed command. Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
37 lines
960 B
Go
37 lines
960 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 xfs provides an interface to xfsprogs.
|
|
package xfs
|
|
|
|
import (
|
|
"github.com/talos-systems/talos/pkg/cmd"
|
|
)
|
|
|
|
// GrowFS expands a XFS filesystem to the maximum possible. The partition
|
|
// MUST be mounted, or this will fail.
|
|
func GrowFS(partname string) error {
|
|
return cmd.Run("xfs_growfs", "-d", partname)
|
|
}
|
|
|
|
// MakeFS creates a XFS filesystem on the specified partition.
|
|
func MakeFS(partname string, setters ...Option) error {
|
|
opts := NewDefaultOptions(setters...)
|
|
|
|
// The ftype=1 naming option is required by overlayfs.
|
|
args := []string{"-n", "ftype=1"}
|
|
|
|
if opts.Force {
|
|
args = append(args, "-f")
|
|
}
|
|
|
|
if opts.Label != "" {
|
|
args = append(args, "-L", opts.Label)
|
|
}
|
|
|
|
args = append(args, partname)
|
|
|
|
return cmd.Run("mkfs.xfs", args...)
|
|
}
|