mirror of
https://github.com/kairos-io/immucore.git
synced 2025-07-01 09:02:14 +00:00
24 lines
600 B
Go
24 lines
600 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// https://github.com/kairos-io/packages/blob/7c3581a8ba6371e5ce10c3a98bae54fde6a505af/packages/system/dracut/immutable-rootfs/30cos-immutable-rootfs/cos-mount-layout.sh#L58
|
||
|
|
||
|
// input: LABEL=FOO:/mount
|
||
|
// output: /dev/disk...:/mount
|
||
|
func ParseMount(s string) string {
|
||
|
switch {
|
||
|
case strings.Contains(s, "UUID="):
|
||
|
dat := strings.Split(s, "UUID=")
|
||
|
return fmt.Sprintf("/dev/disk/by-uuid/%s", dat[1])
|
||
|
case strings.Contains(s, "LABEL="):
|
||
|
dat := strings.Split(s, "LABEL=")
|
||
|
return fmt.Sprintf("/dev/disk/by-label/%s", dat[1])
|
||
|
default:
|
||
|
return s
|
||
|
}
|
||
|
}
|