mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-05-28 00:51:22 +02:00
feat(sd): add filesystem type selection for SD card format (exFAT/FAT32)
Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
@@ -782,7 +782,11 @@ func rpcUnmountSDStorage() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func rpcFormatSDStorage(confirm bool) error {
|
||||
func rpcFormatSDStorage(confirm bool, fsType string) error {
|
||||
validFsTypes := map[string]bool{"exfat": true, "fat32": true}
|
||||
if !validFsTypes[fsType] {
|
||||
fsType = "fat32"
|
||||
}
|
||||
if !confirm {
|
||||
return fmt.Errorf("format not confirmed")
|
||||
}
|
||||
@@ -864,7 +868,13 @@ func rpcFormatSDStorage(confirm bool) error {
|
||||
return fmt.Errorf("failed to stat sd partition: %w", err)
|
||||
}
|
||||
|
||||
mkfsOut, mkfsErr := exec.Command("mkfs.vfat", "-F", "32", "-n", "PICOKVM", "/dev/mmcblk1p1").CombinedOutput()
|
||||
var mkfsCmd *exec.Cmd
|
||||
if fsType == "exfat" {
|
||||
mkfsCmd = exec.Command("mkfs.exfat", "-n", "PICOKVM", "/dev/mmcblk1p1")
|
||||
} else {
|
||||
mkfsCmd = exec.Command("mkfs.vfat", "-F", "32", "-n", "PICOKVM", "/dev/mmcblk1p1")
|
||||
}
|
||||
mkfsOut, mkfsErr := mkfsCmd.CombinedOutput()
|
||||
if mkfsErr != nil {
|
||||
return fmt.Errorf("failed to format sdcard: %w: %s", mkfsErr, strings.TrimSpace(string(mkfsOut)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user