@@ -111,7 +111,7 @@ func CreateRawFile(filePath string, fileSize string, sudo bool) error {
111111 }
112112 }
113113 cmd := fmt .Sprintf ("fallocate -l %s %s" , fileSizeStr , filePath )
114- if _ , err = shell .ExecCmd (cmd , sudo , "" , nil ); err != nil {
114+ if _ , err = shell .ExecCmd (cmd , sudo , shell . HostPath , nil ); err != nil {
115115 log .Errorf ("Failed to create raw file %s: %v" , filePath , err )
116116 return fmt .Errorf ("failed to create raw file %s: %w" , filePath , err )
117117 }
@@ -130,7 +130,7 @@ func GetDiskNameFromDiskPath(diskPath string) (string, error) {
130130
131131func DiskGetHwSectorSize (diskName string ) (int , error ) {
132132 cmd := fmt .Sprintf ("cat /sys/block/%s/queue/hw_sector_size" , diskName )
133- output , err := shell .ExecCmd (cmd , true , "" , nil )
133+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
134134 if err != nil {
135135 log .Errorf ("Failed to get hw sector size for disk %s: %v" , diskName , err )
136136 return 0 , err
@@ -140,7 +140,7 @@ func DiskGetHwSectorSize(diskName string) (int, error) {
140140
141141func DiskGetPhysicalBlockSize (diskName string ) (int , error ) {
142142 cmd := fmt .Sprintf ("cat /sys/block/%s/queue/physical_block_size" , diskName )
143- output , err := shell .ExecCmd (cmd , true , "" , nil )
143+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
144144 if err != nil {
145145 log .Errorf ("Failed to get physical block size for disk %s: %v" , diskName , err )
146146 return 0 , err
@@ -150,7 +150,7 @@ func DiskGetPhysicalBlockSize(diskName string) (int, error) {
150150
151151func DiskGetDevInfo (diskPath string ) (map [string ]interface {}, error ) {
152152 cmd := fmt .Sprintf ("lsblk %s --json --list --output NAME,PATH,PARTTYPE,FSTYPE,UUID,MOUNTPOINT,PARTUUID,PARTLABEL,TYPE" , diskPath )
153- output , err := shell .ExecCmd (cmd , true , "" , nil )
153+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
154154 if err != nil {
155155 log .Errorf ("Failed to get device info for disk %s: %v" , diskPath , err )
156156 return nil , err
@@ -174,7 +174,7 @@ func DiskGetDevInfo(diskPath string) (map[string]interface{}, error) {
174174
175175func DiskGetPartitionsInfo (diskPath string ) ([]map [string ]interface {}, error ) {
176176 cmd := fmt .Sprintf ("lsblk %s --json --list --output NAME,PATH,PARTTYPE,FSTYPE,UUID,MOUNTPOINT,PARTUUID,PARTLABEL,TYPE" , diskPath )
177- output , err := shell .ExecCmd (cmd , true , "" , nil )
177+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
178178 if err != nil {
179179 log .Errorf ("Failed to get partitions info for disk %s: %v" , diskPath , err )
180180 return nil , err
@@ -198,7 +198,7 @@ func DiskGetPartitionsInfo(diskPath string) ([]map[string]interface{}, error) {
198198
199199func DiskGetInfo (diskPath string ) (map [string ]interface {}, error ) {
200200 cmd := fmt .Sprintf ("fdisk -l %s" , diskPath )
201- output , err := shell .ExecCmd (cmd , true , "" , nil )
201+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
202202 if err != nil {
203203 log .Errorf ("Failed to get disk info for disk %s: %v" , diskPath , err )
204204 return nil , err
@@ -272,7 +272,7 @@ func CheckDiskIOStats(diskPath string) (bool, error) {
272272 return false , err
273273 }
274274 cmd := fmt .Sprintf ("cat /proc/diskstats | grep %s*" , diskName )
275- output , err := shell .ExecCmd (cmd , true , "" , nil )
275+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
276276 if err != nil {
277277 log .Errorf ("Failed to get io stats for disk %s: %v" , diskPath , err )
278278 return false , err
@@ -490,15 +490,15 @@ func diskPartitionCreate(
490490 // Create the partition using sfdisk
491491 cmdStr := fmt .Sprintf ("echo '%s' | sudo sfdisk --no-reread --append %s" ,
492492 sfdiskScript .String (), diskPath )
493- _ , err = shell .ExecCmd (cmdStr , false , "" , nil )
493+ _ , err = shell .ExecCmd (cmdStr , false , shell . HostPath , nil )
494494 if err != nil {
495495 log .Errorf ("Failed to create partition %d on disk %s: %v" , partitionNum , diskPath , err )
496496 return "" , fmt .Errorf ("failed to create partition %d on disk %s: %w" , partitionNum , diskPath , err )
497497 }
498498
499499 // Refresh partition table using partx
500500 cmdStr = fmt .Sprintf ("partx -u %s" , diskPath )
501- _ , err = shell .ExecCmd (cmdStr , true , "" , nil )
501+ _ , err = shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
502502 if err != nil {
503503 log .Errorf ("Failed to refresh partition table after creating partition %d: %v" , partitionNum , err )
504504 return "" , fmt .Errorf ("failed to refresh partition table after creating partition %d: %w" , partitionNum , err )
@@ -514,7 +514,7 @@ func diskPartitionCreate(
514514
515515 if partitionInfo .FsType == "fat32" || partitionInfo .FsType == "fat16" || partitionInfo .FsType == "vfat" {
516516 cmdStr = fmt .Sprintf ("mkfs -t vfat %s" , diskPartDev )
517- _ , err := shell .ExecCmd (cmdStr , true , "" , nil )
517+ _ , err := shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
518518 if err != nil {
519519 log .Errorf ("Failed to format partition %d with fs type %s: %v" , partitionNum , partitionInfo .FsType , err )
520520 return "" , fmt .Errorf ("failed to format partition %d with fs type %s: %w" , partitionNum , partitionInfo .FsType , err )
@@ -534,20 +534,20 @@ func diskPartitionCreate(
534534 } else {
535535 cmdStr = fmt .Sprintf ("mkfs -t %s %s" , partitionInfo .FsType , diskPartDev )
536536 }
537- _ , err := shell .ExecCmd (cmdStr , true , "" , nil )
537+ _ , err := shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
538538 if err != nil {
539539 log .Errorf ("Failed to format partition %d with fs type %s: %v" , partitionNum , partitionInfo .FsType , err )
540540 return "" , fmt .Errorf ("failed to format partition %d with fs type %s: %w" , partitionNum , partitionInfo .FsType , err )
541541 }
542542 } else if partitionInfo .FsType == "linux-swap" {
543543 cmdStr = fmt .Sprintf ("mkswap %s" , diskPartDev )
544- _ , err := shell .ExecCmd (cmdStr , true , "" , nil )
544+ _ , err := shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
545545 if err != nil {
546546 log .Errorf ("Failed to format partition %d with fs type %s: %v" , partitionNum , partitionInfo .FsType , err )
547547 return "" , fmt .Errorf ("failed to format partition %d with fs type %s: %w" , partitionNum , partitionInfo .FsType , err )
548548 }
549549 cmdStr = fmt .Sprintf ("swapon %s" , diskPartDev )
550- _ , err = shell .ExecCmd (cmdStr , true , "" , nil )
550+ _ , err = shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
551551 if err != nil {
552552 log .Errorf ("Failed to enable swap on partition %d: %v" , partitionNum , err )
553553 return "" , fmt .Errorf ("failed to enable swap on partition %d: %w" , partitionNum , err )
@@ -563,15 +563,15 @@ func diskPartitionDelete(diskPath string, partitionNum int) error {
563563 return fmt .Errorf ("invalid partition number: %d" , partitionNum )
564564 }
565565 cmdStr := fmt .Sprintf ("sfdisk --delete %s %d" , diskPath , partitionNum )
566- _ , err := shell .ExecCmd (cmdStr , true , "" , nil )
566+ _ , err := shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
567567 if err != nil {
568568 log .Errorf ("Failed to delete partition %d: %v" , partitionNum , err )
569569 return fmt .Errorf ("failed to delete partition %d: %w" , partitionNum , err )
570570 }
571571
572572 // Refresh partition table
573573 cmdStr = fmt .Sprintf ("partx -d --nr %d %s" , partitionNum , diskPath )
574- _ , err = shell .ExecCmd (cmdStr , true , "" , nil )
574+ _ , err = shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
575575 if err != nil {
576576 // Non-fatal if partition is already gone
577577 log .Warnf ("Could not remove partition %d from kernel table: %v" , partitionNum , err )
@@ -597,7 +597,7 @@ func DiskPartitionsCreate(diskPath string, partitionsList []config.PartitionInfo
597597
598598 if partitionTableType == "gpt" {
599599 cmdStr := fmt .Sprintf ("echo 'label: gpt' | sudo sfdisk %s" , diskPath )
600- _ , err := shell .ExecCmd (cmdStr , false , "" , nil )
600+ _ , err := shell .ExecCmd (cmdStr , false , shell . HostPath , nil )
601601 if err != nil {
602602 log .Errorf ("Failed to create GPT partition table on disk %s: %v" , diskPath , err )
603603 return nil , fmt .Errorf ("failed to create GPT partition table on disk %s: %w" , diskPath , err )
@@ -622,7 +622,7 @@ func DiskPartitionsCreate(diskPath string, partitionsList []config.PartitionInfo
622622 var partitionNum int
623623 maxPrimaryPartitionsNum := 4
624624 cmdStr := fmt .Sprintf ("echo 'label: dos' | sudo sfdisk %s" , diskPath )
625- _ , err := shell .ExecCmd (cmdStr , false , "" , nil )
625+ _ , err := shell .ExecCmd (cmdStr , false , shell . HostPath , nil )
626626 if err != nil {
627627 log .Errorf ("Failed to create MBR partition table on disk %s: %v" , diskPath , err )
628628 return nil , fmt .Errorf ("failed to create MBR partition table on disk %s: %w" , diskPath , err )
@@ -679,7 +679,7 @@ func DiskPartitionsCreate(diskPath string, partitionsList []config.PartitionInfo
679679
680680func GetPartitionLabel (diskPartDev string ) (string , error ) {
681681 cmdStr := fmt .Sprintf ("blkid %s -s PARTLABEL -o value" , diskPartDev )
682- label , err := shell .ExecCmd (cmdStr , true , "" , nil )
682+ label , err := shell .ExecCmd (cmdStr , true , shell . HostPath , nil )
683683 if err != nil {
684684 log .Errorf ("Failed to get partition label for %s: %v" , diskPartDev , err )
685685 return "" , fmt .Errorf ("failed to get partition label for %s: %w" , diskPartDev , err )
@@ -689,13 +689,13 @@ func GetPartitionLabel(diskPartDev string) (string, error) {
689689
690690func WipePartitions (diskPath string ) error {
691691 // Wipe filesystem signatures
692- _ , err := shell .ExecCmd (fmt .Sprintf ("wipefs -a -f %s" , diskPath ), true , "" , nil )
692+ _ , err := shell .ExecCmd (fmt .Sprintf ("wipefs -a -f %s" , diskPath ), true , shell . HostPath , nil )
693693 if err != nil {
694694 log .Errorf ("Failed to wipe filesystem signatures on disk %s: %v" , diskPath , err )
695695 return fmt .Errorf ("failed to wipe disk %s: %w" , diskPath , err )
696696 }
697697
698- _ , err = shell .ExecCmd ("sync" , true , "" , nil )
698+ _ , err = shell .ExecCmd ("sync" , true , shell . HostPath , nil )
699699 if err != nil {
700700 log .Errorf ("Failed to sync after wiping disk %s: %v" , diskPath , err )
701701 return fmt .Errorf ("failed to sync after wiping disk %s: %w" , diskPath , err )
@@ -705,7 +705,7 @@ func WipePartitions(diskPath string) error {
705705
706706func GetUUID (diskPartitionPath string ) (string , error ) {
707707 cmd := fmt .Sprintf ("blkid %s -s UUID -o value" , diskPartitionPath )
708- output , err := shell .ExecCmd (cmd , true , "" , nil )
708+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
709709 if err != nil {
710710 log .Errorf ("Failed to get UUID for %s: %v" , diskPartitionPath , err )
711711 return output , fmt .Errorf ("failed to get partition UUID for %s: %w" , diskPartitionPath , err )
@@ -715,7 +715,7 @@ func GetUUID(diskPartitionPath string) (string, error) {
715715
716716func GetPartUUID (diskPartitionPath string ) (string , error ) {
717717 cmd := fmt .Sprintf ("blkid %s -s PARTUUID -o value" , diskPartitionPath )
718- output , err := shell .ExecCmd (cmd , true , "" , nil )
718+ output , err := shell .ExecCmd (cmd , true , shell . HostPath , nil )
719719 if err != nil {
720720 log .Errorf ("Failed to get PARTUUID for %s: %v" , diskPartitionPath , err )
721721 return output , fmt .Errorf ("failed to get partition UUID for %s: %w" , diskPartitionPath , err )
0 commit comments