equal
deleted
inserted
replaced
34 #include "lua.h" |
34 #include "lua.h" |
35 #include "lualib.h" |
35 #include "lualib.h" |
36 #include "lauxlib.h" |
36 #include "lauxlib.h" |
37 |
37 |
38 #include <fcntl.h> |
38 #include <fcntl.h> |
39 #if defined(_GNU_SOURCE) |
39 #if defined(__linux__) && defined(_GNU_SOURCE) |
40 #include <linux/falloc.h> |
40 #include <linux/falloc.h> |
41 #endif |
41 #endif |
42 |
42 |
43 #if (defined(_SVID_SOURCE) && !defined(WITHOUT_MALLINFO)) |
43 #if (defined(_SVID_SOURCE) && !defined(WITHOUT_MALLINFO)) |
44 #include <malloc.h> |
44 #include <malloc.h> |
668 FILE *f = *(FILE**) luaL_checkudata(L, 1, LUA_FILEHANDLE); |
668 FILE *f = *(FILE**) luaL_checkudata(L, 1, LUA_FILEHANDLE); |
669 |
669 |
670 offset = luaL_checkinteger(L, 2); |
670 offset = luaL_checkinteger(L, 2); |
671 len = luaL_checkinteger(L, 3); |
671 len = luaL_checkinteger(L, 3); |
672 |
672 |
673 #if defined(_GNU_SOURCE) |
673 #if defined(__linux__) && defined(_GNU_SOURCE) |
674 if(fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len) == 0) |
674 if(fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len) == 0) |
675 { |
675 { |
676 lua_pushboolean(L, 1); |
676 lua_pushboolean(L, 1); |
677 return 1; |
677 return 1; |
678 } |
678 } |