Build fixes
[project/luci.git] / libs / nixio / src / fs.c
index 10727d030bdea110d31c49e4142eb14f472d1d81..53a406081ca527f3d6658a7b0efc7a4a20f7c1ef 100644 (file)
@@ -254,17 +254,17 @@ static int nixio_link(lua_State *L) {
 
 static int nixio_utimes(lua_State *L) {
        const char *path = luaL_checkstring(L, 1);
-       if (lua_gettop(L) < 2) {
+       if (lua_gettop(L) < 2 || (lua_isnoneornil(L, 2) && lua_isnoneornil(L, 3))) {
                return nixio__pstatus(L, !utimes(path, NULL));
        } else {
-               double atime = luaL_checknumber(L, 2);
-               double mtime = luaL_optnumber(L, 3, atime);
+               double atime = luaL_checkinteger(L, 2);
+               double mtime = luaL_optinteger(L, 3, atime);
                struct timeval times[2];
 
                times[0].tv_sec = atime;
-               times[0].tv_usec = (long)((atime - (int64_t)atime) * 1000000);
+               times[0].tv_usec = 0;
                times[1].tv_sec = mtime;
-               times[1].tv_usec = (long)((mtime - (int64_t)mtime) * 1000000);
+               times[1].tv_usec = 0;
 
                return nixio__pstatus(L, !utimes(path, times));
        }
@@ -317,7 +317,7 @@ int nixio__push_stat(lua_State *L, nixio_stat_t *buf) {
        lua_pushinteger(L, buf->st_rdev);
        lua_setfield(L, -2, "rdev");
 
-       lua_pushnumber(L, buf->st_size);
+       lua_pushinteger(L, buf->st_size);
        lua_setfield(L, -2, "size");
 
        lua_pushinteger(L, buf->st_atime);
@@ -469,37 +469,37 @@ static int nixio_glob(lua_State *L) {
 static int nixio__push_statvfs(lua_State *L, struct statvfs *buf) {
        lua_createtable(L, 0, 12);
 
-       lua_pushnumber(L, buf->f_bavail);
+       lua_pushinteger(L, buf->f_bavail);
        lua_setfield(L, -2, "bavail");
 
-       lua_pushnumber(L, buf->f_bfree);
+       lua_pushinteger(L, buf->f_bfree);
        lua_setfield(L, -2, "bfree");
 
-       lua_pushnumber(L, buf->f_blocks);
+       lua_pushinteger(L, buf->f_blocks);
        lua_setfield(L, -2, "blocks");
 
-       lua_pushnumber(L, buf->f_bsize);
+       lua_pushinteger(L, buf->f_bsize);
        lua_setfield(L, -2, "bsize");
 
-       lua_pushnumber(L, buf->f_frsize);
+       lua_pushinteger(L, buf->f_frsize);
        lua_setfield(L, -2, "frsize");
 
-       lua_pushnumber(L, buf->f_favail);
+       lua_pushinteger(L, buf->f_favail);
        lua_setfield(L, -2, "favail");
 
-       lua_pushnumber(L, buf->f_ffree);
+       lua_pushinteger(L, buf->f_ffree);
        lua_setfield(L, -2, "ffree");
 
-       lua_pushnumber(L, buf->f_files);
+       lua_pushinteger(L, buf->f_files);
        lua_setfield(L, -2, "files");
 
-       lua_pushnumber(L, buf->f_flag);
+       lua_pushinteger(L, buf->f_flag);
        lua_setfield(L, -2, "flag");
 
-       lua_pushnumber(L, buf->f_fsid);
+       lua_pushinteger(L, buf->f_fsid);
        lua_setfield(L, -2, "fsid");
 
-       lua_pushnumber(L, buf->f_namemax);
+       lua_pushinteger(L, buf->f_namemax);
        lua_setfield(L, -2, "namemax");
 
        return 1;