aboutsummaryrefslogtreecommitdiffstats
path: root/util-src/pposix.c
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-04-25 02:41:55 +0200
committerKim Alvefur <zash@zash.se>2014-04-25 02:41:55 +0200
commitecf04ddb9a9531e6e53de5bb60c6fd46faf64323 (patch)
treed9f91de224bd763aca6719558d89d15184375cd6 /util-src/pposix.c
parent504be3c65f8eda71428ac4da8e97e6450d44b1d9 (diff)
downloadprosody-ecf04ddb9a9531e6e53de5bb60c6fd46faf64323.tar.gz
prosody-ecf04ddb9a9531e6e53de5bb60c6fd46faf64323.zip
util.pposix: Fix error reporting from really old Linux fallocate() that did not use errno for some reason (thanks pro)
Diffstat (limited to 'util-src/pposix.c')
-rw-r--r--util-src/pposix.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c
index a8654995..df814c28 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -674,11 +674,15 @@ int lc_fallocate(lua_State* L)
len = luaL_checkinteger(L, 3);
#if defined(__linux__) && defined(_GNU_SOURCE)
- if(fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len) == 0)
+ errno = 0;
+ ret = fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len);
+ if(ret == 0)
{
lua_pushboolean(L, 1);
return 1;
}
+ /* Some old versions of Linux apparently use the return value instead of errno */
+ if(errno == 0) errno = ret;
if(errno != ENOSYS && errno != EOPNOTSUPP)
{