lib: Add "open dfd iter handling noent" helper, port tree-wide

Follow up to a previous patch that addressed a double-close; I
realized we already had a helper for doing "open dfd iter, do nothing
if we get ENOENT".  Raise it to libotuil, and port all consumers.

Closes: #863
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-05-16 18:39:19 +00:00
1 parent 90cd7f7234
commit 9380dbb14d
7 files changed
+112 -131

No files matched your search

+5 -10
View File
@@ -2272,18 +2272,13 @@ list_loose_objects_at (OstreeRepo *self,
{
GVariant *key, *value;
glnx_fd_close int target_dfd = glnx_opendirat_with_errno (dfd, prefix, FALSE);
if (target_dfd < 0)
{
/* Nothing to do if this dir doesn't exist */
if (errno == ENOENT)
return TRUE;
return glnx_throw_errno (error);
}
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_take_fd (target_dfd, &dfd_iter, error))
gboolean exists;
if (!ot_dfd_iter_init_allow_noent (dfd, prefix, &dfd_iter, &exists, error))
return FALSE;
target_dfd = -1; /* Transferred */
/* Note early return */
if (!exists)
return TRUE;
while (TRUE)
{