fix: reject opening directories as files in ext2 and fat32, add mbrtowc to libc

This commit is contained in:
2026-08-30 09:50:11 +02:00
parent fdbb233cd3
commit fd397ac41d
5 changed files with 28 additions and 1 deletions
+15
View File
@@ -25,6 +25,7 @@
#include <sys/mman.h>
#include <sys/time.h>
#include <unistd.h>
#include <wchar.h>
/* ========================================================================
Raw syscall wrappers (C versions matching kernel ABI)
@@ -3622,6 +3623,20 @@ int mbtowc(wchar_t *pwc, const char *s, size_t n) {
return 1;
}
/* Restartable form of mbtowc. The C locale carries no shift state, so ps is
ignored; binutils reaches for this once configure sees mbstate_t. */
size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) {
(void)ps;
if (s == NULL) return 0; /* query: the C locale is stateless */
if (n == 0) return (size_t)-2; /* incomplete: no bytes to examine */
if (*s == '\0') {
if (pwc != NULL) *pwc = 0;
return 0;
}
if (pwc != NULL) *pwc = (wchar_t)(unsigned char)*s;
return 1;
}
int wctomb(char *s, wchar_t wc) {
if (s == NULL) return 0;
*s = (char)wc;