Polyfill statfs() and fstatfs() on BSD distros

This commit is contained in:
Justine Tunney 2022-08-17 13:41:21 -07:00
parent e3fe127ccd
commit f7ee9d7d99
42 changed files with 968 additions and 287 deletions

View file

@ -1,2 +0,0 @@
.include "o/libc/sysv/macros.internal.inc"
.scall fstatfs,0xfff04022c215a08a,globl

View file

@ -1,2 +0,0 @@
.include "o/libc/sysv/macros.internal.inc"
.scall statfs,0xfff03f22b2159089,globl

View file

@ -0,0 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall sys_fstatfs,0x09f04022c215a08a,globl,hidden

View file

@ -0,0 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall sys_statfs,0x09d03f22b2159089,globl,hidden

View file

@ -304,6 +304,12 @@ syscon misc SIG_UNBLOCK 1 2 2 2 2 1 # bsd consensus; faked nt
syscon misc SIG_SETMASK 2 3 3 3 3 2 # bsd consensus; faked nt
syscon misc SIG_ATOMIC_MIN -2147483648 -2147483648 -9223372036854775808 -2147483648 -2147483648 0
# lseek() whence
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon splice SEEK_HOLE 4 3 4 -1 -1 -1 #
syscon splice SEEK_DATA 3 4 3 -1 -1 -1 #
# splice() flags
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
@ -1146,21 +1152,21 @@ syscon ms MS_SYNC 4 16 0 2 4 4 # faked nt
syscon ms MS_ASYNC 1 1 1 1 1 1 # consensus (faked nt)
syscon ms MS_INVALIDATE 2 2 2 4 2 0
# statvfs() flags
# statfs() flags
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon statvfs ST_RDONLY 1 1 1 1 1 0 # unix consensus
syscon statvfs ST_NOSUID 2 2 2 2 2 0 # unix consensus
syscon statvfs ST_NODEV 4 0 0 0 0x00000010 0
syscon statvfs ST_NOEXEC 8 0 0 0 4 0
syscon statvfs ST_SYNCHRONOUS 16 0 0 0 2 0
syscon statvfs ST_APPEND 0x0100 0 0 0 0 0
syscon statvfs ST_IMMUTABLE 0x0200 0 0 0 0 0
syscon statvfs ST_MANDLOCK 0x0040 0 0 0 0 0
syscon statvfs ST_NOATIME 0x0400 0 0 0x04000000 0 0
syscon statvfs ST_NODIRATIME 0x0800 0 0 0 0 0
syscon statvfs ST_WRITE 0x0080 0 0 0 0 0
syscon statvfs ST_RELATIME 0x1000 0 0 0 0x00020000 0
syscon statfs ST_RDONLY 1 1 1 1 1 0 # MNT_RDONLY on BSD
syscon statfs ST_NOSUID 2 8 8 8 8 0 # MNT_NOSUID on BSD
syscon statfs ST_NODEV 4 16 0 16 16 0 # MNT_NODEV on BSD
syscon statfs ST_NOEXEC 8 4 4 4 4 0 # MNT_NOEXEC on BSD
syscon statfs ST_SYNCHRONOUS 16 2 2 2 2 0 # MNT_SYNCHRONOUS on BSD
syscon statfs ST_NOATIME 0x0040 0x10000000 0x10000000 0x00008000 0x04000000 0 # MNT_NOATIME on BSD
syscon statfs ST_RELATIME 0x1000 0 0 0 0x00020000 0 # MNT_RELATIME on NetBSD
syscon statfs ST_APPEND 0x0100 0 0 0 0 0 #
syscon statfs ST_IMMUTABLE 0x0200 0 0 0 0 0 #
syscon statfs ST_MANDLOCK 0x0040 0 0 0 0 0 #
syscon statfs ST_NODIRATIME 0x0800 0 0 0 0 0 #
syscon statfs ST_WRITE 0x0080 0 0 0 0 0 #
# sendfile() flags
#

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon splice,SEEK_DATA,3,4,3,-1,-1,-1

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon splice,SEEK_HOLE,4,3,4,-1,-1,-1

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_APPEND,0x0100,0,0,0,0,0
.syscon statfs,ST_APPEND,0x0100,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_IMMUTABLE,0x0200,0,0,0,0,0
.syscon statfs,ST_IMMUTABLE,0x0200,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_MANDLOCK,0x0040,0,0,0,0,0
.syscon statfs,ST_MANDLOCK,0x0040,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_NOATIME,0x0400,0,0,0x04000000,0,0
.syscon statfs,ST_NOATIME,0x0040,0x10000000,0x10000000,0x00008000,0x04000000,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_NODEV,4,0,0,0,0x00000010,0
.syscon statfs,ST_NODEV,4,16,0,16,16,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_NODIRATIME,0x0800,0,0,0,0,0
.syscon statfs,ST_NODIRATIME,0x0800,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_NOEXEC,8,0,0,0,4,0
.syscon statfs,ST_NOEXEC,8,4,4,4,4,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_NOSUID,2,2,2,2,2,0
.syscon statfs,ST_NOSUID,2,8,8,8,8,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_RDONLY,1,1,1,1,1,0
.syscon statfs,ST_RDONLY,1,1,1,1,1,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_RELATIME,0x1000,0,0,0,0x00020000,0
.syscon statfs,ST_RELATIME,0x1000,0,0,0,0x00020000,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_SYNCHRONOUS,16,0,0,0,2,0
.syscon statfs,ST_SYNCHRONOUS,16,2,2,2,2,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_WRITE,0x0080,0,0,0,0,0
.syscon statfs,ST_WRITE,0x0080,0,0,0,0,0

16
libc/sysv/consts/seek.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_SEEK_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_SEEK_H_
#include "libc/runtime/symbolic.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const int SEEK_DATA;
extern const int SEEK_HOLE;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#define SEEK_DATA SYMBOLIC(SEEK_DATA)
#define SEEK_HOLE SYMBOLIC(SEEK_HOLE)
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_SEEK_H_ */

View file

@ -168,8 +168,8 @@ scall sys_mknod 0x1c200e00e200e085 globl hidden
scall mknodat 0x1cc14022fffff103 globl # FreeBSD 12+
scall sys_mkfifo 0x0840840842084fff globl hidden
scall mkfifoat 0x1cb13f1f1fffffff globl
scall statfs 0xfff03f22b2159089 globl
scall fstatfs 0xfff04022c215a08a globl
scall sys_statfs 0x09d03f22b2159089 globl hidden
scall sys_fstatfs 0x09f04022c215a08a globl hidden
scall sys_getpriority 0x064064064206408c globl hidden
scall sys_setpriority 0x060060060206008d globl hidden # modern nice()
scall mlock 0x0cb0cb0cb20cb095 globl