mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Improve isystem includes and magic numbers
This commit is contained in:
parent
1e5bd4d23e
commit
228fb7428b
143 changed files with 1183 additions and 266 deletions
|
@ -50,6 +50,8 @@ endif
|
|||
|
||||
# Release Mode
|
||||
#
|
||||
# Follows traditional closed source release binary norms.
|
||||
#
|
||||
# - `make MODE=rel`
|
||||
# - More optimized
|
||||
# - Reasonably small
|
||||
|
@ -74,14 +76,40 @@ TARGET_ARCH ?= \
|
|||
|
||||
endif
|
||||
|
||||
# Asan Mode
|
||||
#
|
||||
# Safer binaries good for backend production serving.
|
||||
#
|
||||
# - `make MODE=asan`
|
||||
# - Memory safety
|
||||
# - Production worthy
|
||||
# - Backtraces
|
||||
# - Debuggability
|
||||
# - Larger binaries
|
||||
|
||||
ifeq ($(MODE), asan)
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
|
||||
CONFIG_COPTS += \
|
||||
-fsanitize=address
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
endif
|
||||
|
||||
# Debug Mode
|
||||
#
|
||||
# - `make MODE=dbg`
|
||||
# - Backtraces
|
||||
# - Zero optimization
|
||||
# - Enables sanitization
|
||||
# - Enables stack canaries
|
||||
# - Enormous binaries (b/c ubsan suboptimalities)
|
||||
# - Enables asan
|
||||
# - Enables ubsan (TODO)
|
||||
# - Stack canaries
|
||||
# - No optimization (TODO)
|
||||
# - Enormous binaries
|
||||
|
||||
ifeq ($(MODE), dbg)
|
||||
|
||||
|
@ -91,11 +119,10 @@ CONFIG_CPPFLAGS += \
|
|||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-Og
|
||||
-O2
|
||||
|
||||
CONFIG_COPTS += \
|
||||
$(SECURITY_BLANKETS) \
|
||||
$(SANITIZER)
|
||||
-fsanitize=address
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
@ -116,6 +143,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tiny)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -143,6 +171,7 @@ endif
|
|||
# - No portability
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinylinux)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -172,6 +201,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinylinuxbsd)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -200,6 +230,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinysysv)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
@ -228,6 +259,7 @@ endif
|
|||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinynowin)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
|
|
55
libc/bits/newbie.h
Normal file
55
libc/bits/newbie.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_NEWBIE_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_NEWBIE_H_
|
||||
#include "libc/bits/bswap.h"
|
||||
|
||||
/*
|
||||
* Macros for newbies.
|
||||
* https://justine.lol/endian.html
|
||||
*/
|
||||
|
||||
#define BYTE_ORDER __BYTE_ORDER__
|
||||
#define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
|
||||
#define BIG_ENDIAN __ORDER_BIG_ENDIAN__
|
||||
#define PDP_ENDIAN __ORDER_PDP_ENDIAN__
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define htobe16(x) bswap_16(x)
|
||||
#define be16toh(x) bswap_16(x)
|
||||
#define betoh16(x) bswap_16(x)
|
||||
#define htobe32(x) bswap_32(x)
|
||||
#define be32toh(x) bswap_32(x)
|
||||
#define betoh32(x) bswap_32(x)
|
||||
#define htobe64(x) bswap_64(x)
|
||||
#define be64toh(x) bswap_64(x)
|
||||
#define betoh64(x) bswap_64(x)
|
||||
#define htole16(x) (uint16_t)(x)
|
||||
#define le16toh(x) (uint16_t)(x)
|
||||
#define letoh16(x) (uint16_t)(x)
|
||||
#define htole32(x) (uint32_t)(x)
|
||||
#define le32toh(x) (uint32_t)(x)
|
||||
#define letoh32(x) (uint32_t)(x)
|
||||
#define htole64(x) (uint64_t)(x)
|
||||
#define le64toh(x) (uint64_t)(x)
|
||||
#define letoh64(x) (uint64_t)(x)
|
||||
#else
|
||||
#define htobe16(x) (uint16_t)(x)
|
||||
#define be16toh(x) (uint16_t)(x)
|
||||
#define betoh16(x) (uint16_t)(x)
|
||||
#define htobe32(x) (uint32_t)(x)
|
||||
#define be32toh(x) (uint32_t)(x)
|
||||
#define betoh32(x) (uint32_t)(x)
|
||||
#define htobe64(x) (uint64_t)(x)
|
||||
#define be64toh(x) (uint64_t)(x)
|
||||
#define betoh64(x) (uint64_t)(x)
|
||||
#define htole16(x) bswap_16(x)
|
||||
#define le16toh(x) bswap_16(x)
|
||||
#define letoh16(x) bswap_16(x)
|
||||
#define htole32(x) bswap_32(x)
|
||||
#define le32toh(x) bswap_32(x)
|
||||
#define letoh32(x) bswap_32(x)
|
||||
#define htole64(x) bswap_64(x)
|
||||
#define le64toh(x) bswap_64(x)
|
||||
#define letoh64(x) bswap_64(x)
|
||||
#endif
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_BITS_NEWBIE_H_ */
|
|
@ -151,6 +151,7 @@ int posix_fadvise(int, uint64_t, uint64_t, int);
|
|||
int posix_madvise(void *, uint64_t, int);
|
||||
int prctl();
|
||||
int raise(int);
|
||||
int reboot(int);
|
||||
int readlink(const char *, char *, size_t);
|
||||
int remove(const char *);
|
||||
int rename(const char *, const char *);
|
||||
|
|
|
@ -41,10 +41,11 @@ LIBC_CALLS_A_DIRECTDEPS = \
|
|||
LIBC_INTRIN \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_NT_IPHLPAPI \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_NT_NTDLL \
|
||||
LIBC_NT_POWERPROF \
|
||||
LIBC_NT_WS2_32 \
|
||||
LIBC_NT_IPHLPAPI \
|
||||
LIBC_STR \
|
||||
LIBC_STUBS \
|
||||
LIBC_SYSV_CALLS \
|
||||
|
|
28
libc/calls/ftok.c
Normal file
28
libc/calls/ftok.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
int ftok(const char *path, int id) {
|
||||
struct stat st;
|
||||
if (stat(path, &st) == -1) return -1;
|
||||
return (uint32_t)id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff);
|
||||
}
|
20
libc/calls/ipc.h
Normal file
20
libc/calls/ipc.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_IPC_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_IPC_H_
|
||||
|
||||
#define IPC_PRIVATE 0
|
||||
#define IPC_RMID 0
|
||||
#define IPC_SET 1
|
||||
#define IPC_STAT 2
|
||||
#define IPC_INFO 3
|
||||
#define IPC_CREAT 01000
|
||||
#define IPC_EXCL 02000
|
||||
#define IPC_NOWAIT 04000
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int ftok(const char *, int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_IPC_H_ */
|
100
libc/calls/mount.c
Normal file
100
libc/calls/mount.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/mount.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
int32_t sys_mount_linux(const char *source, const char *target,
|
||||
const char *filesystemtype, uint64_t mountflags,
|
||||
const void *data) asm("sys_mount");
|
||||
int32_t sys_mount_bsd(const char *type, const char *dir, int32_t flags,
|
||||
void *data) asm("sys_mount");
|
||||
|
||||
/**
|
||||
* Mounts file system.
|
||||
*
|
||||
* The following flags may be specified:
|
||||
*
|
||||
* - `MS_RDONLY` (mount read-only)
|
||||
* - `MS_NOSUID` (don't honor S_ISUID bit)
|
||||
* - `MS_NODEV` (disallow special files)
|
||||
* - `MS_NOEXEC` (disallow program execution)
|
||||
* - `MS_SYNCHRONOUS` (writes are synced at once)
|
||||
* - `MS_NOATIME` (do not update access times)
|
||||
* - `MS_REMOUNT` (tune existing mounting)
|
||||
*
|
||||
* The following flags may also be used, but could be set to zero at
|
||||
* runtime if the underlying kernel doesn't support them.
|
||||
*
|
||||
* - `MNT_ASYNC` (xnu, freebsd, openbsd, netbsd)
|
||||
* - `MNT_RELOAD` (xnu, freebsd, openbsd, netbsd)
|
||||
* - `MS_STRICTATIME` (linux, xnu)
|
||||
* - `MS_RELATIME` (linux, netbsd)
|
||||
* - `MNT_SNAPSHOT` (xnu, freebsd)
|
||||
* - `MS_MANDLOCK` (linux)
|
||||
* - `MS_DIRSYNC` (linux)
|
||||
* - `MS_NODIRATIME` (linux)
|
||||
* - `MS_BIND` (linux)
|
||||
* - `MS_MOVE` (linux)
|
||||
* - `MS_REC` (linux)
|
||||
* - `MS_SILENT` (linux)
|
||||
* - `MS_POSIXACL` (linux)
|
||||
* - `MS_UNBINDABLE` (linux)
|
||||
* - `MS_PRIVATE` (linux)
|
||||
* - `MS_SLAVE` (linux)
|
||||
* - `MS_SHARED` (linux)
|
||||
* - `MS_KERNMOUNT` (linux)
|
||||
* - `MS_I_VERSION` (linux)
|
||||
* - `MS_LAZYTIME` (linux)
|
||||
* - `MS_ACTIVE` (linux)
|
||||
* - `MS_NOUSER` (linux)
|
||||
* - `MS_RMT`_MASK (linux)
|
||||
* - `MNT_SUIDDIR` (freebsd)
|
||||
* - `MNT_NOCLUSTERR` (freebsd)
|
||||
* - `MNT_NOCLUSTERW` (freebsd)
|
||||
*
|
||||
* Some example values for the `type` parameter:
|
||||
*
|
||||
* - `"nfs"`
|
||||
* - `"vfat"`
|
||||
* - `"tmpfs"`
|
||||
* - `"iso8601"`
|
||||
*
|
||||
*/
|
||||
int mount(const char *source, const char *target, const char *type,
|
||||
unsigned long flags, const void *data) {
|
||||
if (!IsWindows()) {
|
||||
if (!IsBsd()) {
|
||||
return sys_mount_linux(source, target, type, flags, data);
|
||||
} else {
|
||||
if (!strcmp(type, "iso9660")) type = "cd9660";
|
||||
if (!strcmp(type, "vfat")) {
|
||||
if (IsOpenbsd() || IsNetbsd()) {
|
||||
type = "msdos";
|
||||
} else {
|
||||
type = "msdosfs";
|
||||
}
|
||||
}
|
||||
return sys_mount_bsd(type, target, flags, data);
|
||||
}
|
||||
} else {
|
||||
return enosys();
|
||||
}
|
||||
}
|
17
libc/calls/mount.h
Normal file
17
libc/calls/mount.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_MOUNT_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_MOUNT_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int mount(const char *, const char *, const char *, unsigned long,
|
||||
const void *);
|
||||
int unmount(const char *, int);
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
int umount(const char *);
|
||||
int umount2(const char *, int);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_MOUNT_H_ */
|
93
libc/calls/reboot.c
Normal file
93
libc/calls/reboot.c
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/framebuffervirtualscreeninfo.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nt/system.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
#define kNtShutdownForceOthers 1
|
||||
#define kNtShutdownForceSelf 2
|
||||
#define kNtShutdownGraceOverride 0x20
|
||||
#define kNtShutdownHybrid 0x200
|
||||
|
||||
int32_t sys_reboot_linux(int32_t, int32_t, int32_t) asm("sys_reboot");
|
||||
int32_t sys_reboot_bsd(int32_t, const char *) asm("sys_reboot");
|
||||
|
||||
/**
|
||||
* Reboots system.
|
||||
*
|
||||
* The `howto` argument may be one of the following:
|
||||
*
|
||||
* - `RB_AUTOBOOT`
|
||||
* - `RB_POWER_OFF`
|
||||
* - `RB_HALT_SYSTEM`
|
||||
* - `RB_SW_SUSPEND` (linux and windows only)
|
||||
* - `RB_KEXEC` (linux only)
|
||||
* - `RB_ENABLE_CAD` (linux only)
|
||||
* - `RB_DISABLE_CAD` (linux only)
|
||||
*
|
||||
* There's an implicit `sync()` operation before the reboot happens.
|
||||
* This can be prevented by or'ing `howto` with `RB_NOSYNC`. Setting
|
||||
* this option will also prevent apps on Windows from having time to
|
||||
* close themselves.
|
||||
*/
|
||||
int reboot(int howto) {
|
||||
bool ok, immediately;
|
||||
if (howto != -1) {
|
||||
if (!(howto & 0x20000000)) {
|
||||
sync();
|
||||
immediately = false;
|
||||
} else {
|
||||
howto &= ~0x20000000;
|
||||
immediately = true;
|
||||
}
|
||||
if (!IsWindows()) {
|
||||
if (IsLinux()) {
|
||||
return sys_reboot_linux(0xFEE1DEAD, 0x28121969, howto);
|
||||
} else {
|
||||
return sys_reboot_bsd(howto, 0);
|
||||
}
|
||||
} else {
|
||||
if (howto == 0xD000FCE2u) {
|
||||
ok = !!SetSuspendState(0, 0, 0);
|
||||
} else {
|
||||
howto |= kNtShutdownForceOthers;
|
||||
howto |= kNtShutdownForceSelf;
|
||||
if (NtGetVersion() >= 8) {
|
||||
howto |= kNtShutdownHybrid;
|
||||
}
|
||||
if (immediately) {
|
||||
ok = !!InitiateShutdown(0, 0, 0, howto | kNtShutdownGraceOverride, 0);
|
||||
} else {
|
||||
ok = !!InitiateShutdown(0, 0, 20, howto, 0);
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return einval();
|
||||
}
|
||||
}
|
33
libc/calls/ttydefaults.h
Normal file
33
libc/calls/ttydefaults.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_TTYDEFAULTS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_TTYDEFAULTS_H_
|
||||
#include "libc/sysv/consts/baud.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
|
||||
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
|
||||
#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
|
||||
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE | ECHOKE | ECHOCTL)
|
||||
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
|
||||
#define TTYDEF_SPEED (B9600)
|
||||
|
||||
#define CTRL(x) ((x) ^ 0100)
|
||||
#define CEOF CTRL('D')
|
||||
#define CERASE CTRL('?')
|
||||
#define CINTR CTRL('C')
|
||||
#define CKILL CTRL('U')
|
||||
#define CQUIT CTRL('\\')
|
||||
#define CSUSP CTRL('Z')
|
||||
#define CDSUSP CTRL('Y')
|
||||
#define CSTART CTRL('Q')
|
||||
#define CSTOP CTRL('S')
|
||||
#define CLNEXT CTRL('V')
|
||||
#define CDISCARD CTRL('O')
|
||||
#define CWERASE CTRL('W')
|
||||
#define CREPRINT CTRL('R')
|
||||
#define CEOT CEOF
|
||||
#define CBRK CEOL
|
||||
#define CRPRNT CREPRINT
|
||||
#define CFLUSH CDISCARD
|
||||
#define CMIN 1
|
||||
#define CTIME 0
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_TTYDEFAULTS_H_ */
|
41
libc/calls/unmount.c
Normal file
41
libc/calls/unmount.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/mount.h"
|
||||
|
||||
int sys_unmount(const char *, int);
|
||||
|
||||
/**
|
||||
* Unmounts file system.
|
||||
*
|
||||
* The following flags may be specified:
|
||||
*
|
||||
* - `MNT_FORCE`
|
||||
*
|
||||
* The following flags may also be used, but could be set to zero at
|
||||
* runtime if the underlying kernel doesn't support them.
|
||||
*
|
||||
* - `MNT_DETACH`
|
||||
* - `MNT_EXPIRE`
|
||||
* - `UMOUNT_NOFOLLOW`
|
||||
* - `MNT_BYFSID`
|
||||
*
|
||||
*/
|
||||
int unmount(const char *target, int flags) {
|
||||
return sys_unmount(target, flags);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef LIBC_ISYSTEM_ENDIAN_H_
|
||||
#define LIBC_ISYSTEM_ENDIAN_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/bits/newbie.h"
|
||||
#endif
|
||||
|
|
4
libc/isystem/langinfo.h
Normal file
4
libc/isystem/langinfo.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_ */
|
4
libc/isystem/locale.h
Normal file
4
libc/isystem/locale.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LOCALE_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LOCALE_H_
|
||||
#include "libc/unicode/locale.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LOCALE_H_ */
|
|
@ -1,4 +1,8 @@
|
|||
#ifndef LIBC_ISYSTEM_SIGNAL_H_
|
||||
#define LIBC_ISYSTEM_SIGNAL_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
#endif
|
||||
|
|
7
libc/isystem/stat.h
Normal file
7
libc/isystem/stat.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STAT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STAT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STAT_H_ */
|
7
libc/isystem/strings.h
Normal file
7
libc/isystem/strings.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_
|
||||
#include "libc/str/str.h"
|
||||
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#include "libc/nexgen32e/ffs.h"
|
||||
#endif
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STRINGS_H_ */
|
5
libc/isystem/sys/dir.h
Normal file
5
libc/isystem/sys/dir.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_
|
||||
#include "libc/isystem/dirent.h"
|
||||
#define direct dirent
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_ */
|
4
libc/isystem/sys/errno.h
Normal file
4
libc/isystem/sys/errno.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_
|
||||
#include "libc/isystem/errno.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_ */
|
4
libc/isystem/sys/fcntl.h
Normal file
4
libc/isystem/sys/fcntl.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_
|
||||
#include "libc/isystem/fcntl.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_ */
|
10
libc/isystem/sys/file.h
Normal file
10
libc/isystem/sys/file.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_FILE_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_FILE_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/lock.h"
|
||||
|
||||
#define L_SET SEEK_SET
|
||||
#define L_INCR SEEK_CUR
|
||||
#define L_XTND SEEK_END
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_FILE_H_ */
|
|
@ -1,6 +1,11 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_IOCTL_H_
|
||||
#define LIBC_ISYSTEM_SYS_IOCTL_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/ioctl.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/sysv/consts/blk.h"
|
||||
#include "libc/sysv/consts/fd.h"
|
||||
#include "libc/sysv/consts/n.h"
|
||||
#include "libc/sysv/consts/pty.h"
|
||||
#include "libc/sysv/consts/sio.h"
|
||||
#endif
|
||||
|
|
6
libc/isystem/sys/ipc.h
Normal file
6
libc/isystem/sys/ipc.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_IPC_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_IPC_H_
|
||||
#include "libc/calls/ipc.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/ipc.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_IPC_H_ */
|
|
@ -1,6 +1,17 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_MMAN_H_
|
||||
#define LIBC_ISYSTEM_SYS_MMAN_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/mlock.h"
|
||||
#include "libc/sysv/consts/msync.h"
|
||||
#include "libc/sysv/consts/posix.h"
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#include "libc/sysv/consts/madv.h"
|
||||
#endif
|
||||
#if defined(_GNU_SOURCE)
|
||||
#include "libc/sysv/consts/mfd.h"
|
||||
#include "libc/sysv/consts/mremap.h"
|
||||
#endif
|
||||
#endif
|
||||
|
|
6
libc/isystem/sys/mount.h
Normal file
6
libc/isystem/sys/mount.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_MOUNT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_MOUNT_H_
|
||||
#include "libc/calls/mount.h"
|
||||
#include "libc/sysv/consts/mount.h"
|
||||
#include "libc/sysv/consts/unmount.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_MOUNT_H_ */
|
5
libc/isystem/sys/msg.h
Normal file
5
libc/isystem/sys/msg.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_MSG_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_MSG_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/msg.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_MSG_H_ */
|
4
libc/isystem/sys/poll.h
Normal file
4
libc/isystem/sys/poll.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_
|
||||
#include "libc/isystem/poll.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_ */
|
5
libc/isystem/sys/ptrace.h
Normal file
5
libc/isystem/sys/ptrace.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_PTRACE_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_PTRACE_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/ptrace.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_PTRACE_H_ */
|
5
libc/isystem/sys/reboot.h
Normal file
5
libc/isystem/sys/reboot.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_REBOOT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_REBOOT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/reboot.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_REBOOT_H_ */
|
|
@ -1,4 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_RESOURCE_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_RESOURCE_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/prio.h"
|
||||
#include "libc/sysv/consts/rlim.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
#include "libc/sysv/consts/rusage.h"
|
||||
#endif
|
||||
|
|
5
libc/isystem/sys/select.h
Normal file
5
libc/isystem/sys/select.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_SELECT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_SELECT_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sock/select.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_SELECT_H_ */
|
4
libc/isystem/sys/signal.h
Normal file
4
libc/isystem/sys/signal.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_
|
||||
#include "libc/isystem/signal.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_ */
|
4
libc/isystem/sys/statvfs.h
Normal file
4
libc/isystem/sys/statvfs.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_
|
||||
#include "libc/sysv/consts/st.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STATVFS_H_ */
|
4
libc/isystem/sys/syscall.h
Normal file
4
libc/isystem/sys/syscall.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_ */
|
4
libc/isystem/sys/termios.h
Normal file
4
libc/isystem/sys/termios.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_
|
||||
#include "libc/isystem/termios.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_ */
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_TIME_H_
|
||||
#define LIBC_ISYSTEM_SYS_TIME_H_
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/itimer.h"
|
||||
#include "libc/time/struct/timezone.h"
|
||||
#include "libc/time/time.h"
|
||||
#endif
|
||||
|
|
5
libc/isystem/sys/times.h
Normal file
5
libc/isystem/sys/times.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/tms.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TIMES_H_ */
|
4
libc/isystem/sys/ttydefaults.h
Normal file
4
libc/isystem/sys/ttydefaults.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_TTYDEFAULTS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TTYDEFAULTS_H_
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TTYDEFAULTS_H_ */
|
|
@ -1,4 +1,20 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_TYPES_H_
|
||||
#define LIBC_ISYSTEM_SYS_TYPES_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
typedef unsigned char u_int8_t;
|
||||
typedef unsigned short u_int16_t;
|
||||
typedef unsigned u_int32_t;
|
||||
typedef char *caddr_t;
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short, ushort;
|
||||
typedef unsigned u_int, uint;
|
||||
typedef unsigned long u_long, ulong;
|
||||
typedef long long quad_t;
|
||||
typedef unsigned long long u_quad_t;
|
||||
#include <endian.h>
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
4
libc/isystem/sys/un.h
Normal file
4
libc/isystem/sys/un.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_
|
||||
#include "libc/sock/sock.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_UN_H_ */
|
|
@ -1,4 +1,5 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_UTSNAME_H_
|
||||
#define LIBC_ISYSTEM_SYS_UTSNAME_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/utsname.h"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_WAIT_H_
|
||||
#define LIBC_ISYSTEM_SYS_WAIT_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
#endif
|
||||
|
|
6
libc/isystem/uio.h
Normal file
6
libc/isystem/uio.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_UIO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_UIO_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_UIO_H_ */
|
4
libc/isystem/wait.h
Normal file
4
libc/isystem/wait.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_
|
||||
#include "libc/isystem/sys/wait.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_ */
|
4
libc/isystem/zlib.h
Normal file
4
libc/isystem/zlib.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_ZLIB_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_ZLIB_H_
|
||||
#include "third_party/zlib/zlib.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_ZLIB_H_ */
|
12
libc/nt/PowerProf/SetSuspendState.s
Normal file
12
libc/nt/PowerProf/SetSuspendState.s
Normal file
|
@ -0,0 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp PowerProf,__imp_SetSuspendState,SetSuspendState,0
|
||||
|
||||
.text.windows
|
||||
SetSuspendState:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_SetSuspendState(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn SetSuspendState,globl
|
||||
.previous
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp advapi32,__imp_InitiateShutdownA,InitiateShutdownA,1402
|
||||
|
||||
.text.windows
|
||||
InitiateShutdownA:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_InitiateShutdownA(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn InitiateShutdownA,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp advapi32,__imp_InitiateShutdownW,InitiateShutdownW,1403
|
||||
|
||||
.text.windows
|
||||
InitiateShutdown:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_InitiateShutdownW(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn InitiateShutdown,globl
|
||||
.previous
|
||||
|
|
|
@ -2897,8 +2897,8 @@ imp 'InitializeSecurityDescriptor' InitializeSecurityDescriptor advapi32 0
|
|||
imp 'InitializeSid' InitializeSid advapi32 0 # KernelBase
|
||||
imp 'InitializeSynchronizationBarrier' InitializeSynchronizationBarrier kernel32 0 # KernelBase
|
||||
imp 'InitializeTouchInjection' InitializeTouchInjection user32 2034
|
||||
imp 'InitiateShutdownA' InitiateShutdownA advapi32 1402
|
||||
imp 'InitiateShutdown' InitiateShutdownW advapi32 1403
|
||||
imp 'InitiateShutdownA' InitiateShutdownA advapi32 1402 5
|
||||
imp 'InitiateShutdown' InitiateShutdownW advapi32 1403 5
|
||||
imp 'InitiateSystemShutdownA' InitiateSystemShutdownA advapi32 1404
|
||||
imp 'InitiateSystemShutdownExA' InitiateSystemShutdownExA advapi32 1405
|
||||
imp 'InitiateSystemShutdownEx' InitiateSystemShutdownExW advapi32 1406
|
||||
|
@ -6358,6 +6358,7 @@ imp 'SetStateVersion' SetStateVersion KernelBase 1549
|
|||
imp 'SetStdHandle' SetStdHandle kernel32 0 2 # KernelBase
|
||||
imp 'SetStdHandleEx' SetStdHandleEx KernelBase 1551
|
||||
imp 'SetStretchBltMode' SetStretchBltMode gdi32 1908
|
||||
imp 'SetSuspendState' SetSuspendState PowerProf 0 3
|
||||
imp 'SetSysColors' SetSysColors user32 2375
|
||||
imp 'SetSysColorsTemp' SetSysColorsTemp user32 2376
|
||||
imp 'SetSystemCursor' SetSystemCursor user32 2377
|
||||
|
|
|
@ -332,6 +332,25 @@ $(LIBC_NT_IPHLPAPI_A).pkg: \
|
|||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
LIBC_NT_ARTIFACTS += LIBC_NT_POWERPROF_A
|
||||
LIBC_NT_POWERPROF = $(LIBC_NT_POWERPROF_A_DEPS) $(LIBC_NT_POWERPROF_A)
|
||||
LIBC_NT_POWERPROF_A = o/$(MODE)/libc/nt/powerprof.a
|
||||
LIBC_NT_POWERPROF_A_SRCS := $(wildcard libc/nt/PowerProf/*.s)
|
||||
LIBC_NT_POWERPROF_A_OBJS = $(LIBC_NT_POWERPROF_A_SRCS:%.s=o/$(MODE)/%.o)
|
||||
LIBC_NT_POWERPROF_A_CHECKS = $(LIBC_NT_POWERPROF_A).pkg
|
||||
LIBC_NT_POWERPROF_A_DIRECTDEPS = LIBC_NT_KERNEL32
|
||||
LIBC_NT_POWERPROF_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(LIBC_NT_POWERPROF_A_DIRECTDEPS),$($(x))))
|
||||
$(LIBC_NT_POWERPROF_A): \
|
||||
libc/nt/PowerProf/ \
|
||||
$(LIBC_NT_POWERPROF_A).pkg \
|
||||
$(LIBC_NT_POWERPROF_A_OBJS)
|
||||
$(LIBC_NT_POWERPROF_A).pkg: \
|
||||
$(LIBC_NT_POWERPROF_A_OBJS) \
|
||||
$(foreach x,$(LIBC_NT_POWERPROF_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
$(LIBC_NT_OBJS): o/libc/nt/codegen.inc
|
||||
|
||||
o/libc/nt/codegen.inc: \
|
||||
|
|
39
libc/nt/system.h
Normal file
39
libc/nt/system.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_SYSTEM_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_SYSTEM_H_
|
||||
/* ░░░░
|
||||
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
|
||||
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
|
||||
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
|
||||
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
||||
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
|
||||
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
|
||||
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
|
||||
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
|
||||
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
|
||||
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
|
||||
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
|
||||
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
|
||||
│ cosmopolitan § new technology » system control ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
bool32 SetSuspendState(bool32 bHibernate, bool32 bForce,
|
||||
bool32 bWakeupEventsDisabled);
|
||||
|
||||
uint32_t InitiateShutdown(const char16_t *lpMachineName,
|
||||
const char16_t *lpMessage, uint32_t dwGracePeriod,
|
||||
uint32_t dwShutdownFlags, uint32_t dwReason);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_SYSTEM_H_ */
|
30
libc/stdio/fgetln.c
Normal file
30
libc/stdio/fgetln.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
char *fgetln(FILE *stream, size_t *len) {
|
||||
ssize_t rc;
|
||||
size_t n = 0;
|
||||
if ((rc = getdelim(&stream->getln, &n, '\n', stream)) > 0) {
|
||||
*len = rc;
|
||||
return stream->getln;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ typedef struct FILE {
|
|||
uint32_t size; /* 0x20 */
|
||||
uint32_t nofree; /* 0x24 */
|
||||
int pid; /* 0x28 */
|
||||
char *getln;
|
||||
} FILE;
|
||||
|
||||
extern FILE *stdin;
|
||||
|
|
|
@ -81,6 +81,11 @@ o/$(MODE)/libc/str/windowstimetotime.o: \
|
|||
OVERRIDE_CFLAGS += \
|
||||
-O3
|
||||
|
||||
o/$(MODE)/libc/str/hey-gcc.asm \
|
||||
o/$(MODE)/libc/str/hey.o: \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-fsanitize=undefined
|
||||
|
||||
LIBC_STR_LIBS = $(foreach x,$(LIBC_STR_ARTIFACTS),$($(x)))
|
||||
LIBC_STR_SRCS = $(foreach x,$(LIBC_STR_ARTIFACTS),$($(x)_SRCS))
|
||||
LIBC_STR_HDRS = $(foreach x,$(LIBC_STR_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall reboot,0x0d003703720370a9,globl
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mount,0x19a01501520a70a5,globl
|
||||
.scall sys_mount,0x19a01501520a70a5,globl
|
2
libc/sysv/calls/sys_reboot.s
Normal file
2
libc/sysv/calls/sys_reboot.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_reboot,0x0d003703720370a9,globl,hidden
|
2
libc/sysv/calls/sys_unmount.s
Normal file
2
libc/sysv/calls/sys_unmount.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_unmount,0x016016016209f0a6,globl,hidden
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall umount2,0xfffffffffffff0a6,globl
|
||||
.scall umount2,0x016016016209f0a6,globl,hidden
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall unmount,0x016016016209ffff,globl
|
|
@ -135,6 +135,7 @@ syscon sig SIGUSR2 12 31 31 31 31 12 # do whatever you want; bsd
|
|||
syscon sig SIGPIPE 13 13 13 13 13 13 # write to closed file descriptor; unix consensus & faked on nt
|
||||
syscon sig SIGALRM 14 14 14 14 14 14 # sent by setitimer(2) or timer_settime(2); unix consensus & faked on nt
|
||||
syscon sig SIGTERM 15 15 15 15 15 15 # terminate; resumable; unix consensus & faked on nt; X3.159-1988
|
||||
syscon sig SIGSTKFLT 16 0 0 0 0 0 # wut
|
||||
syscon sig SIGCHLD 17 20 20 20 20 17 # child process exited or terminated and is now a zombie (unless this is SIG_IGN or SA_NOCLDWAIT) or child process stopped due to terminal i/o or profiling/debugging (unless you used SA_NOCLDSTOP); bsd consensus
|
||||
syscon sig SIGCONT 18 19 19 19 19 18 # child process resumed from profiling/debugging; bsd consensus
|
||||
syscon sig SIGSTOP 19 17 17 17 17 19 # child process stopped due to profiling/debugging; bsd consensus
|
||||
|
@ -1232,38 +1233,78 @@ syscon sf SF_NODISKIO 0 0 1 0 0 0
|
|||
syscon sf SF_MNOWAIT 0 0 2 0 0 0
|
||||
syscon sf SF_SYNC 0 0 4 0 0 0
|
||||
|
||||
# mount flags
|
||||
# mount() flags
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
|
||||
syscon mount MS_ACTIVE 0x40000000 0 0 0 0 0
|
||||
syscon mount MS_BIND 0x1000 0 0 0 0 0
|
||||
syscon mount MS_DIRSYNC 0x80 0 0 0 0 0
|
||||
syscon mount MS_I_VERSION 0x800000 0 0 0 0 0
|
||||
syscon mount MS_KERNMOUNT 0x400000 0 0 0 0 0
|
||||
syscon mount MS_LAZYTIME 0x02000000 0 0 0 0 0
|
||||
syscon mount MS_MANDLOCK 0x40 0 0 0 0 0
|
||||
syscon mount MS_MGC_VAL 0xc0ed0000 0 0 0 0 0
|
||||
syscon mount MS_MOVE 0x2000 0 0 0 0 0
|
||||
syscon mount MS_NOATIME 0x0400 0 0 0 0 0
|
||||
syscon mount MS_NODEV 4 0 0 0 0 0
|
||||
syscon mount MS_NODIRATIME 0x0800 0 0 0 0 0
|
||||
syscon mount MS_NOEXEC 8 0 0 0 0 0
|
||||
syscon mount MS_NOSUID 2 0 0 0 0 0
|
||||
syscon mount MS_NOUSER -2147483648 0 0 0 0 0
|
||||
syscon mount MS_POSIXACL 0x010000 0 0 0 0 0
|
||||
syscon mount MS_PRIVATE 0x040000 0 0 0 0 0
|
||||
syscon mount MS_RDONLY 1 0 0 0 0 0
|
||||
syscon mount MS_REC 0x4000 0 0 0 0 0
|
||||
syscon mount MS_RELATIME 0x200000 0 0 0 0 0
|
||||
syscon mount MS_REMOUNT 0x20 0 0 0 0 0
|
||||
syscon mount MS_RMT_MASK 0x02800051 0 0 0 0 0
|
||||
syscon mount MS_SHARED 0x100000 0 0 0 0 0
|
||||
syscon mount MS_SILENT 0x8000 0 0 0 0 0
|
||||
syscon mount MS_SLAVE 0x080000 0 0 0 0 0
|
||||
syscon mount MS_STRICTATIME 0x01000000 0 0 0 0 0
|
||||
syscon mount MS_SYNCHRONOUS 0x10 0 0 0 0 0
|
||||
syscon mount MS_UNBINDABLE 0x020000 0 0 0 0 0
|
||||
syscon mount MS_MGC_MSK 0xffff0000 0 0 0 0 0
|
||||
syscon mount MS_RDONLY 0x00000001 0x00000001 0x00000001 0x00000001 0x00000001 0x00000001 # consensus; MNT_RDONLY on bsd; faked nt
|
||||
syscon mount MNT_RDONLY 0x00000001 0x00000001 0x00000001 0x00000001 0x00000001 0x00000001 # consensus; MS_RDONLY on linux; faked nt
|
||||
syscon mount MS_NOSUID 0x00000002 0x00000008 0x00000008 0x00000008 0x00000008 0x00000001 # don't honor S_ISUID bit; bsd consensus; MNT_NOSUID on bsd; faked nt
|
||||
syscon mount MNT_NOSUID 0 0x00000008 0x00000008 0x00000008 0x00000008 0x00000001 # don't honor S_ISUID bit; bsd consensus; appears incorrectly defined in linux headers; MS_NOSUID on linux; faked nt
|
||||
syscon mount MS_NODEV 0x00000004 0x00000010 0x00000010 0x00000010 0x00000010 0x00000004 # disallow special files; bsd consensus; MNT_NODEV on bsd; faked nt
|
||||
syscon mount MNT_NODEV 0x00000004 0x00000010 0x00000010 0x00000010 0x00000010 0x00000004 # disallow special files; bsd consensus; MS_NODEV on linux; faked nt
|
||||
syscon mount MS_NOEXEC 0x00000008 0x00000004 0x00000004 0x00000004 0x00000004 0x00000008 # disallow program execution; bsd consensus; MNT_NOEXEC on bsd; faked nt
|
||||
syscon mount MNT_NOEXEC 0x00000008 0x00000004 0x00000004 0x00000004 0x00000004 0x00000008 # disallow program execution; bsd consensus; MS_NOEXEC on linux; faked nt
|
||||
syscon mount MS_SYNCHRONOUS 0x00000010 0x00000002 0x00000002 0x00000002 0x00000002 0x00000010 # bsd consensus; MNT_SYNCHRONOUS on bsd; faked nt
|
||||
syscon mount MNT_SYNCHRONOUS 0x00000010 0x00000002 0x00000002 0x00000002 0x00000002 0x00000010 # bsd consensus; MS_SYNCHRONOUS on linux; faked nt
|
||||
syscon mount MS_REMOUNT 0x00000020 0x00010000 0x00010000 0x00010000 0x00010000 0x00000020 # tune existing mounting; bsd consensus; MNT_UPDATE on bsd; faked nt
|
||||
syscon mount MNT_UPDATE 0x00000020 0x00010000 0x00010000 0x00010000 0x00010000 0x00000020 # tune existing mounting; bsd consensus; MS_REMOUNT on linux; faked nt
|
||||
syscon mount MS_MANDLOCK 0x00000040 0 0 0 0 0 #
|
||||
syscon mount MS_DIRSYNC 0x00000080 0 0 0 0 0 #
|
||||
syscon mount MS_NOATIME 0x00000400 0x10000000 0x10000000 0x00008000 0x04000000 0x00000400 # do not update access times; MNT_NOATIME on bsd
|
||||
syscon mount MNT_NOATIME 0x00000400 0x10000000 0x10000000 0x00008000 0x04000000 0x00000400 # do not update access times; MS_NOATIME on linux
|
||||
syscon mount MS_NODIRATIME 0x00000800 0 0 0 0 0 #
|
||||
syscon mount MS_BIND 0x00001000 0 0 0 0 0 #
|
||||
syscon mount MS_MOVE 0x00002000 0 0 0 0 0 #
|
||||
syscon mount MS_REC 0x00004000 0 0 0 0 0 #
|
||||
syscon mount MS_SILENT 0x00008000 0 0 0 0 0 #
|
||||
syscon mount MS_POSIXACL 0x00010000 0 0 0 0 0 #
|
||||
syscon mount MS_UNBINDABLE 0x00020000 0 0 0 0 0 #
|
||||
syscon mount MS_PRIVATE 0x00040000 0 0 0 0 0 #
|
||||
syscon mount MS_SLAVE 0x00080000 0 0 0 0 0 #
|
||||
syscon mount MS_SHARED 0x00100000 0 0 0 0 0 #
|
||||
syscon mount MS_RELATIME 0x00200000 0 0 0 0x00020000 0 # MNT_RELATIME on bsd
|
||||
syscon mount MNT_RELATIME 0x00200000 0 0 0 0x00020000 0 # MS_RELATIME on linux
|
||||
syscon mount MS_KERNMOUNT 0x00400000 0 0 0 0 0 #
|
||||
syscon mount MS_I_VERSION 0x00800000 0 0 0 0 0 #
|
||||
syscon mount MS_STRICTATIME 0x01000000 0x80000000 0 0 0 0 # enable strict update of file access time; MNT_STRICTATIME on bsd
|
||||
syscon mount MNT_STRICTATIME 0x01000000 0x80000000 0 0 0 0 # enable strict update of file access time; MS_STRICTATIME on linux
|
||||
syscon mount MS_LAZYTIME 0x02000000 0 0 0 0 0 #
|
||||
syscon mount MS_ACTIVE 0x40000000 0 0 0 0 0 #
|
||||
syscon mount MS_NOUSER 0x80000000 0 0 0 0 0 #
|
||||
syscon mount MS_RMT_MASK 0x02800051 0 0 0 0 0 #
|
||||
syscon mount MS_MGC_VAL 0xc0ed0000 0 0 0 0 0 # Linux 2.3
|
||||
syscon mount MS_MGC_MSK 0xffff0000 0 0 0 0 0 # Linux 2.3
|
||||
syscon mount MNT_ASYNC 0 0x00000040 0x00000040 0x00000040 0x00000040 0 # file system written asynchronously; bsd consensus
|
||||
syscon mount MNT_RELOAD 0 0x00040000 0x00040000 0x00040000 0x00040000 0 # reload filesystem data; bsd consensus
|
||||
syscon mount MNT_SUIDDIR 0 0 0x00100000 0 0 0 # special suid dir handling
|
||||
syscon mount MNT_NOCLUSTERR 0 0 0x40000000 0 0 0 # disable cluster read
|
||||
syscon mount MNT_NOCLUSTERW 0 0 0x80000000 0 0 0 # disable cluster write
|
||||
syscon mount MNT_SNAPSHOT 0 0x40000000 0x01000000 0 0 0 # confusing
|
||||
|
||||
# unmount() flags
|
||||
# a.k.a. umount2() on linux
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
|
||||
syscon unmount MNT_FORCE 1 0x00080000 0x00080000 0x00080000 0x00080000 2 # force unmount or readonly
|
||||
syscon unmount MNT_DETACH 2 0 0 0 0 0 # just detach from the tree
|
||||
syscon unmount MNT_EXPIRE 4 0 0 0 0 0 # mark for expiry
|
||||
syscon unmount UMOUNT_NOFOLLOW 8 0 0 0 0 0 # don't follow symlinks on unmount
|
||||
syscon unmount MNT_BYFSID 0 0 0x08000000 0 0 0 # if used pass "FSID:val0:val1", where val0 and val1 are the contents of the fsid_t val[] array in decimal
|
||||
|
||||
# reboot() magnums
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
|
||||
syscon reboot RB_AUTOBOOT 0x01234567 0 0 0 0 4 # reboots; SHUTDOWN_RESTART on NT
|
||||
syscon reboot RB_POWER_OFF 0x4321fedc 0xffffffff 0x4000 0x1000 0x808 8 # SHUTDOWN_POWEROFF on NT
|
||||
syscon reboot RB_POWERDOWN 0x4321fedc 0xffffffff 0x4000 0x1000 0x808 8 # openbsd/netbsd name
|
||||
syscon reboot RB_POWEROFF 0x4321fedc 0xffffffff 0x4000 0x1000 0x808 8 # freebsd name
|
||||
syscon reboot RB_HALT_SYSTEM 0xcdef0123 8 8 8 8 16 # the processor is simply halted; SHUTDOWN_NOREBOOT on NT
|
||||
syscon reboot RB_HALT 0xcdef0123 8 8 8 8 16 # the processor is simply halted; bsd name
|
||||
syscon reboot RB_SW_SUSPEND 0xd000fce2 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xd000fce2 #
|
||||
syscon reboot RB_KEXEC 0x45584543 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff #
|
||||
syscon reboot RB_ENABLE_CAD 0x89abcdef 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff # enable control-alt-delete reboot
|
||||
syscon reboot RB_DISABLE_CAD 0 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff # make control-alt-delete just eintr
|
||||
syscon reboot RB_NOSYNC 0x20000000 4 4 4 4 0x20000000 # prevents implicit sync() beforehand; polyfilled linux; polyfilled on nt just in case
|
||||
|
||||
# send() / recv() flags
|
||||
#
|
||||
|
@ -1484,7 +1525,6 @@ syscon termios BUSY 4 0 0 0 0 0
|
|||
syscon termios CANBSIZ 255 0 0 0 0 0
|
||||
syscon termios CBAUD 0x100f 0 0 0 0 0
|
||||
syscon termios CBAUDEX 0x1000 0 0 0 0 0
|
||||
syscon termios CBRK 0 255 255 255 255 0 #
|
||||
syscon termios CEOL 0 255 255 255 255 0 #
|
||||
syscon termios EXTA 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus
|
||||
syscon termios EXTB 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus
|
||||
|
@ -1503,8 +1543,6 @@ syscon termios CSTOPB 0x40 0x0400 0x0400 0x0400 0x0400 0 # bsd c
|
|||
syscon termios HUPCL 0x0400 0x4000 0x4000 0x4000 0x4000 0 # bsd consensus
|
||||
syscon termios CSTART 17 17 17 17 17 0 # unix consensus
|
||||
syscon termios CSTOP 19 19 19 19 19 0 # unix consensus
|
||||
syscon termios CSUSP 26 26 26 26 26 0 # unix consensus
|
||||
syscon termios CWERASE 23 23 23 23 23 0 # unix consensus
|
||||
|
||||
# Pseudoteletypewriter Control
|
||||
#
|
||||
|
@ -1593,15 +1631,6 @@ syscon misc TH_PUSH 8 8 8 8 8 0 # unix consensus
|
|||
syscon misc TH_URG 32 32 32 32 32 32 # consensus
|
||||
syscon misc TH_ACK 16 16 16 16 16 16 # consensus
|
||||
|
||||
syscon misc IPC_PRIVATE 0 0 0 0 0 0 # consensus
|
||||
syscon misc IPC_RMID 0 0 0 0 0 0 # consensus
|
||||
syscon misc IPC_CREAT 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus
|
||||
syscon misc IPC_EXCL 0x0400 0x0400 0x0400 0x0400 0x0400 0 # unix consensus
|
||||
syscon misc IPC_NOWAIT 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus
|
||||
syscon misc IPC_SET 1 1 1 1 1 0 # unix consensus
|
||||
syscon misc IPC_STAT 2 2 2 2 2 0 # unix consensus
|
||||
syscon misc IPC_INFO 3 0 3 0 0 0
|
||||
|
||||
syscon shm SHM_R 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus
|
||||
syscon shm SHM_RDONLY 0x1000 0x1000 0x1000 0x1000 0x1000 0 # unix consensus
|
||||
syscon shm SHM_RND 0x2000 0x2000 0x2000 0x2000 0x2000 0 # unix consensus
|
||||
|
@ -1645,14 +1674,6 @@ syscon misc NO_ADDRESS 4 4 4 4 4 0x2afc # unix consensus
|
|||
syscon misc NO_DATA 4 4 4 4 4 0x2afc # unix consensus
|
||||
syscon misc NO_RECOVERY 3 3 3 3 3 0x2afb # unix consensus
|
||||
|
||||
syscon misc RB_DISABLE_CAD 0 0 0 0 0 0 # consensus
|
||||
syscon misc RB_AUTOBOOT 0x01234567 0 0 0 0 0
|
||||
syscon misc RB_ENABLE_CAD 0x89abcdef 0 0 0 0 0
|
||||
syscon misc RB_HALT_SYSTEM 0xcdef0123 0 0 0 0 0
|
||||
syscon misc RB_KEXEC 0x45584543 0 0 0 0 0
|
||||
syscon misc RB_POWER_OFF 0x4321fedc 0 0 0 0 0
|
||||
syscon misc RB_SW_SUSPEND 0xd000fce2 0 0 0 0 0
|
||||
|
||||
syscon misc NI_DGRAM 0x10 0x10 0x10 0x10 0x10 0x10 # consensus
|
||||
syscon misc NI_MAXSERV 0x20 0x20 0x20 0x20 0x20 0x20 # consensus
|
||||
syscon misc NI_MAXHOST 0x0401 0x0401 0x0401 0x0100 0x0100 0x0401
|
||||
|
@ -1894,10 +1915,6 @@ syscon misc LIO_READ 0 1 2 0 0 0
|
|||
syscon misc LIO_WAIT 0 2 1 0 0 0
|
||||
syscon misc LIO_NOP 2 0 0 0 0 0
|
||||
|
||||
syscon misc MNT_FORCE 1 0x080000 0 0x080000 0x080000 0
|
||||
syscon misc MNT_DETACH 2 0 0 0 0 0
|
||||
syscon misc MNT_EXPIRE 4 0 0 0 0 0
|
||||
|
||||
syscon misc UDP_ENCAP_ESPINUDP_NON_IKE 1 0 1 0 0 0
|
||||
syscon misc UDP_NO_CHECK6_RX 102 0 0 0 0 0
|
||||
syscon misc UDP_NO_CHECK6_TX 101 0 0 0 0 0
|
||||
|
@ -3122,7 +3139,6 @@ syscon misc START_STOP 27 0 0 0 0 0
|
|||
syscon misc STATUS_MASK 62 0 0 0 0 0
|
||||
syscon misc SWAP_FLAG_DISCARD 0x010000 0 0 0 0 0
|
||||
syscon misc SYNCHRONIZE_CACHE 53 0 0 0 0 0
|
||||
syscon misc UMOUNT_NOFOLLOW 8 0 0 0 0 0
|
||||
syscon misc UNIT_ATTENTION 6 0 0 0 0 0
|
||||
syscon misc UPDATE_BLOCK 61 0 0 0 0 0
|
||||
syscon misc UT_HOSTSIZE 0x0100 0x10 0 0x0100 0x0100 0
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon termios,CSUSP,26,26,26,26,26,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon termios,CWERASE,23,23,23,23,23,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_CREAT,0x0200,0x0200,0x0200,0x0200,0x0200,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_EXCL,0x0400,0x0400,0x0400,0x0400,0x0400,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_INFO,3,0,3,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_NOWAIT,0x0800,0x0800,0x0800,0x0800,0x0800,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_PRIVATE,0,0,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_RMID,0,0,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,IPC_SET,1,1,1,1,1,0
|
2
libc/sysv/consts/MNT_ASYNC.S
Normal file
2
libc/sysv/consts/MNT_ASYNC.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_ASYNC,0,0x00000040,0x00000040,0x00000040,0x00000040,0
|
2
libc/sysv/consts/MNT_BYFSID.S
Normal file
2
libc/sysv/consts/MNT_BYFSID.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon unmount,MNT_BYFSID,0,0,0x08000000,0,0,0
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,MNT_DETACH,2,0,0,0,0,0
|
||||
.syscon unmount,MNT_DETACH,2,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,MNT_EXPIRE,4,0,0,0,0,0
|
||||
.syscon unmount,MNT_EXPIRE,4,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,MNT_FORCE,1,0x080000,0,0x080000,0x080000,0
|
||||
.syscon unmount,MNT_FORCE,1,0x00080000,0x00080000,0x00080000,0x00080000,2
|
||||
|
|
2
libc/sysv/consts/MNT_NOATIME.S
Normal file
2
libc/sysv/consts/MNT_NOATIME.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_NOATIME,0x00000400,0x10000000,0x10000000,0x00008000,0x04000000,0x00000400
|
2
libc/sysv/consts/MNT_NOCLUSTERR.S
Normal file
2
libc/sysv/consts/MNT_NOCLUSTERR.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_NOCLUSTERR,0,0,0x40000000,0,0,0
|
2
libc/sysv/consts/MNT_NOCLUSTERW.S
Normal file
2
libc/sysv/consts/MNT_NOCLUSTERW.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_NOCLUSTERW,0,0,0x80000000,0,0,0
|
2
libc/sysv/consts/MNT_NODEV.S
Normal file
2
libc/sysv/consts/MNT_NODEV.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_NODEV,0x00000004,0x00000010,0x00000010,0x00000010,0x00000010,0x00000004
|
2
libc/sysv/consts/MNT_NOEXEC.S
Normal file
2
libc/sysv/consts/MNT_NOEXEC.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_NOEXEC,0x00000008,0x00000004,0x00000004,0x00000004,0x00000004,0x00000008
|
2
libc/sysv/consts/MNT_NOSUID.S
Normal file
2
libc/sysv/consts/MNT_NOSUID.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_NOSUID,0,0x00000008,0x00000008,0x00000008,0x00000008,0x00000001
|
2
libc/sysv/consts/MNT_RDONLY.S
Normal file
2
libc/sysv/consts/MNT_RDONLY.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_RDONLY,0x00000001,0x00000001,0x00000001,0x00000001,0x00000001,0x00000001
|
2
libc/sysv/consts/MNT_RELATIME.S
Normal file
2
libc/sysv/consts/MNT_RELATIME.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_RELATIME,0x00200000,0,0,0,0x00020000,0
|
2
libc/sysv/consts/MNT_RELOAD.S
Normal file
2
libc/sysv/consts/MNT_RELOAD.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_RELOAD,0,0x00040000,0x00040000,0x00040000,0x00040000,0
|
2
libc/sysv/consts/MNT_SNAPSHOT.S
Normal file
2
libc/sysv/consts/MNT_SNAPSHOT.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_SNAPSHOT,0,0x40000000,0x01000000,0,0,0
|
2
libc/sysv/consts/MNT_STRICTATIME.S
Normal file
2
libc/sysv/consts/MNT_STRICTATIME.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_STRICTATIME,0x01000000,0x80000000,0,0,0,0
|
2
libc/sysv/consts/MNT_SUIDDIR.S
Normal file
2
libc/sysv/consts/MNT_SUIDDIR.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_SUIDDIR,0,0,0x00100000,0,0,0
|
2
libc/sysv/consts/MNT_SYNCHRONOUS.S
Normal file
2
libc/sysv/consts/MNT_SYNCHRONOUS.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_SYNCHRONOUS,0x00000010,0x00000002,0x00000002,0x00000002,0x00000002,0x00000010
|
2
libc/sysv/consts/MNT_UPDATE.S
Normal file
2
libc/sysv/consts/MNT_UPDATE.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MNT_UPDATE,0x00000020,0x00010000,0x00010000,0x00010000,0x00010000,0x00000020
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_BIND,0x1000,0,0,0,0,0
|
||||
.syscon mount,MS_BIND,0x00001000,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_DIRSYNC,0x80,0,0,0,0,0
|
||||
.syscon mount,MS_DIRSYNC,0x00000080,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_I_VERSION,0x800000,0,0,0,0,0
|
||||
.syscon mount,MS_I_VERSION,0x00800000,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_KERNMOUNT,0x400000,0,0,0,0,0
|
||||
.syscon mount,MS_KERNMOUNT,0x00400000,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_MANDLOCK,0x40,0,0,0,0,0
|
||||
.syscon mount,MS_MANDLOCK,0x00000040,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_MOVE,0x2000,0,0,0,0,0
|
||||
.syscon mount,MS_MOVE,0x00002000,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_NOATIME,0x0400,0,0,0,0,0
|
||||
.syscon mount,MS_NOATIME,0x00000400,0x10000000,0x10000000,0x00008000,0x04000000,0x00000400
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_NODEV,4,0,0,0,0,0
|
||||
.syscon mount,MS_NODEV,0x00000004,0x00000010,0x00000010,0x00000010,0x00000010,0x00000004
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_NODIRATIME,0x0800,0,0,0,0,0
|
||||
.syscon mount,MS_NODIRATIME,0x00000800,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mount,MS_NOEXEC,8,0,0,0,0,0
|
||||
.syscon mount,MS_NOEXEC,0x00000008,0x00000004,0x00000004,0x00000004,0x00000004,0x00000008
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue