diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-19 22:22:50 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-19 22:22:50 +0200 |
| commit | e5ad3fb4402d7df52c346408cbacbf68af4fa05a (patch) | |
| tree | 997c0595f80c9300dcc8680423fcfdf642a1bda6 /src/lib/ext.cc | |
| parent | 1bcf14c383fad1dd87dda8d6b506887b63fa8b34 (diff) | |
Sleep for a while if necessary to allow disks to wake up (#1916).
Diffstat (limited to 'src/lib/ext.cc')
| -rw-r--r-- | src/lib/ext.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/ext.cc b/src/lib/ext.cc index b88a88726..39c90ae12 100644 --- a/src/lib/ext.cc +++ b/src/lib/ext.cc @@ -331,6 +331,18 @@ try file_windows_partition_set (bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size); #else file_dev_name_set (posix_partition.c_str()); + + /* On macOS (at least) if you try to write to a drive that is sleeping the ext4_mkfs call + * below is liable to return EIO because it can't open the device. Try to work around that + * here by opening and closing the device, waiting 5 seconds if it fails. + */ + int wake = open(posix_partition.c_str(), O_RDWR); + if (wake == -1) { + dcpomatic_sleep_seconds (5); + } else { + close(wake); + } + bd = file_dev_get (); #endif |
