[libglnx] fdio: Only invoke fallocate() for sizes > 0
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] fdio: Only invoke fallocate() for sizes > 0
- Date: Thu, 4 Aug 2016 18:43:40 +0000 (UTC)
commit 5ac0d702d70b00887f9329e47f4d5653e994531a
Author: Colin Walters <walters verbum org>
Date: Wed Aug 3 11:00:08 2016 -0400
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.
glnx-fdio.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/glnx-fdio.c b/glnx-fdio.c
index 8200660..19144da 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -926,12 +926,15 @@ glnx_file_replace_contents_with_perms_at (int dfd,
len = strlen ((char*)buf);
/* Note that posix_fallocate does *not* set errno but returns it. */
- r = posix_fallocate (fd, 0, len);
- if (r != 0)
+ if (len > 0)
{
- errno = r;
- glnx_set_error_from_errno (error);
- return FALSE;
+ r = posix_fallocate (fd, 0, len);
+ if (r != 0)
+ {
+ errno = r;
+ glnx_set_error_from_errno (error);
+ return FALSE;
+ }
}
if ((r = glnx_loop_write (fd, buf, len)) != 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]