mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Rewrite special file handling on Windows
This change gets GNU grep working. What caused it to not work, is it wouldn't write to an output file descriptor when its dev/ino equaled /dev/null's. So now we invent special dev/ino values for these files
This commit is contained in:
parent
aca2261cda
commit
2db2f40a98
53 changed files with 485 additions and 299 deletions
|
@ -20,23 +20,15 @@
|
|||
#include "libc/limits.h"
|
||||
#include "libc/runtime/zipos.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/zip.internal.h"
|
||||
|
||||
static uint64_t __zipos_fnv(const char *s, int len) {
|
||||
uint64_t hash = 0xcbf29ce484222325;
|
||||
for (int i = 0; i < len; i++) {
|
||||
hash *= 0x100000001b3;
|
||||
hash ^= (unsigned char)s[i];
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint64_t __zipos_inode(struct Zipos *zipos, int64_t cfile, //
|
||||
const void *name, size_t namelen) {
|
||||
unassert(cfile >= 0);
|
||||
if (cfile == ZIPOS_SYNTHETIC_DIRECTORY) {
|
||||
if (namelen && ((char *)name)[namelen - 1] == '/') --namelen;
|
||||
cfile = INT64_MIN | __zipos_fnv(name, namelen);
|
||||
cfile = INT64_MIN | __fnv(name, namelen);
|
||||
}
|
||||
return cfile;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue