Skip to content

Commit 06dd45b

Browse files
committed
Do special case ENOENT after all
Otherwise seeking into a raw dmg file will fail when hitting parts of it that are not covered by a band. The expectation in that case is to pad with zeroes, like we do for partial bands.
1 parent b3f62d8 commit 06dd45b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/sparsebundlefs.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,13 @@ static int sparsebundle_open_file(const char *path)
229229

230230
sparsebundle_close_files();
231231
return sparsebundle_open_file(path);
232+
} else if (errno == ENOENT) {
233+
syslog(LOG_DEBUG, "%s does not exist", path);
234+
return -1;
235+
} else {
236+
syslog(LOG_ERR, "failed to open %s: %s", path, strerror(errno));
237+
return -1;
232238
}
233-
syslog(LOG_ERR, "failed to open %s: %s", path, strerror(errno));
234-
return -1;
235239
}
236240

237241
sparsebundle->open_files[path] = fd;
@@ -319,7 +323,7 @@ static int sparsebundle_read_process_band(const char *band_path, size_t length,
319323

320324
int band_file_fd = sparsebundle_open_file(band_path);
321325
if (band_file_fd == -1)
322-
return -errno;
326+
return errno == ENOENT ? 0 : -errno;
323327

324328
read = pread(band_file_fd, *buffer, length, offset);
325329
if (read == -1) {
@@ -371,7 +375,7 @@ static int sparsebundle_read_buf_process_band(const char *band_path, size_t leng
371375

372376
int band_file_fd = sparsebundle_open_file(band_path);
373377
if (band_file_fd == -1)
374-
return -errno;
378+
return errno == ENOENT ? 0 : -errno;
375379

376380
struct stat band_stat;
377381
stat(band_path, &band_stat);

0 commit comments

Comments
 (0)