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 = strings.TrimRight(block_size, "\n")
is128 := false
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) {
for _, cmd := range utils.GenRepartCommands(partpercent, block_size) {
adbd.RunCommand(cmd)
logger.Debug("Executed command", logger.Args("cmd", cmd))
}

View file

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