Skip to content

Commit

Permalink
Probe (open and close) the CI Drive before calling blkid
Browse files Browse the repository at this point in the history
This fixes a strange bug where the first call to /dev/fd0
fails with an IO error. Probably due to the O_NONBLOCK flag
added here:
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/libblkid/src/verify.c?id=39f5af25982d8b0244000e92a9d0e0e6557d0e17
  • Loading branch information
0xef53 committed Oct 27, 2021
1 parent 3092414 commit 4f89420
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/cloudinit/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ func ReadData() (*Data, error) {
}

func GetDeviceAttr(device, attr string) (string, error) {
out, err := exec.Command("blkid", "-ovalue", "-t", "TYPE=iso9660", "-s", strings.ToUpper(attr), device).CombinedOutput()
// Check device availability
if fd, err := os.Open(device); err == nil {
fd.Close()
} else {
return "", err
}

out, err := exec.Command("blkid", "-c", "/dev/null", "-ovalue", "-t", "TYPE=iso9660", "-s", strings.ToUpper(attr), device).CombinedOutput()
if err != nil {
var exitCode int
if exiterr, ok := err.(*exec.ExitError); ok {
Expand Down

0 comments on commit 4f89420

Please sign in to comment.