talos/internal/pkg/mount/v2/repair.go
Andrey Smirnov edf5c5e29b
fix: extfs repair and resize
Fixes #10103

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2025-01-13 13:04:33 +04:00

36 lines
892 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 mount
import (
"fmt"
"github.com/siderolabs/talos/pkg/makefs"
)
// repair a filesystem.
func (p *Point) repair(printerOptions PrinterOptions) error {
var repairFunc func(partition string) error
switch p.fstype {
case "ext4":
repairFunc = makefs.Ext4Repair
case "xfs":
repairFunc = makefs.XFSRepair
default:
return fmt.Errorf("unsupported filesystem type for repair: %s", p.fstype)
}
printerOptions.Printf("filesystem (%s) on %s needs cleaning, running repair", p.fstype, p.source)
if err := repairFunc(p.source); err != nil {
return fmt.Errorf("repair: %w", err)
}
printerOptions.Printf("filesystem successfully repaired on %s", p.source)
return nil
}