mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 15:28:30 +00:00
Fix SQLite regressions caused by 3b086af91
This commit is contained in:
parent
bdc453b22d
commit
3851025b77
7 changed files with 25 additions and 12 deletions
|
@ -96,7 +96,7 @@ static textwindows bool OverlapsFileLock(struct FileLock *fl, int64_t off,
|
||||||
EndA = off + (len - 1);
|
EndA = off + (len - 1);
|
||||||
BegB = fl->off;
|
BegB = fl->off;
|
||||||
EndB = fl->off + (fl->len - 1);
|
EndB = fl->off + (fl->len - 1);
|
||||||
return MAX(BegA, BegB) < MIN(EndA, EndB);
|
return MAX(BegA, BegB) <= MIN(EndA, EndB);
|
||||||
}
|
}
|
||||||
|
|
||||||
static textwindows bool EncompassesFileLock(struct FileLock *fl, int64_t off,
|
static textwindows bool EncompassesFileLock(struct FileLock *fl, int64_t off,
|
||||||
|
|
|
@ -43,7 +43,9 @@ textwindows int sys_fstatat_nt(int dirfd, const char *path, struct stat *st,
|
||||||
dwDesiredAccess = kNtFileGenericRead;
|
dwDesiredAccess = kNtFileGenericRead;
|
||||||
TryAgain:
|
TryAgain:
|
||||||
if ((fh = CreateFile(
|
if ((fh = CreateFile(
|
||||||
path16, dwDesiredAccess, 0, 0, kNtOpenExisting,
|
path16, dwDesiredAccess,
|
||||||
|
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete, 0,
|
||||||
|
kNtOpenExisting,
|
||||||
kNtFileAttributeNormal | kNtFileFlagBackupSemantics |
|
kNtFileAttributeNormal | kNtFileFlagBackupSemantics |
|
||||||
((flags & AT_SYMLINK_NOFOLLOW) ? kNtFileFlagOpenReparsePoint
|
((flags & AT_SYMLINK_NOFOLLOW) ? kNtFileFlagOpenReparsePoint
|
||||||
: 0),
|
: 0),
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "libc/nt/enum/accessmask.h"
|
#include "libc/nt/enum/accessmask.h"
|
||||||
#include "libc/nt/enum/creationdisposition.h"
|
#include "libc/nt/enum/creationdisposition.h"
|
||||||
#include "libc/nt/enum/fileflagandattributes.h"
|
#include "libc/nt/enum/fileflagandattributes.h"
|
||||||
|
#include "libc/nt/enum/filesharemode.h"
|
||||||
#include "libc/nt/ipc.h"
|
#include "libc/nt/ipc.h"
|
||||||
#include "libc/nt/runtime.h"
|
#include "libc/nt/runtime.h"
|
||||||
#include "libc/sysv/consts/limits.h"
|
#include "libc/sysv/consts/limits.h"
|
||||||
|
@ -57,8 +58,11 @@ static textwindows int sys_pipe_nt_impl(int pipefd[2], unsigned flags) {
|
||||||
mode, 1, PIPE_BUF, PIPE_BUF, 0, &kNtIsInheritable);
|
mode, 1, PIPE_BUF, PIPE_BUF, 0, &kNtIsInheritable);
|
||||||
__fds_lock();
|
__fds_lock();
|
||||||
if (hin != -1) {
|
if (hin != -1) {
|
||||||
if ((hout = CreateFile(pipename, kNtGenericWrite, 0, &kNtIsInheritable,
|
if ((hout = CreateFile(
|
||||||
kNtOpenExisting, kNtFileFlagOverlapped, 0)) != -1) {
|
pipename, kNtGenericWrite,
|
||||||
|
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete,
|
||||||
|
&kNtIsInheritable, kNtOpenExisting, kNtFileFlagOverlapped, 0)) !=
|
||||||
|
-1) {
|
||||||
g_fds.p[reader].kind = kFdFile;
|
g_fds.p[reader].kind = kFdFile;
|
||||||
g_fds.p[reader].flags = O_RDONLY | flags;
|
g_fds.p[reader].flags = O_RDONLY | flags;
|
||||||
g_fds.p[reader].mode = 0010444;
|
g_fds.p[reader].mode = 0010444;
|
||||||
|
|
|
@ -32,8 +32,10 @@ textwindows int sys_truncate_nt(const char *path, uint64_t length) {
|
||||||
uint16_t path16[PATH_MAX];
|
uint16_t path16[PATH_MAX];
|
||||||
if (__mkntpath(path, path16) == -1) return -1;
|
if (__mkntpath(path, path16) == -1) return -1;
|
||||||
BLOCK_SIGNALS;
|
BLOCK_SIGNALS;
|
||||||
if ((fh = CreateFile(path16, kNtGenericWrite, kNtFileShareRead, NULL,
|
if ((fh = CreateFile(
|
||||||
kNtOpenExisting, kNtFileAttributeNormal, 0)) != -1) {
|
path16, kNtGenericWrite,
|
||||||
|
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete, NULL,
|
||||||
|
kNtOpenExisting, kNtFileAttributeNormal, 0)) != -1) {
|
||||||
rc = sys_ftruncate_nt(fh, length);
|
rc = sys_ftruncate_nt(fh, length);
|
||||||
CloseHandle(fh);
|
CloseHandle(fh);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1061,7 +1061,6 @@ privileged void kvprintf(const char *fmt, va_list v) {
|
||||||
#pragma GCC diagnostic ignored "-Walloca-larger-than="
|
#pragma GCC diagnostic ignored "-Walloca-larger-than="
|
||||||
long size = __get_safe_size(8000, 3000);
|
long size = __get_safe_size(8000, 3000);
|
||||||
if (size < 80) {
|
if (size < 80) {
|
||||||
asm("int3");
|
|
||||||
klog(STACK_ERROR, sizeof(STACK_ERROR) - 1);
|
klog(STACK_ERROR, sizeof(STACK_ERROR) - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "libc/nt/enum/accessmask.h"
|
#include "libc/nt/enum/accessmask.h"
|
||||||
#include "libc/nt/enum/creationdisposition.h"
|
#include "libc/nt/enum/creationdisposition.h"
|
||||||
#include "libc/nt/enum/fileflagandattributes.h"
|
#include "libc/nt/enum/fileflagandattributes.h"
|
||||||
|
#include "libc/nt/enum/filesharemode.h"
|
||||||
#include "libc/nt/ipc.h"
|
#include "libc/nt/ipc.h"
|
||||||
#include "libc/nt/runtime.h"
|
#include "libc/nt/runtime.h"
|
||||||
#include "libc/sock/internal.h"
|
#include "libc/sock/internal.h"
|
||||||
|
@ -73,7 +74,8 @@ textwindows int sys_socketpair_nt(int family, int type, int proto, int sv[2]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 = CreateFile(pipename, kNtGenericWrite | kNtGenericRead, 0,
|
h1 = CreateFile(pipename, kNtGenericWrite | kNtGenericRead,
|
||||||
|
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete,
|
||||||
&kNtIsInheritable, kNtOpenExisting, kNtFileFlagOverlapped, 0);
|
&kNtIsInheritable, kNtOpenExisting, kNtFileFlagOverlapped, 0);
|
||||||
|
|
||||||
__fds_lock();
|
__fds_lock();
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "libc/nt/enum/accessmask.h"
|
#include "libc/nt/enum/accessmask.h"
|
||||||
#include "libc/nt/enum/creationdisposition.h"
|
#include "libc/nt/enum/creationdisposition.h"
|
||||||
#include "libc/nt/enum/fileflagandattributes.h"
|
#include "libc/nt/enum/fileflagandattributes.h"
|
||||||
|
#include "libc/nt/enum/filesharemode.h"
|
||||||
#include "libc/nt/enum/filetype.h"
|
#include "libc/nt/enum/filetype.h"
|
||||||
#include "libc/nt/files.h"
|
#include "libc/nt/files.h"
|
||||||
#include "libc/nt/runtime.h"
|
#include "libc/nt/runtime.h"
|
||||||
|
@ -229,10 +230,13 @@ TryAgain:
|
||||||
|
|
||||||
// get inode such that it's consistent with stat()
|
// get inode such that it's consistent with stat()
|
||||||
// it's important that we not follow symlinks here
|
// it's important that we not follow symlinks here
|
||||||
int64_t fh = CreateFile(jp, kNtFileReadAttributes, 0, 0, kNtOpenExisting,
|
int64_t fh =
|
||||||
kNtFileAttributeNormal | kNtFileFlagBackupSemantics |
|
CreateFile(jp, kNtFileReadAttributes,
|
||||||
kNtFileFlagOpenReparsePoint,
|
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete, 0,
|
||||||
0);
|
kNtOpenExisting,
|
||||||
|
kNtFileAttributeNormal | kNtFileFlagBackupSemantics |
|
||||||
|
kNtFileFlagOpenReparsePoint,
|
||||||
|
0);
|
||||||
if (fh != kNtInvalidHandleValue) {
|
if (fh != kNtInvalidHandleValue) {
|
||||||
struct NtByHandleFileInformation wst;
|
struct NtByHandleFileInformation wst;
|
||||||
if (GetFileInformationByHandle(fh, &wst)) {
|
if (GetFileInformationByHandle(fh, &wst)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue