libreboot-utils: much stricter close() handling

remove close_warn and close_no_err

make close_on_eintr a void, and abort
on error instead of returning -1.

a failed file closure is a world-ending
event. burn accordingly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-28 07:30:55 +00:00
parent fd26c6e631
commit 63984a4a6a
5 changed files with 40 additions and 95 deletions
+4 -17
View File
@@ -239,8 +239,8 @@ write_to_gbe_bin(void)
saved_errno = errno;
f->io_err_gbe_bin |= -close_warn(&f->tmp_fd, f->tname);
f->io_err_gbe_bin |= -close_warn(&f->gbe_fd, f->fname);
close_on_eintr(&f->tmp_fd);
close_on_eintr(&f->gbe_fd);
errno = saved_errno;
@@ -440,15 +440,8 @@ gbe_mv(void)
ret_gbe_mv:
/* TODO: this whole section is bloat.
it can be generalised
*/
if (f->gbe_fd > -1) {
if (close_on_eintr(f->gbe_fd) < 0) {
f->gbe_fd = -1;
rval = -1;
}
close_on_eintr(&f->gbe_fd);
f->gbe_fd = -1;
if (fsync_dir(f->fname) < 0) {
@@ -457,13 +450,7 @@ ret_gbe_mv:
}
}
if (f->tmp_fd > -1) {
if (close_on_eintr(f->tmp_fd) < 0) {
f->tmp_fd = -1;
rval = -1;
}
f->tmp_fd = -1;
}
close_on_eintr(&f->tmp_fd);
/* before this function is called,
* tmp_fd may have been moved