Skip to content

Commit 2f4574f

Browse files
authored
Merge pull request #274 from open-edge-platform/dev_feiyu
Clear specify host execution path with shell cmd
2 parents a848bd5 + 0b61c8f commit 2f4574f

25 files changed

Lines changed: 109 additions & 109 deletions

File tree

internal/chroot/chrootbuild/chrootbuild.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (chrootBuilder *ChrootBuilder) BuildChrootEnv(targetOs string, targetDist s
313313

314314
log.Infof("Chroot environment build completed successfully")
315315

316-
if _, err = shell.ExecCmd("rm -rf "+chrootEnvPath, true, "", nil); err != nil {
316+
if _, err = shell.ExecCmd("rm -rf "+chrootEnvPath, true, shell.HostPath, nil); err != nil {
317317
log.Errorf("Failed to remove chroot environment build path: %v", err)
318318
return fmt.Errorf("failed to remove chroot environment build path: %w", err)
319319
}

internal/chroot/chrootbuild/chrootbuild_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (t *testableChrootBuilder) BuildChrootEnv(targetOs, targetDist, targetArch
9797

9898
log.Infof("Chroot environment build completed successfully")
9999

100-
if _, err = shell.ExecCmd("rm -rf "+chrootEnvPath, true, "", nil); err != nil {
100+
if _, err = shell.ExecCmd("rm -rf "+chrootEnvPath, true, shell.HostPath, nil); err != nil {
101101
log.Errorf("Failed to remove chroot environment build path: %v", err)
102102
return fmt.Errorf("failed to remove chroot environment build path: %w", err)
103103
}

internal/chroot/chrootenv.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (chrootEnv *ChrootEnv) MountChrootPath(hostFullPath, chrootPath, mountFlags
184184
return fmt.Errorf("failed to get chroot host path for %s: %w", chrootPath, err)
185185
}
186186
if _, err := os.Stat(chrootHostPath); os.IsNotExist(err) {
187-
if _, err = shell.ExecCmd("mkdir -p "+chrootHostPath, true, "", nil); err != nil {
187+
if _, err = shell.ExecCmd("mkdir -p "+chrootHostPath, true, shell.HostPath, nil); err != nil {
188188
return fmt.Errorf("failed to create directory %s: %w", chrootHostPath, err)
189189
}
190190
}
@@ -302,7 +302,7 @@ func (chrootEnv *ChrootEnv) createChrootRepo(targetOs, targetDist string) error
302302
if err != nil {
303303
return fmt.Errorf("failed to get chroot host path for local repo config: %w", err)
304304
}
305-
if _, err := shell.ExecCmd("rm -f "+chrootRepoCongfigPath+"/*", true, "", nil); err != nil {
305+
if _, err := shell.ExecCmd("rm -f "+chrootRepoCongfigPath+"/*", true, shell.HostPath, nil); err != nil {
306306
return fmt.Errorf("failed to remove existing local repo config files: %w", err)
307307
}
308308

@@ -325,7 +325,7 @@ func (chrootEnv *ChrootEnv) initChrootWorkspace() error {
325325
chrootWorkspace := filepath.Join(chrootEnv.ChrootEnvRoot, "workspace")
326326
chrootEnv.ChrootImageBuildDir = filepath.Join(chrootWorkspace, "imagebuild")
327327
if _, err := os.Stat(chrootEnv.ChrootImageBuildDir); os.IsNotExist(err) {
328-
if _, err = shell.ExecCmd("mkdir -p "+chrootEnv.ChrootImageBuildDir, true, "", nil); err != nil {
328+
if _, err = shell.ExecCmd("mkdir -p "+chrootEnv.ChrootImageBuildDir, true, shell.HostPath, nil); err != nil {
329329
return fmt.Errorf("failed to create directory %s: %w", chrootEnv.ChrootImageBuildDir, err)
330330
}
331331
}

internal/chroot/deb/installer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (debInstaller *DebInstaller) cleanupOnError(chrootEnvPath, repoPath string,
3939
return
4040
}
4141

42-
if _, RemoveErr := shell.ExecCmd("rm -rf "+chrootEnvPath, true, "", nil); RemoveErr != nil {
42+
if _, RemoveErr := shell.ExecCmd("rm -rf "+chrootEnvPath, true, shell.HostPath, nil); RemoveErr != nil {
4343
log.Errorf("Failed to remove chroot environment build path: %v", RemoveErr)
4444
*err = fmt.Errorf("operation failed: %w, cleanup errors: %v", *err, RemoveErr)
4545
}
@@ -62,19 +62,19 @@ func (debInstaller *DebInstaller) UpdateLocalDebRepo(repoPath, targetArch string
6262
metaDataPath := filepath.Join(repoPath,
6363
fmt.Sprintf("dists/stable/main/binary-%s", targetArch), "Packages.gz")
6464
if _, err := os.Stat(metaDataPath); err == nil {
65-
if _, err = shell.ExecCmd("rm -f "+metaDataPath, false, "", nil); err != nil {
65+
if _, err = shell.ExecCmd("rm -f "+metaDataPath, false, shell.HostPath, nil); err != nil {
6666
return fmt.Errorf("failed to remove existing Packages.gz: %w", err)
6767
}
6868
}
6969
metaDataDir := filepath.Dir(metaDataPath)
7070
if _, err := os.Stat(metaDataDir); os.IsNotExist(err) {
71-
if _, err = shell.ExecCmd("mkdir -p "+metaDataDir, false, "", nil); err != nil {
71+
if _, err = shell.ExecCmd("mkdir -p "+metaDataDir, false, shell.HostPath, nil); err != nil {
7272
return fmt.Errorf("failed to create metadata directory %s: %w", metaDataDir, err)
7373
}
7474
}
7575

7676
cmd := fmt.Sprintf("cd %s && sudo dpkg-scanpackages . /dev/null | gzip -9c > %s", repoPath, metaDataPath)
77-
if _, err := shell.ExecCmd(cmd, false, "", nil); err != nil {
77+
if _, err := shell.ExecCmd(cmd, false, shell.HostPath, nil); err != nil {
7878
return fmt.Errorf("failed to create local debian cache repository: %w", err)
7979
}
8080

@@ -126,7 +126,7 @@ func (debInstaller *DebInstaller) InstallDebPkg(targetOsConfigDir, chrootEnvPath
126126
"-- bookworm %s %s",
127127
pkgListStr, chrootEnvPath, localRepoConfigPath)
128128

129-
if _, err = shell.ExecCmdWithStream(cmd, true, "", nil); err != nil {
129+
if _, err = shell.ExecCmdWithStream(cmd, true, shell.HostPath, nil); err != nil {
130130
log.Errorf("Failed to install debian packages in chroot environment: %v", err)
131131
return fmt.Errorf("failed to install debian packages in chroot environment: %w", err)
132132
}

internal/chroot/rpm/installer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (rpmInstaller *RpmInstaller) cleanupOnError(chrootEnvPath string, err *erro
4848
*err = fmt.Errorf("operation failed: %w, cleanup errors: %v", *err, cleanErr)
4949
return
5050
}
51-
if _, RemoveErr := shell.ExecCmd("rm -rf "+chrootEnvPath, true, "", nil); RemoveErr != nil {
51+
if _, RemoveErr := shell.ExecCmd("rm -rf "+chrootEnvPath, true, shell.HostPath, nil); RemoveErr != nil {
5252
log.Errorf("failed to remove chroot environment build path: %v", RemoveErr)
5353
*err = fmt.Errorf("operation failed: %w, cleanup errors: %v", *err, RemoveErr)
5454
}
@@ -57,7 +57,7 @@ func (rpmInstaller *RpmInstaller) cleanupOnError(chrootEnvPath string, err *erro
5757
func (rpmInstaller *RpmInstaller) InstallRpmPkg(targetOs, chrootEnvPath, chrootPkgCacheDir string, allPkgsList []string) (err error) {
5858
chrootRpmDbPath := filepath.Join(chrootEnvPath, "var", "lib", "rpm")
5959
if _, err := os.Stat(chrootRpmDbPath); os.IsNotExist(err) {
60-
if _, err := shell.ExecCmd("mkdir -p "+chrootRpmDbPath, true, "", nil); err != nil {
60+
if _, err := shell.ExecCmd("mkdir -p "+chrootRpmDbPath, true, shell.HostPath, nil); err != nil {
6161
log.Errorf("Failed to create chroot RPM database directory: %v", err)
6262
return fmt.Errorf("failed to create chroot environment directory: %w", err)
6363
}
@@ -86,7 +86,7 @@ func (rpmInstaller *RpmInstaller) InstallRpmPkg(targetOs, chrootEnvPath, chrootP
8686
cmdStr := fmt.Sprintf("rpm -i -v --nodeps --force --root %s --define '_dbpath /var/lib/rpm' %s",
8787
chrootEnvPath, pkgPath)
8888
var output string
89-
output, err = shell.ExecCmd(cmdStr, true, "", nil)
89+
output, err = shell.ExecCmd(cmdStr, true, shell.HostPath, nil)
9090
if err != nil {
9191
log.Errorf("Failed to install package %s: %v, output: %s", pkg, err, output)
9292
return fmt.Errorf("failed to install package %s: %w, output: %s", pkg, err, output)
@@ -109,7 +109,7 @@ func (rpmInstaller *RpmInstaller) InstallRpmPkg(targetOs, chrootEnvPath, chrootP
109109
// updateRpmDB updates the RPM database in the chroot environment
110110
func (rpmInstaller *RpmInstaller) updateRpmDB(chrootEnvBuildPath, chrootPkgCacheDir string, rpmList []string) (err error) {
111111
cmdStr := "rpm -E '%{_db_backend}'"
112-
hostRpmDbBackend, err := shell.ExecCmd(cmdStr, false, "", nil)
112+
hostRpmDbBackend, err := shell.ExecCmd(cmdStr, false, shell.HostPath, nil)
113113
if err != nil {
114114
log.Errorf("Failed to get host RPM DB backend: %v", err)
115115
return fmt.Errorf("failed to get host RPM DB backend: %w", err)

internal/image/imageboot/imageboot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ func installGrubWithEfiMode(installRoot, bootUUID, bootPrefix string, template *
7777
}
7878

7979
chmodCmd := fmt.Sprintf("chmod -R 700 %s", filepath.Dir(grubFinalPath))
80-
if _, err = shell.ExecCmd(chmodCmd, true, "", nil); err != nil {
80+
if _, err = shell.ExecCmd(chmodCmd, true, shell.HostPath, nil); err != nil {
8181
log.Errorf("Failed to set permissions for grub configuration directory: %v", err)
8282
return fmt.Errorf("failed to set permissions for grub configuration directory: %w", err)
8383
}
8484

8585
chmodCmd = fmt.Sprintf("chmod 400 %s", grubFinalPath)
86-
if _, err = shell.ExecCmd(chmodCmd, true, "", nil); err != nil {
86+
if _, err = shell.ExecCmd(chmodCmd, true, shell.HostPath, nil); err != nil {
8787
log.Errorf("Failed to set permissions for grub configuration file: %v", err)
8888
return fmt.Errorf("failed to set permissions for grub configuration file: %w", err)
8989
}

internal/image/imageconvert/imageconvert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func convertImageFile(filePath, imageType string) (string, error) {
102102
return outputFilePath, fmt.Errorf("unsupported image type: %s", imageType)
103103
}
104104

105-
_, err := shell.ExecCmd(cmdStr, false, "", nil)
105+
_, err := shell.ExecCmd(cmdStr, false, shell.HostPath, nil)
106106
if err != nil {
107107
log.Errorf("Failed to convert image file to %s: %v", imageType, err)
108108
return outputFilePath, fmt.Errorf("failed to convert image file to %s: %w", imageType, err)

internal/image/imagedisc/imagedisc.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

131131
func 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

141141
func 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

151151
func 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

175175
func 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

199199
func 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

680680
func 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

690690
func 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

706706
func 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

716716
func 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

Comments
 (0)