Add lchown, lchmod, statvfs, fstatvfs

This commit is contained in:
Justine Tunney 2022-08-22 20:49:33 -07:00
parent 7b74f6e20e
commit 5a632cf72d
24 changed files with 231 additions and 32 deletions

View file

@ -2237,9 +2237,12 @@ static int LuaUnixStatfsFfree(lua_State *L) {
}
// unix.Statfs:fsid()
// └─→ fsid:int
// └─→ x:int, y:int
static int LuaUnixStatfsFsid(lua_State *L) {
return ReturnInteger(L, GetUnixStatfs(L)->f_fsid);
struct statfs *f = GetUnixStatfs(L);
lua_pushinteger(L, f->f_fsid.__val[0]);
lua_pushinteger(L, f->f_fsid.__val[1]);
return 2;
}
// unix.Statfs:namelen()
@ -2314,10 +2317,14 @@ static int LuaUnixStatfsToString(lua_State *L) {
FormatInt64(ibuf, f->f_ffree);
luaL_addstring(&b, ibuf);
}
if (f->f_fsid) {
luaL_addstring(&b, ", fsid=");
FormatUint64(ibuf, f->f_fsid);
if (f->f_fsid.__val[0] || f->f_fsid.__val[1]) {
luaL_addstring(&b, ", fsid={");
FormatUint64(ibuf, f->f_fsid.__val[0]);
luaL_addstring(&b, ibuf);
luaL_addstring(&b, ", ");
FormatUint64(ibuf, f->f_fsid.__val[1]);
luaL_addstring(&b, ibuf);
luaL_addstring(&b, "}");
}
if (f->f_namelen) {
luaL_addstring(&b, ", namelen=");

View file

@ -13,12 +13,14 @@
#include "libc/calls/struct/iovec.h"
#include "libc/calls/struct/sched_param.h"
#include "libc/calls/struct/stat.macros.h"
#include "libc/calls/struct/statvfs.h"
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/calls/struct/tms.h"
#include "libc/calls/struct/utsname.h"
#include "libc/calls/struct/winsize.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/calls/sysparam.h"
#include "libc/calls/termios.h"
#include "libc/calls/weirdtypes.h"
#include "libc/dce.h"
@ -49,6 +51,7 @@
#include "libc/sysv/consts/prio.h"
#include "libc/sysv/consts/s.h"
#include "libc/sysv/consts/sched.h"
#include "libc/sysv/consts/seek.h"
#include "libc/sysv/consts/sf.h"
#include "libc/sysv/consts/sicode.h"
#include "libc/sysv/consts/st.h"
@ -122,14 +125,6 @@ module os
#define NAMLEN(dirent) strlen((dirent)->d_name)
#ifndef MAXPATHLEN
#if defined(PATH_MAX) && PATH_MAX > 1024 /* TODO: wut? */
#define MAXPATHLEN PATH_MAX
#else
#define MAXPATHLEN 1024
#endif
#endif /* MAXPATHLEN */
#ifdef UNION_WAIT
/* Emulate some macros on systems that have a union instead of macros */

View file

@ -142,8 +142,8 @@
#define HAVE_FSYNC 1
#define HAVE_GETENTROPY 1
#define HAVE_GETLOADAVG 1
#define HAVE_FSTATVFS 1
/* #undef HAVE_FEXECVE */
/* #undef HAVE_FSTATVFS */
/* #undef HAVE_FTIME */
/* #define HAVE_GETGROUPS 1 */
/* #define HAVE_SETGROUPS 1 */
@ -205,8 +205,8 @@
#define HAVE_GETLOGIN 1
#define HAVE_LCHOWN 1
#define HAVE_LCHMOD 1
/* #undef HAVE_LCHFLAGS */
/* #undef HAVE_LCHMOD */
/* Define to 1 if you have the `dl' library (-ldl). */
/* #undef HAVE_LIBDL */
@ -311,6 +311,7 @@
#define HAVE_WAIT3 1
#define HAVE_WAIT4 1
#define HAVE_WAITPID 1
#define HAVE_STATVFS 1
/* #define HAVE_MREMAP 1 */
/* #undef HAVE_PLOCK */
@ -320,7 +321,6 @@
/* #undef HAVE_TMPNAM */
/* #undef HAVE_TMPNAM_R */
/* #undef HAVE_SETPGRP */
/* #undef HAVE_STATVFS */
/* #undef HAVE_STAT_TV_NSEC2 */
/* #undef HAVE_SIGPENDING */
/* #undef HAVE_SIGRELSE */
@ -513,7 +513,7 @@
/* #define _Py_MEMORY_SANITIZER */
/* #define HAVE_DEV_PTMX 1 */
/* #define HAVE_OPENPTY 1 */
/* #define HAVE_OPENPTY 1 */
/* #undef HAVE__GETPTY */
/* #undef HAVE_DEV_PTC */
/* #define HAVE_FORKPTY 1 */