aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-02-28 13:26:05 +0100
committerKim Alvefur <zash@zash.se>2017-02-28 13:26:05 +0100
commitd6184b31a325c1621e86217ba3d01afa7e685788 (patch)
tree1f7976a0a08497f4fe97e1373afb81fa1bb267fb
parent7b4ad0e69498476165948e09ee8c7ddd9d1da07a (diff)
downloadprosody-d6184b31a325c1621e86217ba3d01afa7e685788.tar.gz
prosody-d6184b31a325c1621e86217ba3d01afa7e685788.zip
util.pposix: Remove fallocate
-rw-r--r--plugins/mod_posix.lua2
-rwxr-xr-xprosodyctl2
-rw-r--r--util-src/pposix.c61
3 files changed, 3 insertions, 62 deletions
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index 412a7779..5a6cd0c2 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -7,7 +7,7 @@
--
-local want_pposix_version = "0.3.7";
+local want_pposix_version = "0.4.0";
local pposix = assert(require "util.pposix");
if pposix._VERSION ~= want_pposix_version then
diff --git a/prosodyctl b/prosodyctl
index 4fb67a95..be68f0f4 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -135,7 +135,7 @@ dependencies.log_warnings();
-- Switch away from root and into the prosody user --
local switched_user, current_uid;
-local want_pposix_version = "0.3.7";
+local want_pposix_version = "0.4.0";
local ok, pposix = pcall(require, "util.pposix");
if ok and pposix then
diff --git a/util-src/pposix.c b/util-src/pposix.c
index a68aa89d..e70a9d7f 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -13,7 +13,7 @@
* POSIX support functions for Lua
*/
-#define MODULE_VERSION "0.3.7"
+#define MODULE_VERSION "0.4.0"
#if defined(__linux__)
@@ -730,64 +730,6 @@ int lc_meminfo(lua_State *L) {
}
#endif
-/* File handle extraction blatantly stolen from
- * https://github.com/rrthomas/luaposix/blob/master/lposix.c#L631
- * */
-
-int lc_fallocate(lua_State *L) {
- int ret;
- off_t offset, len;
- FILE *f = *(FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE);
-
- if(f == NULL) {
- return luaL_error(L, "attempt to use a closed file");
- }
-
- offset = luaL_checkinteger(L, 2);
- len = luaL_checkinteger(L, 3);
-
-#if defined(__linux__)
- 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) {
- lua_pushnil(L);
- lua_pushstring(L, strerror(errno));
- return 2;
- }
-
-#endif
-
- ret = posix_fallocate(fileno(f), offset, len);
-
- if(ret == 0) {
- lua_pushboolean(L, 1);
- return 1;
- } else {
- lua_pushnil(L);
- lua_pushstring(L, strerror(ret));
-
- /* posix_fallocate() can leave a bunch of NULs at the end, so we cut that
- * this assumes that offset == length of the file */
- if(ftruncate(fileno(f), offset) != 0) {
- lua_pushstring(L, strerror(errno));
- return 3;
- }
-
- return 2;
- }
-}
-
/*
* Append some data to a file handle
* Attempt to allocate space first
@@ -889,7 +831,6 @@ int luaopen_util_pposix(lua_State *L) {
{ "meminfo", lc_meminfo },
#endif
- { "fallocate", lc_fallocate },
{ "atomic_append", lc_atomic_append },
{ NULL, NULL }