mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-21 18:10:30 +00:00
Improve handling of weird reparse points
On Windows file system tools like `ls` would print errors when they find things like WSL symlinks, which can't be read by WIN32. I don't know how they got on my hard drive but this change ensures Cosmo will handle them more gracefully. If a reparse point can't be followed, then fstatat will return information about the link itself. If readlink encounters reparse points that are WIN32 symlinks, then it'll log more helpful details when using MODE=dbg (a.k.a. cosmocc -mdbg). Speaking of which, this change is also going to help you troubleshoot locks; when you build your app using the cosmocc -mdbg flag your --strace logs will now show lock acquisition
This commit is contained in:
parent
90460ceb3c
commit
79516bf08e
4 changed files with 57 additions and 48 deletions
|
@ -18,14 +18,15 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
textwindows int sys_linkat_nt(int olddirfd, const char *oldpath, int newdirfd,
|
||||
const char *newpath) {
|
||||
textwindows int sys_linkat_nt(int olddirfd, const char *oldpath, //
|
||||
int newdirfd, const char *newpath) {
|
||||
#pragma GCC push_options
|
||||
#pragma GCC diagnostic ignored "-Wframe-larger-than="
|
||||
struct {
|
||||
|
@ -36,7 +37,10 @@ textwindows int sys_linkat_nt(int olddirfd, const char *oldpath, int newdirfd,
|
|||
#pragma GCC pop_options
|
||||
if (__mkntpathat(olddirfd, oldpath, 0, M.oldpath16) != -1 &&
|
||||
__mkntpathat(newdirfd, newpath, 0, M.newpath16) != -1) {
|
||||
if (CreateHardLink(M.newpath16, M.oldpath16, NULL)) {
|
||||
bool32 ok = CreateHardLink(M.newpath16, M.oldpath16, NULL);
|
||||
NTTRACE("CreateHardLink(%#hs, %#hs, NULL) → {%hhhd, %d}", M.newpath16,
|
||||
M.oldpath16, ok, GetLastError());
|
||||
if (ok) {
|
||||
return 0;
|
||||
} else {
|
||||
return __fix_enotdir3(__winerr(), M.newpath16, M.oldpath16);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue