Skip to content
Snippets Groups Projects
Commit 5ac0d702 authored by Colin Walters's avatar Colin Walters
Browse files

fdio: Only invoke fallocate() for sizes > 0

In some cases we want to replace with zero size, and `posix_fallocate()`
is documented to return `EINVAL` in this case.

Making this change since I noticed it elsewhere.
parent c2ba4d87
No related branches found
No related tags found
No related merge requests found
...@@ -926,12 +926,15 @@ glnx_file_replace_contents_with_perms_at (int dfd, ...@@ -926,12 +926,15 @@ glnx_file_replace_contents_with_perms_at (int dfd,
len = strlen ((char*)buf); len = strlen ((char*)buf);
/* Note that posix_fallocate does *not* set errno but returns it. */ /* Note that posix_fallocate does *not* set errno but returns it. */
r = posix_fallocate (fd, 0, len); if (len > 0)
if (r != 0)
{ {
errno = r; r = posix_fallocate (fd, 0, len);
glnx_set_error_from_errno (error); if (r != 0)
return FALSE; {
errno = r;
glnx_set_error_from_errno (error);
return FALSE;
}
} }
if ((r = glnx_loop_write (fd, buf, len)) != 0) if ((r = glnx_loop_write (fd, buf, len)) != 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment