talos

Форк
0
/
xfs.go 
63 строки · 1.4 Кб
1
// This Source Code Form is subject to the terms of the Mozilla Public
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
package makefs
6

7
import (
8
	"errors"
9
	"fmt"
10

11
	"github.com/siderolabs/go-cmd/pkg/cmd"
12
)
13

14
const (
15
	// FilesystemTypeXFS is the filesystem type for XFS.
16
	FilesystemTypeXFS = "xfs"
17
)
18

19
// XFSGrow expands a XFS filesystem to the maximum possible. The partition
20
// MUST be mounted, or this will fail.
21
func XFSGrow(partname string) error {
22
	_, err := cmd.Run("xfs_growfs", "-d", partname)
23

24
	return err
25
}
26

27
// XFSRepair repairs a XFS filesystem on the specified partition.
28
func XFSRepair(partname, fsType string) error {
29
	if fsType != FilesystemTypeXFS {
30
		return fmt.Errorf("unsupported filesystem type: %s", fsType)
31
	}
32

33
	_, err := cmd.Run("xfs_repair", partname)
34

35
	return err
36
}
37

38
// XFS creates a XFS filesystem on the specified partition.
39
func XFS(partname string, setters ...Option) error {
40
	if partname == "" {
41
		return errors.New("missing path to disk")
42
	}
43

44
	opts := NewDefaultOptions(setters...)
45

46
	// The ftype=1 naming option is required by overlayfs.
47
	// The bigtime=1 metadata option enables timestamps beyond 2038.
48
	args := []string{"-n", "ftype=1", "-m", "bigtime=1"}
49

50
	if opts.Force {
51
		args = append(args, "-f")
52
	}
53

54
	if opts.Label != "" {
55
		args = append(args, "-L", opts.Label)
56
	}
57

58
	args = append(args, partname)
59

60
	_, err := cmd.Run("mkfs.xfs", args...)
61

62
	return err
63
}
64

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.