Comparison

util-src/pposix.c @ 6155:dc3497041aca

util.pposix: Fix error reporting from really old Linux fallocate() that did not use errno for some reason (thanks pro)
author Kim Alvefur <zash@zash.se>
date Fri, 25 Apr 2014 02:41:55 +0200
parent 6154:dfe88a0e18fd
child 6156:6b1aee6536e8
comparison
equal deleted inserted replaced
6154:dfe88a0e18fd 6155:dc3497041aca
672 672
673 offset = luaL_checkinteger(L, 2); 673 offset = luaL_checkinteger(L, 2);
674 len = luaL_checkinteger(L, 3); 674 len = luaL_checkinteger(L, 3);
675 675
676 #if defined(__linux__) && defined(_GNU_SOURCE) 676 #if defined(__linux__) && defined(_GNU_SOURCE)
677 if(fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len) == 0) 677 errno = 0;
678 ret = fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len);
679 if(ret == 0)
678 { 680 {
679 lua_pushboolean(L, 1); 681 lua_pushboolean(L, 1);
680 return 1; 682 return 1;
681 } 683 }
684 /* Some old versions of Linux apparently use the return value instead of errno */
685 if(errno == 0) errno = ret;
682 686
683 if(errno != ENOSYS && errno != EOPNOTSUPP) 687 if(errno != ENOSYS && errno != EOPNOTSUPP)
684 { 688 {
685 lua_pushnil(L); 689 lua_pushnil(L);
686 lua_pushstring(L, strerror(errno)); 690 lua_pushstring(L, strerror(errno));