Add support for 512 gb mod

This commit is contained in:
timoxa0 2024-08-08 11:14:54 +05:00
parent 97a5127a59
commit 768af6db31
2 changed files with 8 additions and 13 deletions

View file

@ -242,14 +242,7 @@ var deployCmd = &cobra.Command{
block_size, _ := adbd.RunCommand("blockdev --getsize64 /dev/block/sda") block_size, _ := adbd.RunCommand("blockdev --getsize64 /dev/block/sda")
block_size = strings.TrimRight(block_size, "\n") block_size = strings.TrimRight(block_size, "\n")
is128 := false for _, cmd := range utils.GenRepartCommands(partpercent, block_size) {
if r, _ := regexp.MatchString(`^125[0-9]{9}$`, block_size); r {
is128 = true
} else if r, _ := regexp.MatchString(`^253[0-9]{9}$`, block_size); r {
is128 = false
}
for _, cmd := range utils.GenRepartCommands(partpercent, is128) {
adbd.RunCommand(cmd) adbd.RunCommand(cmd)
logger.Debug("Executed command", logger.Args("cmd", cmd)) logger.Debug("Executed command", logger.Args("cmd", cmd))
} }

View file

@ -4,14 +4,17 @@ import (
"fmt" "fmt"
"math" "math"
"net" "net"
"regexp"
) )
func GenRepartCommands(percent int, is128 bool) []string { func GenRepartCommands(percent int, blocksize string) []string {
var maxsize uint8 var maxsize uint16
if is128 { if r, _ := regexp.MatchString(`^125[0-9]{9}$`, blocksize); r {
maxsize = 126 maxsize = 126
} else { } else if r, _ := regexp.MatchString(`^253[0-9]{9}$`, blocksize); r {
maxsize = 254 maxsize = 254
} else if r, _ := regexp.MatchString(`^509[0-9]{9}$`, blocksize); r {
maxsize = 509
} }
linux_max := maxsize - 12 linux_max := maxsize - 12
size := math.Round(float64(linux_max)*float64(percent)) / 100 size := math.Round(float64(linux_max)*float64(percent)) / 100
@ -26,7 +29,6 @@ func GenRepartCommands(percent int, is128 bool) []string {
} }
} }
func GetFreePort() (int, error) { func GetFreePort() (int, error) {
listener, err := net.Listen("tcp", ":0") listener, err := net.Listen("tcp", ":0")
if err != nil { if err != nil {