mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Improve system call polyfills
- Polyfill open() w/ O_CLOEXEC on RHEL5 - Remove old workaround from rmdir() on the New Technology - preadv() and pwritev() are now smarter about demodernization - preadv() and pwritev() are now available on the New Technology
This commit is contained in:
parent
816b0e1851
commit
0ad609268f
21 changed files with 260 additions and 117 deletions
|
@ -20,39 +20,56 @@ const struct AuxiliaryValue {
|
|||
const char *name;
|
||||
const char *description;
|
||||
} kAuxiliaryValues[] = {
|
||||
{"%p", &AT_EXECFD, "AT_EXECFD", "file descriptor of program"},
|
||||
{"%p", &AT_PHDR, "AT_PHDR", "address of elf program headers"},
|
||||
{"%p", &AT_PHENT, "AT_PHENT", "size of program header entry"},
|
||||
{"%p", &AT_PHNUM, "AT_PHNUM", "number of program headers"},
|
||||
{"%p", &AT_PAGESZ, "AT_PAGESZ", "system page size"},
|
||||
{"%p", &AT_BASE, "AT_BASE", "base address of the program interpreter"},
|
||||
{"%p", &AT_ENTRY, "AT_ENTRY", "entry address of executable"},
|
||||
{"%p", &AT_NOTELF, "AT_NOTELF", "set if not an elf"},
|
||||
{"%012lx", &AT_EXECFD, "AT_EXECFD", "file descriptor of program"},
|
||||
{"%012lx", &AT_PHDR, "AT_PHDR", "address of elf program headers"},
|
||||
{"%012lx", &AT_PHENT, "AT_PHENT", "size of program header entry"},
|
||||
{"%012lx", &AT_PHNUM, "AT_PHNUM", "number of program headers"},
|
||||
{"%012lx", &AT_PAGESZ, "AT_PAGESZ", "system page size"},
|
||||
{"%012lx", &AT_BASE, "AT_BASE", "base address of the program interpreter"},
|
||||
{"%012lx", &AT_ENTRY, "AT_ENTRY", "entry address of executable"},
|
||||
{"%012lx", &AT_NOTELF, "AT_NOTELF", "set if not an elf"},
|
||||
{"%-12d", &AT_UID, "AT_UID", "real user id of thread"},
|
||||
{"%-12d", &AT_EUID, "AT_EUID", "effective user id of thread"},
|
||||
{"%-12d", &AT_GID, "AT_GID", "real group id of thread"},
|
||||
{"%-12d", &AT_EGID, "AT_EGID", "effective group id of thread"},
|
||||
{"%-12d", &AT_CLKTCK, "AT_CLKTCK", "frequency of times() counts"},
|
||||
{"%p", &AT_OSRELDATE, "AT_OSRELDATE",
|
||||
{"%012lx", &AT_OSRELDATE, "AT_OSRELDATE",
|
||||
"freebsd release number, e.g. 1200086"},
|
||||
{"%p", &AT_PLATFORM, "AT_PLATFORM", "string identifying hardware platform"},
|
||||
{"%p", &AT_DCACHEBSIZE, "AT_DCACHEBSIZE", "data cache block size"},
|
||||
{"%p", &AT_ICACHEBSIZE, "AT_ICACHEBSIZE", "instruction cache block size"},
|
||||
{"%p", &AT_UCACHEBSIZE, "AT_UCACHEBSIZE", "unified cache block size"},
|
||||
{"%p", &AT_SECURE, "AT_SECURE", "for set{u,g}id binz & security blankets"},
|
||||
{"%012lx", &AT_PLATFORM, "AT_PLATFORM",
|
||||
"string identifying hardware platform"},
|
||||
{"%012lx", &AT_DCACHEBSIZE, "AT_DCACHEBSIZE", "data cache block size"},
|
||||
{"%012lx", &AT_ICACHEBSIZE, "AT_ICACHEBSIZE",
|
||||
"instruction cache block size"},
|
||||
{"%012lx", &AT_UCACHEBSIZE, "AT_UCACHEBSIZE", "unified cache block size"},
|
||||
{"%012lx", &AT_SECURE, "AT_SECURE",
|
||||
"for set{u,g}id binz & security blankets"},
|
||||
{"%-12s", &AT_BASE_PLATFORM, "AT_BASE_PLATFORM",
|
||||
"string identifying real platform"},
|
||||
{"%p", &AT_RANDOM, "AT_RANDOM", "address of sixteen random bytes"},
|
||||
{"%012lx", &AT_RANDOM, "AT_RANDOM", "address of sixteen random bytes"},
|
||||
{"%-12s", &AT_EXECFN, "AT_EXECFN", "pathname used to execute program"},
|
||||
{"%p", &AT_SYSINFO_EHDR, "AT_SYSINFO_EHDR",
|
||||
{"%012lx", &AT_SYSINFO_EHDR, "AT_SYSINFO_EHDR",
|
||||
"linux virtual dso page address"},
|
||||
{"%012lx", &AT_FLAGS, "AT_FLAGS", "unused?"},
|
||||
{"%012lx", &AT_HWCAP, "AT_HWCAP", "cpu stuff"},
|
||||
{"%012lx", &AT_HWCAP2, "AT_HWCAP2", "more cpu stuff"},
|
||||
};
|
||||
|
||||
const struct AuxiliaryValue *DescribeAuxv(unsigned long x) {
|
||||
int i;
|
||||
for (i = 0; i < ARRAYLEN(kAuxiliaryValues); ++i) {
|
||||
if (x == *kAuxiliaryValues[i].id) {
|
||||
return kAuxiliaryValues + i;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[], char **envp) {
|
||||
long key;
|
||||
unsigned i;
|
||||
unsigned long val;
|
||||
unsigned long *auxp;
|
||||
char fmt[64], **env;
|
||||
struct AuxiliaryValue *auxinfo;
|
||||
printf("\nArguments:\n");
|
||||
for (i = 0; i < __argc; ++i) {
|
||||
printf(" ☼ %s\n", argv[i]);
|
||||
|
@ -62,13 +79,13 @@ int main(int argc, char *argv[], char **envp) {
|
|||
printf(" ☼ %s\n", *env);
|
||||
}
|
||||
printf("\nAuxiliary Values:\n");
|
||||
for (i = 0; i < ARRAYLEN(kAuxiliaryValues); ++i) {
|
||||
key = *kAuxiliaryValues[i].id;
|
||||
val = getauxval(key);
|
||||
stpcpy(stpcpy(stpcpy(fmt, "%16s[%p] = "), kAuxiliaryValues[i].fmt),
|
||||
" # %s\n");
|
||||
printf(fmt, kAuxiliaryValues[i].name, key, val,
|
||||
kAuxiliaryValues[i].description);
|
||||
for (auxp = __auxv; *auxp; auxp += 2) {
|
||||
if ((auxinfo = DescribeAuxv(auxp[0]))) {
|
||||
stpcpy(stpcpy(stpcpy(fmt, "%16s[%4ld] = "), auxinfo->fmt), " # %s\n");
|
||||
printf(fmt, auxinfo->name, auxp[0], auxp[1], auxinfo->description);
|
||||
} else {
|
||||
printf("%16s[%4ld] = %012lx\n", "unknown", auxp[0], auxp[1]);
|
||||
}
|
||||
}
|
||||
printf("\nSpecial Directories:\n");
|
||||
printf(" ☼ kTmpPath = %`'s\n", kTmpPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue