summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/mkhtemp.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-04-01 06:17:25 +0100
committerLeah Rowe <leah@libreboot.org>2026-04-01 06:17:25 +0100
commitdf5bb1c8942befa32ab5fdae6235efd6da62e5b5 (patch)
tree368693813424624e21e4aa642702fe0a55a4ad5b /util/libreboot-utils/lib/mkhtemp.c
parentf90af15502dbcd4c3fb8df66b77f869d005978cd (diff)
libreboot-utils: loop fcntl on eintr
but i can't write a generic function for this, because fcntl is a variadic function, so wrapping cannot be done cleanly. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/mkhtemp.c')
-rw-r--r--util/libreboot-utils/lib/mkhtemp.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/util/libreboot-utils/lib/mkhtemp.c b/util/libreboot-utils/lib/mkhtemp.c
index 7d1a02f3..d3ca92b0 100644
--- a/util/libreboot-utils/lib/mkhtemp.c
+++ b/util/libreboot-utils/lib/mkhtemp.c
@@ -744,15 +744,21 @@ int secure_file(int *fd,
int do_lock,
mode_t mode)
{
- int flags;
+ int flags = -1;
struct stat st_now;
int saved_errno = errno;
errno = 0;
if (if_err(fd == NULL || st == NULL, EFAULT) ||
- if_err(*fd < 0, EBADF) ||
- if_err_sys((flags = fcntl(*fd, F_GETFL)) == -1) ||
- if_err(bad_flags > 0 && (flags & bad_flags), EPERM))
+ if_err(*fd < 0, EBADF))
+ goto err_demons;
+
+ while (fs_retry(saved_errno,
+ flags = fcntl(*fd, F_GETFL)));
+ if (flags == -1)
+ goto err_demons;
+
+ if (if_err(bad_flags > 0 && (flags & bad_flags), EPERM))
goto err_demons;
if (expected != NULL) {
@@ -878,6 +884,7 @@ lock_file(int fd, int flags)
{
struct flock fl;
int saved_errno = errno;
+ int fcntl_rval = -1;
errno = 0;
if (if_err(fd < 0, EBADF) ||
@@ -893,7 +900,9 @@ lock_file(int fd, int flags)
fl.l_whence = SEEK_SET;
- if (fcntl(fd, F_SETLK, &fl) == -1)
+ while (fs_retry(saved_errno,
+ fcntl_rval = fcntl(fd, F_SETLK, &fl)));
+ if (fcntl_rval == -1)
goto err_lock_file;
reset_caller_errno(0);