func()

in internal/diskutil/utility.go [76:90]


func (d *DiskUtilityCmd) RepairDisk(ctx context.Context, id string) (string, error) {
	// cmdRepairDisk represents the command used for executing macOS's diskutil to repair a disk.
	// The repairDisk command requires interactive-input ("yes"/"no") but is automated with util.ExecuteCommandYes.
	//   * repairDisk - indicates that a disk is going to be repaired (used to fetch amount of free space)
	//   * id - the device identifier for the disk to be repaired
	cmdRepairDisk := []string{"diskutil", "repairDisk", id}

	// Execute the diskutil repairDisk command and store the output
	cmdOut, err := util.ExecuteCommandYes(ctx, cmdRepairDisk, "", []string{})
	if err != nil {
		return cmdOut.Stdout, fmt.Errorf("diskutil: failed to run repairDisk command, stderr: [%s]: %w", cmdOut.Stderr, err)
	}

	return cmdOut.Stdout, nil
}