libglnx porting: Use glnx_set_error_from_errno

⚠️ There is a notable spiked pit trap here around
`posix_fallocate()` and `errno`.  This has bit other projects,
see e.g.
https://github.com/systemd/systemd/commit/7bb87460e691d30c1a7fd23a1a8240776957e05f

Otherwise the port was straightforward.
This commit is contained in:
Colin Walters committed 2016-03-23 10:26:01 -04:00
1 parent 614483ecd1
commit d456fe5adb
13 files changed
+88 -87

No files matched your search

+6 -6
View File
@@ -45,7 +45,7 @@ ot_gopendirat (int dfd,
int ret = ot_opendirat (dfd, path, follow);
if (ret == -1)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
return FALSE;
}
*out_fd = ret;
@@ -71,7 +71,7 @@ ot_lgetxattrat (int dfd,
while (G_UNLIKELY (bytes_read < 0 && errno == EINTR));
if (G_UNLIKELY (bytes_read < 0))
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
@@ -81,7 +81,7 @@ ot_lgetxattrat (int dfd,
while (G_UNLIKELY (real_size < 0 && errno == EINTR));
if (G_UNLIKELY (real_size < 0))
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
g_free (buf);
goto out;
}
@@ -111,7 +111,7 @@ ot_lsetxattrat (int dfd,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
return FALSE;
}
@@ -134,7 +134,7 @@ ot_readlinkat_gfile_info (int dfd,
while (G_UNLIKELY (len == -1 && errno == EINTR));
if (len == -1)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
targetbuf[len] = '\0';
@@ -180,7 +180,7 @@ ot_openat_read_stream (int dfd,
while (G_UNLIKELY (fd == -1 && errno == EINTR));
if (fd == -1)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
+6 -4
View File
@@ -309,7 +309,9 @@ ot_file_replace_contents_at (int dfd,
int r = posix_fallocate (fd, 0, g_bytes_get_size (contents));
if (r != 0)
{
gs_set_error_from_errno (error, r);
/* posix_fallocate is a weird deviation from errno standards */
errno = r;
glnx_set_error_from_errno (error);
goto out;
}
}
@@ -320,7 +322,7 @@ ot_file_replace_contents_at (int dfd,
if (datasync && fdatasync (fd) != 0)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
@@ -329,7 +331,7 @@ ot_file_replace_contents_at (int dfd,
if (renameat (dfd, tmpname, dfd, path) == -1)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
@@ -429,7 +431,7 @@ ot_util_fsync_directory (GFile *dir,
if (fsync (dfd) != 0)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
+2 -2
View File
@@ -204,7 +204,7 @@ ot_util_variant_map_fd (int fd,
if (fstat (fd, &stbuf) != 0)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}
@@ -212,7 +212,7 @@ ot_util_variant_map_fd (int fd,
map = mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, start);
if (!map)
{
gs_set_error_from_errno (error, errno);
glnx_set_error_from_errno (error);
goto out;
}