diff options
author | Colin Walters <walters@verbum.org> | 2017-06-12 17:00:53 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-06-13 11:43:29 -0400 |
commit | 05abf2143f967cd85b1b1b777ee412a581979cf1 (patch) | |
tree | c556a50df731405cab5b1adb045a3dd38ca17477 /glnx-fdio.c | |
parent | f5ba01cf65309164adb06067b39cf28c071e1ccb (diff) | |
download | libglnx-05abf2143f967cd85b1b1b777ee412a581979cf1.tar.gz |
fdio: Add glnx_try_fallocate()
The glibc `posix_fallocate()` implementation has a bad fallback,
and further we need to handle `EOPNOTSUPP` for musl.
https://github.com/flatpak/flatpak/issues/802
Diffstat (limited to 'glnx-fdio.c')
-rw-r--r-- | glnx-fdio.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/glnx-fdio.c b/glnx-fdio.c index 19de9ec..87e2dbb 100644 --- a/glnx-fdio.c +++ b/glnx-fdio.c @@ -920,7 +920,6 @@ glnx_file_replace_contents_with_perms_at (int dfd, GCancellable *cancellable, GError **error) { - int r; char *dnbuf = strdupa (subpath); const char *dn = dirname (dnbuf); @@ -940,16 +939,8 @@ glnx_file_replace_contents_with_perms_at (int dfd, if (len == -1) len = strlen ((char*)buf); - /* Note that posix_fallocate does *not* set errno but returns it. */ - if (len > 0) - { - r = posix_fallocate (tmpf.fd, 0, len); - if (r != 0) - { - errno = r; - return glnx_throw_errno_prefix (error, "fallocate"); - } - } + if (!glnx_try_fallocate (tmpf.fd, 0, len, error)) + return FALSE; if (glnx_loop_write (tmpf.fd, buf, len) < 0) return glnx_throw_errno (error); |