Changeset 2672
- Timestamp:
- Mar 19, 2006, 6:18:20 AM (19 years ago)
- Location:
- trunk/libc
- Files:
-
- 5 added
- 5 deleted
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/ChangeLog.LIBC
r2483 r2672 2 2 3 3 TODO: open replace on RAMFS fails with error 32! 4 5 2006-03-19: knut st. osmundsen <bird-gccos2-spam@anduin.net> 6 - *: 7 o Synced over changed from 0.6.1 bugfixing. 8 - libc: 9 o Try put the log file handle above the range of the standard handles 10 o #71: Fixed incorrect fmutex padding in FILE which cause _fcloseall 11 (and perhaps others) to crash. (thanks to froloff) 12 o #69: Corrected a few problems related to dos drives and slashes in basename and dirname. 13 o __read & __write logging, and added support for more size flags to the log formatter. 14 o #68: Implemented the _GETOPT_DECLARED blocker in getopt.h too. 15 o #67: Removed termcap.h, curses.h, bsd/curses.h, bsd/termcap.h, 16 gnu/curses.h and gnu/termcap.h because we never built the libs for them. 17 o #65: Added sys/_timespec.h and uncommented it's inclusion in 18 sys/stat.h. This fixes the bustage in non-BSD source mode. 19 o Fixed wrong target name written into the symlink. 20 o #62: Fixed incorrect EOF treatment in getdelim (and in getline since that's just a 21 special case of getdelim). 22 o #49: Fixed stat backend so ctime is set, and made fstat, lstat and stat convert birthtime too. 23 o #61: Fixed incorrect ENOENT errno on symlink when it should return EEXIST. 24 o #60: Fixed blunder in exec/spawn filehandle inheritance code. 25 o #58: The standard file handles are always initialized as open. 26 o #54: Fixed unitialized directory handle member fInUnixTree. 27 o #53: Fixed LIBC panic when _openstream locks the stream vector 28 in any of it's error cases. 29 o #52: Fixed two 'symlink/' problems in the path resolver. 30 o #51: Made unlink able to delete readonly files. 31 o #50: Inherit umask. 32 o #30: Committed forgotten header. 33 o #48: Quick implementation of the freopen(NULL,,) operation 34 to make cat from coreutils happy. 35 o memalign and valloc shouldn't be in __USE_GNU in malloc.h. 36 o #30: Fixed toupper / tolower EOF regression. 37 o Fixed incorrect assertion in __libc_back_fsInfoObjRelease. 38 o #41: And added special file mode mask getter and extra validations to check that 39 the mode mask we read has a valid type. This also shuts up some bad [f]chmod paths. 40 o #41: Calc st_ino and st_dev at the end of the unix attrib getter if they are not present. 41 o #40: Fixed double slash preventing root directories from being opened. 42 o #23: Fixed two incorrect EA size fields, now creating symlinks really works. 43 o #21: Restrict reading and writing of UnixEAs to HPFS, JFS, FAT and RAMFS. 44 o #38: Added DosSysCtl prototype and use it on panic to check for debugger. 45 o #33: Fixed a return path in __libc_back_signalWait which didn't reacquire the semaphore. 46 o #32: Fixed incorrect readdir_r return code when out of files. 47 o #30: Fixed two locale bugs. First, setlocale called a locale 48 dependent function for getting ctype flags. Second, all the 49 is<>() macros / functions was busted for non-ascii chars (-1..-128). 50 o #23: Corrected EA name in template from "FLAGS" to "SYMLINK". 51 o #24: Fixed chdir() crash in fts.c. 52 o #24: Fixed dirfd() problem in fts.c which prevent us from getting 53 any results in child directories. 54 o #22: Added DosFindFirst() as fallback when DosQueryPathInfo() fails 55 to query the symlink EA in the path resolver. This problem occurs 56 when doing stat() on an open file (pwd_mkdb example). 57 - libsocket: 58 o #25: Ensure correct address length returns from recvmsg and recvfrom. 4 59 5 60 2005-12-11: knut st. osmundsen <bird-gccos2-spam@anduin.net> -
trunk/libc/include/InnoTekLIBC/locale.h
r2163 r2672 316 316 /** @} */ 317 317 318 #include <ctype.h> 319 320 /** 321 * Convert the type info we get from the unicode lib to libc talk. 322 * ASSUMES that none of the locals differs from the unicode spec 323 * 324 * @returns libc ctype flags. 325 * @param pUniType The unicode type info to translate. 326 * @param wc The unicode code point. 327 */ 328 static inline unsigned ___wctype_uni(const UNICTYPE *pUniType, wchar_t wc) 329 { 330 unsigned ufType = 0; 331 /* ASSUMES CT_* << 8 == __* ! */ 332 ufType = ((unsigned)pUniType->itype << 8) 333 & (__CT_UPPER | __CT_LOWER | __CT_DIGIT | __CT_SPACE | 334 __CT_PUNCT | __CT_CNTRL | __CT_BLANK | __CT_XDIGIT | 335 __CT_ALPHA | __CT_ALNUM | __CT_GRAPH | __CT_PRINT | 336 __CT_NUMBER | __CT_SYMBOL | __CT_ASCII); 337 if (pUniType->extend & C3_IDEOGRAPH) 338 ufType |= __CT_IDEOGRAM; 339 if (ufType & (__CT_XDIGIT | __CT_DIGIT)) 340 { 341 if ( (unsigned)wc - 0x30U <= (0x39 - 0x30)) 342 ufType |= (unsigned)wc - 0x30; 343 else if ((unsigned)wc - 0x41U <= (0x46 - 0x41)) 344 ufType |= (unsigned)wc - 0x41 + 0xa; 345 else 346 { 347 unsigned uVal = UniQueryNumericValue(wc); 348 if (!(uVal & ~0xffU)) 349 ufType |= uVal; 350 } 351 } 352 ufType |= (pUniType->bidi & 0xf << 24); 353 354 /** @todo screen width. */ 355 return ufType; 356 } 357 318 358 __END_DECLS 319 359 -
trunk/libc/include/InnoTekLIBC/sharedpm.h
r2323 r2672 278 278 279 279 /** 280 * SPM fs inherit data. 280 * The SPM fs inherit data, part 1. 281 * The FS data is stored in two sections for legacy reasons. 281 282 */ 282 283 typedef struct __libc_SPMInhFS … … 291 292 /** Pointer to FS inherit data. */ 292 293 typedef __LIBC_SPMINHFS *__LIBC_PSPMINHFS; 294 295 /** 296 * SPM fs inherit data, part two. 297 */ 298 typedef struct __libc_SPMInhFS2 299 { 300 /** The size of this structure. */ 301 unsigned cb; 302 /** The umask value. */ 303 unsigned fUMask; 304 } __LIBC_SPMINHFS2; 305 /** Pointer to FS inherit data, part two. */ 306 typedef __LIBC_SPMINHFS2 *__LIBC_PSPMINHFS2; 293 307 294 308 /** … … 326 340 * All the strings are NULL terminated and referenced by offset. */ 327 341 char *pszStrings; 342 /** More file system stuff. */ 343 __LIBC_PSPMINHFS2 pFS2; 328 344 } __LIBC_SPMINHERIT; 329 345 /** Pointer to inherit data. */ -
trunk/libc/include/_ctype.h
r2058 r2672 166 166 static __inline__ unsigned __ctype(__ct_rune_t __ch, unsigned __f) 167 167 { 168 return !(__ch & ~0xffU)169 ? __libc_GLocaleCtype.aufType[__ch ] & __f168 return __ch < 256 && __ch >= -128 169 ? __libc_GLocaleCtype.aufType[__ch & 0xff] & __f 170 170 : 0; 171 171 } … … 178 178 static __inline__ int __isctype(__ct_rune_t __ch, unsigned __f) 179 179 { 180 return !(__ch & ~0xffU)181 ? !!(__libc_GLocaleCtypeDefault.aufType[__ch ] & __f)180 return __ch <= 255 && __ch >= -128 181 ? !!(__libc_GLocaleCtypeDefault.aufType[__ch & 0xff] & __f) 182 182 : 0; 183 183 } … … 185 185 static __inline__ __ct_rune_t __toupper(__ct_rune_t __ch) 186 186 { 187 return !(__ch & ~0xffU)188 ? __libc_GLocaleCtype.auchUpper[__ch ]187 return __ch <= 255 && __ch >= -128 && __ch != -1 /*EOF*/ 188 ? __libc_GLocaleCtype.auchUpper[__ch & 0xff] 189 189 : (__ch); 190 190 } … … 192 192 static __inline__ __ct_rune_t __tolower(__ct_rune_t __ch) 193 193 { 194 return !(__ch & ~0xffU)195 ? __libc_GLocaleCtype.auchLower[__ch ]194 return __ch <= 255 && __ch >= -128 && __ch != -1 /*EOF*/ 195 ? __libc_GLocaleCtype.auchLower[__ch & 0xff] 196 196 : __ch; 197 197 } -
trunk/libc/include/emx/io.h
r2439 r2672 320 320 /** Does the file system automatically zero the new space when a file is extended? */ 321 321 unsigned fZeroNewBytes : 1; 322 /** Does the file system provide sufficient EA support for UNIX attributes? */ 323 unsigned fUnixEAs : 1; 322 324 /** Device number of the device the filesystem resides on. 323 325 * On OS/2 the device number is derived from the driveletter. */ -
trunk/libc/include/getopt.h
r2144 r2672 21 21 /** @file 22 22 * GLIBC 2.3.4 23 * @changed bird: Added _GETOPT_DECLARED check and def. 23 24 */ 24 25 … … 55 56 #endif 56 57 58 #ifndef _GETOPT_DECLARED /* bird: see next usage */ 59 57 60 /* For communication from `getopt' to the caller. 58 61 When `getopt' finds an option that takes an argument, … … 85 88 86 89 extern int optopt; 90 91 #endif /* bird */ 87 92 88 93 #ifndef __need_getopt … … 150 155 `getopt'. */ 151 156 157 #ifndef _GETOPT_DECLARED /* bird: Also defined in unistd.h, this is the blocker. */ 158 #define _GETOPT_DECLARED /* bird */ 152 159 #ifdef __GNU_LIBRARY__ 153 160 /* Many other libraries have conflicting prototypes for getopt, with … … 159 166 extern int getopt (); 160 167 #endif /* __GNU_LIBRARY__ */ 168 #endif /* bird */ 169 161 170 162 171 #ifndef __need_getopt -
trunk/libc/include/malloc.h
r1560 r2672 63 63 #endif 64 64 65 #ifdef __USE_GNU66 65 void *valloc(size_t); 67 66 void *memalign(size_t, size_t); 68 #endif69 67 70 68 #if defined (__cplusplus) -
trunk/libc/include/os2emx.h
r2273 r2672 13467 13467 13468 13468 13469 #ifdef INCL_DOSUNDOCUEMENTED 13470 13471 /** Check if the current process is being debugged. 13472 * No parameter. Returns TRUE or FALSE. */ 13473 #define DOSSYSCTL_AM_I_DEBUGGED 2 13474 13475 /** 13476 * System Control Function. 13477 * 13478 * @returns Depends on function. 13479 * @param ulFunction Which function to execute. 13480 * Any of the DOSSYSCTL_* #defines. 13481 */ 13482 APIRET APIENTRY DosSysCtl(ULONG ulFunction, PVOID pvParameter); 13483 13484 #endif /* INCL_DOSUNDOCUEMENTED */ 13485 13486 13469 13487 #ifdef INCL_EXAPIS 13470 13488 -
trunk/libc/include/stdio.h
r2223 r2672 204 204 _fmutex __fsem; 205 205 #endif 206 char __rsem_ersatz[1 2];206 char __rsem_ersatz[16]; 207 207 } __u; 208 208 /** Pointer to the stream vector which this FILE belongs to. -
trunk/libc/include/unistd.h
r2323 r2672 4 4 * 5 5 * @changed Commented out stuff which isn't implemented, TCPIP stuff at bottom. 6 * @changed setkey returns void not int in the standard and our implementation (glibc). 6 7 * @todo Several man-years.. ;) Serious, complete the FreeBSD 5.3 merge and 7 8 * implement all the functions. Currently there is a bunch of POSIX … … 540 541 /** @todo int sethostname(const char *, int); */ 541 542 #ifndef _SETKEY_DECLARED 542 int setkey(const char *); 543 /*int setkey(const char *); bird: SUS say void return and so does glibc! */ 544 void setkey(const char *); 543 545 #define _SETKEY_DECLARED 544 546 #endif -
trunk/libc/src/fbsdlibc/gen/fts.c
r2323 r2672 40 40 #endif 41 41 #ifndef __EMX__ 42 # define HAVE_FCHDIR 43 # define HAVE_DIRFD 42 44 # define IS_SLASH(ch) ( (ch) == '/' ) 43 45 #else 44 46 # define NEED_STRRSLASH 47 # define HAVE_FCHDIR 48 # undef HAVE_DIRFD 45 49 # define IS_SLASH(ch) ( (ch) == '/' || (ch) == '\\' ) 46 50 #endif … … 224 228 * descriptor we run anyway, just more slowly. 225 229 */ 230 #ifdef HAVE_FCHDIR 226 231 if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) 227 SET(FTS_NOCHDIR); 232 #else 233 if (!ISSET(FTS_NOCHDIR) && (sp->fts_rdir = getcwd(NULL, 0)) != NULL) 234 #endif 235 SET(FTS_NOCHDIR); 228 236 229 237 return (sp); … … 314 322 /* Return to original directory, save errno if necessary. */ 315 323 if (!ISSET(FTS_NOCHDIR)) { 324 #ifdef HAVE_FCHDIR 316 325 saved_errno = fchdir(sp->fts_rfd) ? errno : 0; 317 326 (void)_close(sp->fts_rfd); 327 #else 328 saved_errno = chdir(sp->fts_rdir) ? errno : 0; 329 free(sp->fts_rdir); sp->fts_rdir = NULL; 330 #endif 318 331 319 332 /* Set errno and return. */ … … 375 388 p->fts_info = fts_stat(sp, p, 1); 376 389 if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { 390 #ifdef HAVE_FCHDIR 377 391 if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { 378 392 p->fts_errno = errno; … … 380 394 } else 381 395 p->fts_flags |= FTS_SYMFOLLOW; 396 #endif 382 397 } 383 398 return (p); … … 389 404 if (instr == FTS_SKIP || 390 405 (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { 406 #ifdef HAVE_FCHDIR 391 407 if (p->fts_flags & FTS_SYMFOLLOW) 392 408 (void)_close(p->fts_symfd); 409 #endif 393 410 if (sp->fts_child) { 394 411 fts_lfree(sp->fts_child); … … 447 464 */ 448 465 if (p->fts_level == FTS_ROOTLEVEL) { 466 #ifdef HAVE_FCHDIR 449 467 if (FCHDIR(sp, sp->fts_rfd)) { 468 #else 469 if (FCHDIR(sp, sp->fts_rdir)) { 470 #endif 450 471 SET(FTS_STOP); 451 472 return (NULL); … … 465 486 p->fts_info = fts_stat(sp, p, 1); 466 487 if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { 488 #ifdef HAVE_FCHDIR 467 489 if ((p->fts_symfd = 468 490 _open(".", O_RDONLY, 0)) < 0) { … … 471 493 } else 472 494 p->fts_flags |= FTS_SYMFOLLOW; 495 #endif 473 496 } 474 497 p->fts_instr = FTS_NOINSTR; … … 504 527 */ 505 528 if (p->fts_level == FTS_ROOTLEVEL) { 529 #ifdef HAVE_FCHDIR 506 530 if (FCHDIR(sp, sp->fts_rfd)) { 531 #else 532 if (FCHDIR(sp, sp->fts_rdir)) { 533 #endif 507 534 SET(FTS_STOP); 508 535 return (NULL); 509 536 } 537 #ifdef HAVE_FCHDIR 510 538 } else if (p->fts_flags & FTS_SYMFOLLOW) { 511 539 if (FCHDIR(sp, p->fts_symfd)) { … … 517 545 } 518 546 (void)_close(p->fts_symfd); 547 #else 548 (void)saved_errno; 549 #endif 519 550 } else if (!(p->fts_flags & FTS_DONTCHDIR) && 520 551 fts_safe_changedir(sp, p->fts_parent, -1, "..")) { … … 554 585 { 555 586 FTSENT *p; 587 #ifdef HAVE_FCHDIR 556 588 int fd; 557 589 #else 590 char *pszRoot; 591 int rc; 592 #endif 558 593 if (instr != 0 && instr != FTS_NAMEONLY) { 559 594 errno = EINVAL; … … 607 642 return (sp->fts_child = fts_build(sp, instr)); 608 643 644 #ifdef HAVE_FCHDIR 609 645 if ((fd = _open(".", O_RDONLY, 0)) < 0) 646 #else 647 if ((pszRoot = getcwd(NULL, 0)) == NULL) 648 #endif 610 649 return (NULL); 611 650 sp->fts_child = fts_build(sp, instr); 651 #ifdef HAVE_FCHDIR 612 652 if (fchdir(fd)) 613 653 return (NULL); 614 654 (void)_close(fd); 655 #else 656 rc = chdir(pszRoot); 657 free(pszRoot); 658 if (rc) 659 return NULL; 660 #endif 615 661 return (sp->fts_child); 616 662 } … … 740 786 cderrno = 0; 741 787 if (nlinks || type == BREAD) { 788 #ifdef HAVE_DIRFD 742 789 if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { 790 #else 791 if (fts_safe_changedir(sp, cur, -1, cur->fts_accpath)) { 792 #endif 743 793 if (nlinks && type == BREAD) 744 794 cur->fts_errno = errno; … … 905 955 if (descend && (type == BCHILD || !nitems) && 906 956 (cur->fts_level == FTS_ROOTLEVEL ? 957 #ifdef HAVE_FCHDIR 907 958 FCHDIR(sp, sp->fts_rfd) : 959 #else 960 FCHDIR(sp, sp->fts_rdir) : 961 #endif 908 962 fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { 909 963 cur->fts_info = FTS_ERR; … … 1207 1261 if (ISSET(FTS_NOCHDIR)) 1208 1262 return (0); 1263 #ifdef HAVE_FCHDIR 1209 1264 if (fd < 0 && (newfd = _open(path, O_RDONLY, 0)) < 0) 1210 1265 return (-1); 1211 1266 if (_fstat(newfd, &sb)) { 1267 #else 1268 (void)newfd; 1269 if (_stat(path, &sb)) { 1270 #endif 1212 1271 ret = -1; 1213 1272 goto bail; … … 1218 1277 goto bail; 1219 1278 } 1279 #ifdef HAVE_FCHDIR 1220 1280 ret = fchdir(newfd); 1281 #else 1282 ret = chdir(path); 1283 #endif 1221 1284 bail: 1285 #ifdef HAVE_FCHDIR 1222 1286 oerrno = errno; 1223 1287 if (fd < 0) 1224 1288 (void)_close(newfd); 1225 1289 errno = oerrno; 1290 #else 1291 (void)oerrno; 1292 #endif 1226 1293 return (ret); 1227 1294 } -
trunk/libc/src/libc/app/stdio.c
r2120 r2672 92 92 { 93 93 PLIBCFH pFH = __libc_FH(i); 94 if (pFH) 94 if (!pFH) 95 LIBCLOG_MSG("No open file for %d\n", i); 96 97 /* 98 * Common init - recall everything is ZERO. 99 */ 100 gPreStreamVec.cFree--; 101 gaPreFiles[i].__uVersion = _FILE_STDIO_VERSION; 102 gaPreFiles[i]._flags |= _IOOPEN | _IONOCLOSEALL; 103 gaPreFiles[i]._handle = i; 104 gaPreFiles[i]._flush = _flushstream; 105 if (_fmutex_create2(&gaPreFiles[i].__u.__fsem, 0, "LIBC stream") != 0) 95 106 { 96 /* 97 * Common init - recall everything is ZERO. 98 */ 99 gPreStreamVec.cFree--; 100 gaPreFiles[i].__uVersion = _FILE_STDIO_VERSION; 101 gaPreFiles[i]._flags |= _IOOPEN | _IONOCLOSEALL; 102 gaPreFiles[i]._handle = i; 103 gaPreFiles[i]._flush = _flushstream; 104 if (_fmutex_create2(&gaPreFiles[i].__u.__fsem, 0, "LIBC stream") != 0) 105 { 106 LIBC_ASSERTM_FAILED("_setmore failed for i=%d\n", i); 107 abort(); 108 } 107 LIBC_ASSERTM_FAILED("_setmore failed for i=%d\n", i); 108 abort(); 109 } 109 110 110 111 112 113 114 115 116 117 118 119 120 121 122 111 /* 112 * Specific init. 113 */ 114 switch (i) 115 { 116 case 0: 117 /* stdin is always buffered. */ 118 gaPreFiles[0]._flags |= _IOREAD | _IOFBF | _IOBUFUSER; 119 gaPreFiles[0]._ptr = gachStdIn; 120 gaPreFiles[0]._buffer = gachStdIn; 121 gaPreFiles[0]._buf_size = BUFSIZ; 122 LIBCLOG_MSG("__stdinp=%p\n", (void *)__stdinp); 123 break; 123 124 124 125 126 127 | ((pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? _IONBF : _IOFBF);128 129 130 125 case 1: 126 /* stdout is buffered unless it's connected to a device. */ 127 gaPreFiles[1]._flags |= _IOWRT | _IOBUFNONE 128 | (pFH && (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? _IONBF : _IOFBF); 129 LIBCLOG_MSG("__stdoutp=%p flags=%#x (%s)\n", (void *)__stdoutp, gaPreFiles[1]._flags, 130 pFH && (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? "dev" : "none-dev"); 131 break; 131 132 132 case 2: 133 /* stderr is always unbuffered. */ 134 gaPreFiles[2]._flags |= _IOWRT | _IOBUFNONE | _IONBF; 135 LIBCLOG_MSG("__stderrp=%p\n", (void *)__stderrp); 136 break; 137 } 133 case 2: 134 /* stderr is always unbuffered. */ 135 gaPreFiles[2]._flags |= _IOWRT | _IOBUFNONE | _IONBF; 136 LIBCLOG_MSG("__stderrp=%p\n", (void *)__stderrp); 137 break; 138 138 } 139 else140 LIBCLOG_MSG("No open file for %d\n", i);141 139 } /* for standard handles. */ 142 140 LIBCLOG_RETURN_VOID(); -
trunk/libc/src/libc/io/_fopen.c
r1661 r2672 35 35 default: 36 36 errno = EINVAL; 37 STREAMV_LOCK; 37 if (lock) 38 STREAMV_LOCK; 38 39 _closestream (dst); 39 STREAMV_UNLOCK; 40 if (lock) 41 STREAMV_UNLOCK; 40 42 return NULL; 41 43 } … … 83 85 if (_fmutex_create2 (&dst->__u.__fsem, 0, "LIBC stream fopen") != 0) 84 86 { 85 STREAMV_LOCK; 87 if (lock) 88 STREAMV_LOCK; 86 89 _closestream (dst); 87 STREAMV_UNLOCK; 90 if (lock) 91 STREAMV_UNLOCK; 88 92 return NULL; 89 93 } … … 91 95 if (dst->_handle < 0) 92 96 { 93 STREAMV_LOCK; 97 if (lock) 98 STREAMV_LOCK; 94 99 _closestream (dst); 95 STREAMV_UNLOCK; 100 if (lock) 101 STREAMV_UNLOCK; 96 102 return NULL; 97 103 } -
trunk/libc/src/libc/io/freopen.c
r1604 r2672 6 6 #include <string.h> 7 7 #include <share.h> 8 #include <errno.h> 9 #include <sys/fcntl.h> 8 10 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 11 #include <sys/fmutex.h> 10 12 #include <emx/io.h> 11 13 14 #define FALSE 0 15 #define TRUE 1 16 17 /** 18 * Interprets the stream mode string. 19 * 20 * @returns the basic stream flags and *pmode set to the open mode. 21 * @returns -1 and *pomode unset on failure. 22 * @param mode The mode string. 23 * @param pomode Where to store the open mode. 24 */ 25 static int _interpret_stream_mode(const char *mode, unsigned *pomode) 26 { 27 int flags = 0; 28 int omode = 0; 29 char bt, ok; 30 31 switch (*mode) 32 { 33 case 'r': 34 flags = _IOREAD; 35 omode = O_RDONLY; 36 break; 37 case 'w': 38 flags = _IOWRT; 39 omode = O_WRONLY|O_CREAT|O_TRUNC; 40 break; 41 case 'a': 42 flags = _IOWRT; 43 omode = O_WRONLY|O_CREAT|O_APPEND; 44 break; 45 default: 46 errno = EINVAL; 47 return -1; 48 } 49 50 ok = TRUE; 51 bt = FALSE; 52 while (ok && *++mode) 53 { 54 switch (*mode) 55 { 56 case 't': 57 if (bt) 58 ok = FALSE; 59 else 60 { 61 bt = TRUE; 62 omode |= O_TEXT; 63 } 64 break; 65 case 'b': 66 if (bt) 67 ok = FALSE; 68 else 69 { 70 bt = TRUE; 71 omode |= O_BINARY; 72 } 73 break; 74 case '+': 75 if (flags & _IORW) 76 ok = FALSE; 77 else 78 { 79 omode &= ~(O_RDONLY|O_WRONLY); 80 omode |= O_RDWR; 81 flags &= ~(_IOREAD|_IOWRT); 82 flags |= _IORW; 83 } 84 break; 85 default: 86 ok = FALSE; 87 break; 88 } 89 } 90 *pomode = omode; 91 return flags; 92 } 93 12 94 FILE *_STD(freopen) (const char *fname, const char *mode, FILE *stream) 13 95 { 14 FILE *result ;96 FILE *result = NULL; 15 97 16 98 STREAMV_LOCK; 17 if (stream->_flags & _IOOPEN) 18 { /* duplication of fclose(), but no _closestream lock. */ 19 int result; 20 char buf[L_tmpnam]; 99 if (!fname) 100 { 101 /* 102 * Change the stream mode. 103 */ 104 if (stream->_flags & _IOOPEN) 105 { 106 int omode; 107 int flags = _interpret_stream_mode(mode, &omode); 108 if (flags != -1) 109 { 110 if ( ((flags & _IORW) && !(stream->_flags & _IORW)) 111 || ((flags & _IOREAD) && !(stream->_flags & (_IORW | _IOREAD))) 112 || ((flags & _IOWRT) && !(stream->_flags & (_IORW | _IOWRT))) 113 ) 114 errno = EINVAL; 115 else 116 { 117 if (!(stream->_flags & _IOSPECIAL)) 118 { 119 /* flush it and set the new mode */ 120 fflush(stream); 121 if (!fcntl(fileno(stream), F_SETFL, omode)) 122 stream = stream; 123 } 124 else 125 errno = EBADF; /* doesn't support the mode. */ 126 } 127 } 128 } 129 else 130 errno = EBADF; 131 } 132 else 133 { 134 if (stream->_flags & _IOOPEN) 135 { /* duplication of fclose(), but no _closestream lock. */ 136 int result; 137 char buf[L_tmpnam]; 21 138 22 result = EOF; 23 if ((stream->_flags & _IOOPEN) && !(stream->_flags & _IOSPECIAL)) 24 { 25 result = 0; 26 result = fflush (stream); 27 if (close (stream->_handle) < 0) 28 result = EOF; 29 if (result == 0 && (stream->_flags & _IOTMP)) 139 result = EOF; 140 if ((stream->_flags & _IOOPEN) && !(stream->_flags & _IOSPECIAL)) 30 141 { 31 _itoa (stream->_tmpidx, buf, 10);32 strcat (buf, ".tmp");33 if ( remove (buf) !=0)142 result = 0; 143 result = fflush (stream); 144 if (close (stream->_handle) < 0) 34 145 result = EOF; 146 if (result == 0 && (stream->_flags & _IOTMP)) 147 { 148 _itoa (stream->_tmpidx, buf, 10); 149 strcat (buf, ".tmp"); 150 if (remove (buf) != 0) 151 result = EOF; 152 } 153 if ((stream->_flags & _IOBUFMASK) == _IOBUFLIB) 154 free (stream->_buffer); 35 155 } 36 if ((stream->_flags & _IOBUFMASK) == _IOBUFLIB) 37 free (stream->_buffer); 156 _closestream (stream); 38 157 } 39 _closestream (stream);158 result = _openstream (stream, fname, mode, SH_DENYNO, 0); 40 159 } 41 result = _openstream (stream, fname, mode, SH_DENYNO, 0);42 160 STREAMV_UNLOCK; 43 161 return result; -
trunk/libc/src/libc/io/fstat.c
r1519 r2672 21 21 _loc2gmt (&buffer->st_mtime, -1); 22 22 _loc2gmt (&buffer->st_ctime, -1); 23 _loc2gmt (&buffer->st_birthtime, -1); 23 24 } 24 25 else -
trunk/libc/src/libc/io/getdelim.c
r2254 r2672 46 46 * 47 47 * @returns number of bytes read. 48 * @returns -1 on failure , including EOF.48 * @returns -1 on failure - this includes EOF when nothing was retrieved. 49 49 * @param ppszString Where to buffer pointer is stored. *ppszString can of course be NULL. 50 50 * @param pcchString Size of the buffer pointed to by *ppszString. … … 81 81 */ 82 82 STREAM_LOCK(pStream); 83 ssize_t rc = -1;83 ssize_t rc = 0; 84 84 char *psz = *ppszString; 85 85 char *pszEnd = psz + *pcchString - 1; … … 90 90 int ch = _getc_inline(pStream); 91 91 if (ch == EOF) 92 { 93 if (psz == *ppszString) 94 rc = -1; 92 95 break; 96 } 93 97 if (psz == pszEnd) 94 98 { … … 100 104 char *pszNew = (char *)realloc(*ppszString, cch); 101 105 if (!pszNew) 106 { 107 rc = -1; 102 108 break; 109 } 103 110 104 111 psz = pszNew + (psz - *ppszString); … … 109 116 *psz++ = (char)ch; 110 117 if (ch == chDelim) 111 {112 rc = psz - *ppszString;113 118 break; 114 }115 119 } 116 120 STREAM_UNLOCK(pStream); 121 122 if (!rc) 123 rc = psz - *ppszString; 117 124 118 125 *psz = '\0'; -
trunk/libc/src/libc/io/lstat.c
r2254 r2672 50 50 _loc2gmt(&buffer->st_mtime, -1); 51 51 _loc2gmt(&buffer->st_ctime, -1); 52 _loc2gmt(&buffer->st_birthtime, -1); 52 53 LIBCLOG_RETURN_INT(0); 53 54 } -
trunk/libc/src/libc/io/stat.c
r2254 r2672 21 21 _loc2gmt(&buffer->st_mtime, -1); 22 22 _loc2gmt(&buffer->st_ctime, -1); 23 _loc2gmt(&buffer->st_birthtime, -1); 23 24 LIBCLOG_RETURN_INT(rc); 24 25 } -
trunk/libc/src/libc/locale/locale_ctype.c
r2058 r2672 220 220 unsigned __ctype(__ct_rune_t __ch, unsigned __f) 221 221 { 222 return !((__ch) & ~0xffU)223 ? __libc_GLocaleCtype.aufType[ (__ch)/* & 0xff*/] & (__f)222 return __ch <= 255 && __ch >= -128 223 ? __libc_GLocaleCtype.aufType[__ch & 0xff] & __f 224 224 : 0; 225 225 } … … 227 227 int __istype(__ct_rune_t __ch, unsigned __f) 228 228 { 229 return !!__ctype( (__ch), (__f));229 return !!__ctype(__ch, __f); 230 230 } 231 231 232 232 __ct_rune_t __toupper(__ct_rune_t __ch) 233 233 { 234 return !((__ch) & ~0xffU)235 ? __libc_GLocaleCtype.auchUpper[ (__ch)/* & 0xff*/]236 : (__ch);234 return __ch <= 255 && __ch >= -128 && __ch != -1 /* EOF */ 235 ? __libc_GLocaleCtype.auchUpper[__ch & 0xff] 236 : __ch; 237 237 } 238 238 239 239 __ct_rune_t __tolower(__ct_rune_t __ch) 240 240 { 241 return !((__ch) & ~0xffU)242 ? __libc_GLocaleCtype.auchLower[ (__ch)/* & 0xff*/]243 : (__ch);241 return __ch <= 255 && __ch >= 128 && __ch != -1 /* EOF */ 242 ? __libc_GLocaleCtype.auchLower[__ch & 0xff] 243 : __ch; 244 244 } 245 245 … … 397 397 } 398 398 399 400 399 /** 401 400 * Get unicode type. … … 404 403 unsigned ___wctype(__wchar_t wc) 405 404 { 406 unsigned ufType = 0;407 405 if ( __libc_GLocaleWCtype.uMask != ~0x7f 408 406 || wc <= 127) 409 407 { 410 UNICTYPE 408 UNICTYPE *pUniType = UniQueryCharType(wc); 411 409 if (pUniType) 412 { 413 /* ASSUMES CT_* << 8 == __* ! */ 414 ufType = ((unsigned)pUniType->itype << 8) 415 & (__CT_UPPER | __CT_LOWER | __CT_DIGIT | __CT_SPACE | 416 __CT_PUNCT | __CT_CNTRL | __CT_BLANK | __CT_XDIGIT | 417 __CT_ALPHA | __CT_ALNUM | __CT_GRAPH | __CT_PRINT | 418 __CT_NUMBER | __CT_SYMBOL | __CT_ASCII); 419 if (pUniType->extend & C3_IDEOGRAPH) 420 ufType |= __CT_IDEOGRAM; 421 if (ufType & (__CT_XDIGIT | __CT_DIGIT)) 422 { 423 if ( (unsigned)wc - 0x30U <= (0x39 - 0x30)) 424 ufType |= (unsigned)wc - 0x30; 425 else if ((unsigned)wc - 0x41U <= (0x46 - 0x41)) 426 ufType |= (unsigned)wc - 0x41 + 0xa; 427 else 428 { 429 unsigned uVal = UniQueryNumericValue(wc); 430 if (!(uVal & ~0xffU)) 431 ufType |= uVal; 432 } 433 } 434 ufType |= (pUniType->bidi & 0xf << 24); 435 436 /** @todo screen width. */ 437 } 438 } 439 return ufType; 410 return ___wctype_uni(pUniType, wc); 411 } 412 return 0; 440 413 } 441 414 -
trunk/libc/src/libc/locale/setlocale.c
r2262 r2672 599 599 UniChar uc = 0xffff; 600 600 601 /* isxxx() do not support MBCS characters at all. */601 /* isxxx() does not support MBCS characters at all. */ 602 602 if (!pCtype->mbcs || !IS_MBCS_PREFIX(pCtype, i)) 603 603 { … … 609 609 if (pUniType) 610 610 { 611 ufType = ___wctype (uc);611 ufType = ___wctype_uni(pUniType, uc); 612 612 if (ufType & __CT_LOWER) 613 613 uchUpper = Transform(lobj, uobj, UniTransUpper, uc, i); -
trunk/libc/src/libc/misc/basename.c
r1506 r2672 71 71 } 72 72 73 /* d:/ */ 74 if (*endp == ':' && endp == path + 1) { 75 (void)strncpy(bname, path, 3); 76 bname[3] = '\0'; 77 return(bname); 78 } 79 73 80 /* Find the start of the base */ 74 81 startp = endp; 75 while (startp > path && *(startp - 1) != '/' && *(startp - 1) != '\\' && *(startp - 1) != ':') 82 while ( startp > path 83 && *(startp - 1) != '/' 84 && *(startp - 1) != '\\' 85 && (*(startp - 1) != ':' || startp != path + 2)) 76 86 startp--; 77 87 -
trunk/libc/src/libc/misc/dirent.c
r2254 r2672 169 169 //errno = ENOENT; 170 170 *ppdent = NULL; 171 LIBCLOG_RETURN_P( -1); /** @todo readdir_r return code is wrong */171 LIBCLOG_RETURN_P(0); 172 172 } 173 173 -
trunk/libc/src/libc/misc/dirname.c
r1506 r2672 67 67 68 68 /* Find the start of the dir */ 69 while (endp > path && *endp != '/' && *endp != ' /' && *endp != ':')69 while (endp > path && *endp != '/' && *endp != '\\' && (*endp != ':' || endp != path + 1)) 70 70 endp--; 71 71 … … 74 74 (void)strcpy(bname, *endp == '/' || *endp == '\\' ? "/" : "."); 75 75 return(bname); 76 } else { 76 } 77 78 if (*endp == ':' && endp == path + 1) { 79 if (endp[1] == '/' || endp[1] == '\\') 80 endp++; 81 } else if (endp != path + 2 || path[1] != ':') { 77 82 do { 78 83 endp--; -
trunk/libc/src/libc/sys/__read.c
r2437 r2672 15 15 #include <emx/syscalls.h> 16 16 #include "syscalls.h" 17 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 18 #include <InnoTekLIBC/logstrict.h> 17 19 18 20 int __read (int handle, void *buf, size_t cbToRead) 19 21 { 22 LIBCLOG_ENTER("fd=%d buf=%p cbToRead=%zu\n", handle, buf, cbToRead); 20 23 int rc; 21 24 PLIBCFH pFH; … … 29 32 { 30 33 errno = EBADF; 31 return -1;34 LIBCLOG_ERROR_RETURN_INT(-1); 32 35 } 33 36 … … 50 53 pvBuf_safe = _lmalloc(cbToRead); 51 54 if (!pvBuf_safe) 52 return ERROR_NOT_ENOUGH_MEMORY; 55 { 56 errno = ENOMEM; 57 LIBCLOG_ERROR_RETURN_INT(-1); 58 } 53 59 memcpy(pvBuf_safe, buf, cbToRead); 54 60 } … … 89 95 rc = -EBADF; 90 96 errno = -rc; 91 return -1;97 LIBCLOG_ERROR_RETURN_INT(-1); 92 98 } 93 94 return cbRead; 99 LIBCLOG_RETURN_INT(cbRead); 95 100 } -
trunk/libc/src/libc/sys/__spawnve.c
r2323 r2672 58 58 size_t cbFS; 59 59 __LIBC_PSPMINHFS pFS; 60 if (!__libc_back_fsInheritPack(&pFS, &cbFS)) 60 size_t cbFS2; 61 __LIBC_PSPMINHFS2 pFS2; 62 if (!__libc_back_fsInheritPack(&pFS, &cbFS, &pFS2, &cbFS2)) 61 63 { 62 64 /* … … 71 73 */ 72 74 #define ALIGNIT(cb) (((cb) + 3) & ~3) 73 size_t cb = sizeof(__LIBC_SPMINHERIT) + ALIGNIT(cbFH) + ALIGNIT(cbFS) + ALIGNIT(cb Sig) + ALIGNIT(cbStrings);75 size_t cb = sizeof(__LIBC_SPMINHERIT) + ALIGNIT(cbFH) + ALIGNIT(cbFS) + ALIGNIT(cbFS2) + ALIGNIT(cbSig) + ALIGNIT(cbStrings); 74 76 pRet = __libc_spmAlloc(cb); 75 77 if (pRet) … … 94 96 else 95 97 pRet->pFS = NULL; 98 99 /* fs2 */ 100 if (pFS2) 101 { 102 pRet->pFS2 = (__LIBC_PSPMINHFS2)p; 103 p += ALIGNIT(cbFS2); 104 memcpy(pRet->pFS2, pFS2, cbFS2); 105 free(pFS2); 106 } 107 else 108 pRet->pFS2 = NULL; 96 109 97 110 /* sig */ … … 123 136 } 124 137 free(pFS); 138 free(pFS2); 125 139 } 126 140 -
trunk/libc/src/libc/sys/__write.c
r2437 r2672 15 15 #include <emx/syscalls.h> 16 16 #include "syscalls.h" 17 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 18 #include <InnoTekLIBC/logstrict.h> 17 19 18 20 int __write(int handle, const void *buf, size_t cbToWrite) 19 21 { 22 LIBCLOG_ENTER("fd=%d buf=%p cbToWrite=%zu\n", handle, buf, cbToWrite); 20 23 PLIBCFH pFH; 21 24 int rc; … … 32 35 { 33 36 errno = EBADF; 34 return -1;37 LIBCLOG_ERROR_RETURN_INT(-1); 35 38 } 36 39 … … 52 55 pvBuf_safe = _lmalloc(cbToWrite); 53 56 if (!pvBuf_safe) 54 return ERROR_NOT_ENOUGH_MEMORY; 57 { 58 errno = ENOMEM; 59 LIBCLOG_ERROR_RETURN_INT(-1); 60 } 55 61 memcpy(pvBuf_safe, buf, cbToWrite); 56 62 buf = pvBuf_safe; … … 98 104 rc = -EBADF; 99 105 errno = -rc; 100 return -1;106 LIBCLOG_ERROR_RETURN_INT(-1); 101 107 } 102 return cbWritten;108 LIBCLOG_RETURN_INT(cbWritten); 103 109 } 104 110 -
trunk/libc/src/libc/sys/b_dir.c
r2424 r2672 368 368 */ 369 369 char *psz = strchr(pszNativePath, '\0'); 370 psz[0] = '/'; 371 psz[1] = '*'; 372 psz[2] = '\0'; 370 if (psz[-1] != '/' && psz[-1] != '\\') 371 { 372 psz[0] = '/'; 373 psz[1] = '*'; 374 psz[2] = '\0'; 375 } 376 else 377 { 378 psz[0] = '*'; 379 psz[1] = '\0'; 380 } 373 381 bzero(Tmp.uBuf.pv, Tmp.cbBuf); 374 382 FS_VAR_SAVE_LOAD(); … … 380 388 &Tmp.cFiles, 381 389 Tmp.fType); 390 *psz = '\0'; 382 391 if (!rc) 383 392 { … … 390 399 391 400 __LIBC_PFHDIR pFHDir = (__LIBC_PFHDIR)pFH; 392 pFHDir-> hDir = Tmp.hDir;401 pFHDir->fInUnixTree = 0; 393 402 pFHDir->fType = Tmp.fType; 394 403 pFHDir->uBuf.pv = Tmp.uBuf.pv; … … 396 405 pFHDir->cFiles = Tmp.cFiles; 397 406 pFHDir->cbBuf = Tmp.cbBuf; 407 pFHDir->hDir = Tmp.hDir; 398 408 pFHDir->uCurEntry = 0; 399 409 … … 447 457 pFHDir->Core.Inode = Inode; 448 458 pFHDir->Core.Dev = Dev; 459 pFHDir->fInUnixTree = fInUnixTree; 449 460 450 461 /* … … 508 519 pFHDir->Core.Inode = pStat->st_ino; 509 520 pFHDir->Core.Dev = pStat->st_dev; 521 pFHDir->fInUnixTree = fInUnixTree; 510 522 511 523 LIBCLOG_MSG("pFHDir=%p:{.hDir=%#lx, .fType=%d, .cFiles=%ld, .cbBuf=%#x} fh=%d\n", -
trunk/libc/src/libc/sys/b_fs.h
r2328 r2672 242 242 * @returns 0 on success. 243 243 * @returns -1 on failure. 244 * @param ppFS Where to store the pointer to the inherit data. 245 * @param pcbFS Where to store the size of the inherit data. 246 */ 247 int __libc_back_fsInheritPack(__LIBC_PSPMINHFS *ppFS, size_t *pcbFS); 244 * @param ppFS Where to store the pointer to the inherit data, part 1. 245 * @param pcbFS Where to store the size of the inherit data, part 1. 246 * @param ppFS2 Where to store the pointer to the inherit data, part 2. 247 * @param pcbFS2 Where to store the size of the inherit data, part 2. 248 */ 249 int __libc_back_fsInheritPack(__LIBC_PSPMINHFS *ppFS, size_t *pcbFS, __LIBC_PSPMINHFS2 *ppFS2, size_t *pcbFS2); 248 250 249 251 /** … … 332 334 int __libc_back_fsUnixAttribsGet(int hFile, const char *pszNativePath, struct stat *pStat); 333 335 336 /** 337 * Reads the unix file mode EA. 338 * 339 * @returns 0 on success. 340 * @returns -ENOTSUP if the file mode EA is not present or if Unix EAs isn't supported on the volume. 341 * @returns Negative errno on failure. 342 * @param hFile File handle to the fs object. If no handle handy, set to -1. 343 * @param pszNativePath Native path to the fs object. If handle is give this will be ignored. 344 * @param pMode Where to store the mode mask. 345 */ 346 int __libc_back_fsUnixAttribsGetMode(int hFile, const char *pszNativePath, mode_t *pMode); 334 347 335 348 /** … … 411 424 412 425 /** 426 * Gets the fs info object for the specfied path. 427 * 428 * @returns Pointer to info object for the path, if it got one. 429 * @param pszNativePath The native path as returned by the resolver. 430 */ 431 __LIBC_PFSINFO __libc_back_fsInfoObjByPath(const char *pszNativePath); 432 433 /** 434 * Gets the fs info object for the specfied path, with cache. 435 * 436 * @returns Pointer to info object for the path, if it got one. 437 * @param pszNativePath The native path as returned by the resolver. 438 * @param pCached An cached fs info object reference. Can be NULL. 439 */ 440 __LIBC_PFSINFO __libc_back_fsInfoObjByPathCached(const char *pszNativePath, __LIBC_PFSINFO pCached); 441 442 /** 413 443 * Adds a reference to an existing FS info object. 414 444 * … … 428 458 void __libc_back_fsInfoObjRelease(__LIBC_PFSINFO pFsInfo); 429 459 460 /** 461 * Checks if the path supports Unix EAs or not. 462 * 463 * @returns true / false. 464 * @param pszNativePath The native path to check. 465 */ 466 int __libc_back_fsInfoSupportUnixEAs(const char *pszNativePath); 467 430 468 __END_DECLS 431 469 -
trunk/libc/src/libc/sys/b_fsDirCreate.c
r2313 r2672 69 69 */ 70 70 PEAOP2 pEaOp2 = NULL; 71 if (__predict_true( !__libc_gfNoUnix))71 if (__predict_true(__libc_back_fsInfoSupportUnixEAs(szNativePath))) 72 72 { 73 73 Mode &= ~__libc_gfsUMask; -
trunk/libc/src/libc/sys/b_fsFileModeSetFH.c
r2313 r2672 121 121 * If in unix mode we'll have to update/add the MODE too. 122 122 */ 123 if (!__libc_gfNoUnix) 123 if ( !__libc_gfNoUnix 124 && pFH->pFsInfo 125 && pFH->pFsInfo->fUnixEAs) 124 126 { 125 struct stat st = {0};126 rc = __libc_back_fsUnixAttribsGet (fh, pFH->pszNativePath, &st);127 mode_t CurMode; 128 rc = __libc_back_fsUnixAttribsGetMode(fh, pFH->pszNativePath, &CurMode); 127 129 if (__predict_true(!rc)) 128 130 { 129 131 /* correct the passed in Mode mask. */ 130 132 Mode &= ALLPERMS; /** @todo sticky bit and set uid/gid access validation... */ 131 Mode |= st.st_mode & ~ALLPERMS;133 Mode |= CurMode & ~ALLPERMS; 132 134 133 135 /* construct FEA2 stuff. */ -
trunk/libc/src/libc/sys/b_fsFileStatFH.c
r2316 r2672 71 71 LIBCLOG_ERROR_RETURN_INT(rc); 72 72 73 int fUnixEAs = !__libc_gfNoUnix && pFH->pFsInfo && pFH->pFsInfo->fUnixEAs; 73 74 if (/*!pFH->pOps*/ 1) 74 75 { … … 110 111 if (__libc_gpfnDosOpenL) 111 112 { 112 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 113 if (fUnixEAs) 114 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 115 else 116 rc = -1; 113 117 if (rc) 114 118 { … … 121 125 #endif 122 126 { 123 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 127 if (fUnixEAs) 128 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 129 else 130 rc = -1; 124 131 if (rc) 125 132 { … … 175 182 176 183 /* If in unix mode we'll check the EAs (if any). */ 177 if ( !__libc_gfNoUnix184 if ( fUnixEAs 178 185 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 179 186 __libc_back_fsUnixAttribsGet(fh, pFH->pszNativePath, pStat); -
trunk/libc/src/libc/sys/b_fsNativeFileModeSet.c
r2313 r2672 89 89 FS_SAVE_LOAD(); 90 90 int rc; 91 #if OFF_MAX > LONG_MAX 92 if (__libc_gpfnDosOpenL) 93 { 94 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 95 fLarge = 1; 91 const int fUnixEAs = __libc_back_fsInfoSupportUnixEAs(pszNativePath); 92 if (fUnixEAs) 93 { 94 #if OFF_MAX > LONG_MAX 95 if (__libc_gpfnDosOpenL) 96 { 97 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 98 fLarge = 1; 99 } 100 else 101 #endif 102 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 103 /* If the file is open in write mode, we cannot even get the EA size. stupid. 104 * It'll fail with ERROR_SHARING_VIOLATION, which we handle rigth below. */ 96 105 } 97 106 else 98 #endif 99 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 100 /* Now, if the file is open in write mode, we cannot even get the EA size. stupid. */ 107 rc = ERROR_SHARING_VIOLATION; /* take the fallback path if we don't want EAs. */ 101 108 if (rc == ERROR_SHARING_VIOLATION) 102 109 { … … 150 157 * If in unix mode we'll have to update/add the MODE too. 151 158 */ 152 if ( !__libc_gfNoUnix)153 { 154 struct stat st = {0};155 rc = __libc_back_fsUnixAttribsGet (-1, pszNativePath, &st);159 if (fUnixEAs) 160 { 161 mode_t CurMode; 162 rc = __libc_back_fsUnixAttribsGetMode(-1, pszNativePath, &CurMode); 156 163 if (__predict_true(!rc)) 157 164 { 158 165 /* correct the passed in Mode mask. */ 159 166 Mode &= ALLPERMS; /** @todo sticky bit and set uid/gid access validation... */ 160 Mode |= st.st_mode & ~ALLPERMS;167 Mode |= CurMode & ~ALLPERMS; 161 168 162 169 /* construct FEA2 stuff. */ -
trunk/libc/src/libc/sys/b_fsNativeFileStat.c
r2316 r2672 86 86 */ 87 87 /** @todo copy device check from the path resolver. */ 88 88 89 /* 89 90 * Get path info. … … 91 92 FS_SAVE_LOAD(); 92 93 int rc; 93 #if OFF_MAX > LONG_MAX 94 if (__libc_gpfnDosOpenL) 95 { 96 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 97 fLarge = 1; 98 } 99 else 100 #endif 101 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 94 const int fUnixEAs = __libc_back_fsInfoSupportUnixEAs(pszNativePath); 95 if (fUnixEAs) 96 { 97 #if OFF_MAX > LONG_MAX 98 if (__libc_gpfnDosOpenL) 99 { 100 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 101 fLarge = 1; 102 } 103 else 104 #endif 105 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 106 /* If the file is open in write mode, we cannot even get the EA size. stupid. 107 * It'll fail with ERROR_SHARING_VIOLATION, which we handle rigth below. */ 108 } 109 else 110 rc = ERROR_SHARING_VIOLATION; /* take the fallback path if we don't want EAs. */ 111 102 112 /* Now, if the file is open in write mode, we cannot even get the EA size. stupid. */ 103 113 if (rc == ERROR_SHARING_VIOLATION) … … 128 138 */ 129 139 /* Times: FAT might not return create and access time. */ 130 pStat->st_mtime = pStat->st_ mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite);140 pStat->st_mtime = pStat->st_ctime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite); 131 141 if ( FTIMEZEROP(info.fsts4.ftimeCreation) 132 142 && FDATEZEROP(info.fsts4.fdateCreation)) … … 198 208 /* If in unix mode we'll check the EAs (if any). */ 199 209 rc = 1; 200 if ( !__libc_gfNoUnix210 if ( fUnixEAs 201 211 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 202 212 rc = __libc_back_fsUnixAttribsGet(-1, pszNativePath, pStat); -
trunk/libc/src/libc/sys/b_fsUnlink.c
r2254 r2672 80 80 * times. 81 81 */ 82 static int fUseForce = 0; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */83 if ( fUseForce == 0)82 static int s_fUseForce = 0; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */ 83 if (s_fUseForce == 0) 84 84 { 85 85 PSZ psz = NULL; 86 86 if (DosScanEnv((PCSZ)"DELDIR", &psz) || !psz) 87 fUseForce = 1;87 s_fUseForce = 1; 88 88 else 89 fUseForce = -1;89 s_fUseForce = -1; 90 90 } 91 91 … … 93 93 * We'll attempt delete it as a file first. 94 94 */ 95 if ( fUseForce == 1)95 if (s_fUseForce == 1) 96 96 rc = DosForceDelete((PCSZ)&szNativePath[0]); 97 97 else … … 100 100 { 101 101 /* 102 * Ok, try delete it as a directory then. 102 * There are three causes here: 103 * 1) the file is marked read-only. 104 * 2) it's a directory. 105 * 3) we are denied access - network, hpfs386 or SES. 106 * 107 * If it's either of the first two we are subject to race conditions, so we 108 * have to retry. The third cause is distiguishable from the two othes by 109 * the failing DosSetPathInfo. 103 110 */ 104 rc = DosDeleteDir((PCSZ)&szNativePath[0]); 111 int fDirectory = 0; 112 for (unsigned i = 0; (rc == ERROR_ACCESS_DENIED || rc == ERROR_PATH_NOT_FOUND) && i < 2; i++) 113 { 114 FILESTATUS3 fsts3; 115 rc = DosQueryPathInfo((PCSZ)&szNativePath[0], FIL_STANDARD, &fsts3, sizeof(fsts3)); 116 if (!rc) 117 { 118 fDirectory = (fsts3.attrFile & FILE_DIRECTORY) != 0; 119 120 /* turn of the read-only attribute */ 121 if (fsts3.attrFile & FILE_READONLY) 122 { 123 fsts3.attrFile &= ~FILE_READONLY; 124 rc = DosSetPathInfo((PCSZ)&szNativePath[0], FIL_STANDARD, &fsts3, sizeof(fsts3), 0); 125 LIBCLOG_MSG("attempt at disabling the R attribute -> %d\n", rc); 126 if ( rc == ERROR_ACCESS_DENIED 127 || rc == ERROR_SHARING_VIOLATION) 128 { 129 rc = ERROR_ACCESS_DENIED; 130 break; 131 } 132 } 133 134 /* retry */ 135 if (fDirectory) 136 rc = DosDeleteDir((PCSZ)&szNativePath[0]); 137 else if (s_fUseForce == 1) 138 rc = DosForceDelete((PCSZ)&szNativePath[0]); 139 else 140 rc = DosDelete((PCSZ)&szNativePath[0]); 141 } 142 else 143 { 144 rc = ERROR_ACCESS_DENIED; 145 break; 146 } 147 } 148 149 /* 150 * OS/2 returns access denied when the directory 151 * contains files or it is not a directory. Check for 152 * directory/other and return failure accordingly. 153 */ 105 154 if (rc) 106 155 { 107 /*108 * OS/2 returns access denied when the directory109 * contains files or it is not a directory. Check for110 * directory/other and return failure accordingly.111 */112 156 if (rc == ERROR_ACCESS_DENIED) 113 { 114 struct stat s; 115 rc = __libc_back_fsNativeFileStat(&szNativePath[0], &s); 116 if (!rc && S_ISDIR(s.st_mode)) 117 rc = -ENOTEMPTY; 118 else 119 rc = -EACCES; 120 } 157 rc = fDirectory ? -ENOTEMPTY : -EACCES; 121 158 else 122 159 rc = -__libc_native2errno(rc); -
trunk/libc/src/libc/sys/b_ioFileOpen.c
r2424 r2672 259 259 Mode &= ACCESSPERMS; 260 260 Mode |= S_IFREG; 261 if (flOpenFlags & (OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS)) 261 if ( (flOpenFlags & (OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS)) 262 && __libc_back_fsInfoSupportUnixEAs(szNativePath)) 262 263 { 263 264 pEaOp2 = alloca(sizeof(EAOP2) + sizeof(__libc_gFsUnixAttribsCreateFEA2List)); -
trunk/libc/src/libc/sys/b_nativeSymlinkCreate.c
r2313 r2672 58 58 BYTE fSymlinkEA; 59 59 BYTE cbSymlinkName; 60 USHORT usSymlinkValue;60 USHORT cbSymlinkValue; 61 61 CHAR szSymlinkName[sizeof(EA_SYMLINK)]; 62 62 USHORT usSymlinkType; … … 77 77 OFF(offSymlink, Core.offFlags), FEA_NEEDEA, sizeof(EA_FLAGS) - 1, sizeof(uint32_t) + 4, EA_FLAGS, EAT_BINARY, sizeof(uint32_t), 0, "", 78 78 }, 79 0, FEA_NEEDEA, sizeof(EA_SYMLINK) - 1, 0 + 4, EA_ FLAGS, EAT_ASCII,0, ""79 0, FEA_NEEDEA, sizeof(EA_SYMLINK) - 1, 0 + 4, EA_SYMLINK,EAT_ASCII, 0, "" 80 80 #undef OFF 81 81 }; … … 112 112 113 113 /* 114 * Do we have UnixEAs on this path? 115 */ 116 if (__predict_false(!__libc_back_fsInfoSupportUnixEAs(pszNativePath))) 117 LIBCLOG_ERROR_RETURN(-ENOTSUP, "ret -ENOTSUP - no Unix EAs on '%s'\n", pszNativePath); 118 119 /* 114 120 * Allocate FEA buffer. 115 121 */ … … 126 132 *pFEas = __libc_gFsUnixAttribsCreateSymlinkFEA2List; 127 133 __libc_back_fsUnixAttribsInit(&pFEas->Core, pszNativePath, S_IFLNK | S_IRWXO | S_IRWXG | S_IRWXU); 128 pFEas->Core.cbList = cchTarget + sizeof(USHORT) * 2; 129 pFEas->cbSymlinkData = cchTarget; 134 pFEas->Core.cbList = cchTarget + sizeof(__libc_gFsUnixAttribsCreateSymlinkFEA2List) - 1; 135 pFEas->cbSymlinkValue += cchTarget; 136 pFEas->cbSymlinkData = cchTarget; 130 137 memcpy(pFEas->szSymlink, pszTarget, cchTarget); 131 138 … … 141 148 if (__predict_true(rc == NO_ERROR)) 142 149 { 143 DosWrite(hf, &p FEas->szSymlink[0], cchTarget, &ul);150 DosWrite(hf, &pszTarget, cchTarget, &ul); 144 151 DosClose(hf); 145 152 LIBCLOG_RETURN_INT(0); 146 153 } 147 154 155 struct stat s; 148 156 if (rc == ERROR_EAS_NOT_SUPPORTED) 149 157 rc = -EOPNOTSUPP; 158 else if ( rc == ERROR_OPEN_FAILED 159 && !__libc_back_fsNativeFileStat(pszNativePath, &s)) 160 rc = -EEXIST; 150 161 else 151 162 rc = -__libc_native2errno(rc); -
trunk/libc/src/libc/sys/b_panic.c
r2321 r2672 30 30 * Header Files * 31 31 *******************************************************************************/ 32 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_NOGROUP 32 33 #define INCL_BASE 33 34 #define INCL_ERRORS 34 35 #define INCL_FSMACROS 36 #define INCL_DOSUNDOCUEMENTED 35 37 #define _GNU_SOURCE 36 38 #include <string.h> 37 39 #include <InnotekLIBC/backend.h> 38 40 #include <InnotekLIBC/sharedpm.h> 39 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_NOGROUP40 41 #include <InnotekLIBC/logstrict.h> 41 42 #include <os2emx.h> … … 185 186 BOOL fQuiet = FALSE; 186 187 BOOL fVerbose = TRUE; 187 BOOL fBreakpoint = FALSE;188 BOOL fBreakpoint = DosSysCtl(DOSSYSCTL_AM_I_DEBUGGED, NULL) == TRUE; 188 189 BOOL fDumpProcess = TRUE; 189 190 const char *pszPanicCfg = NULL; … … 204 205 else if (panicStrICmp(&pszPanicCfg, "breakpoint", "BREAKPOINT")) 205 206 fBreakpoint = TRUE; 207 else if (panicStrICmp(&pszPanicCfg, "nobreakpoint", "NOBREAKPOINT")) 208 fBreakpoint = FALSE; 206 209 //else if (panicStrICmp(&pszPanicCfg, "dump", "DUMP")) 207 210 // fDumpProcess = TRUE; … … 415 418 { 416 419 if (!rc) 417 PRINT_C("Process ha vebeen dumped\r\n");420 PRINT_C("Process has been dumped\r\n"); 418 421 else if (rc == 0x00011176 || rc == ERROR_INVALID_PARAMETER) /* first is actual, 2nd is docs */ 419 PRINT_C("Process dumping was disabled, use DUMPPROC to enable it.\r\n");422 PRINT_C("Process dumping was disabled, use DUMPPROC / PROCDUMP to enable it.\r\n"); 420 423 else 421 424 { -
trunk/libc/src/libc/sys/filehandles.c
r2324 r2672 186 186 { 187 187 case __LIBC_SPM_INH_FHB_TYPE_STANDARD: 188 for (i = 0; i < c; i++ )188 for (i = 0; i < c; i++, iFH++) 189 189 { 190 190 __LIBC_PFH pFH; … … 205 205 206 206 case __LIBC_SPM_INH_FHB_TYPE_DIRECTORY: 207 for (i = 0; i < c; i++ )207 for (i = 0; i < c; i++, iFH++) 208 208 { 209 209 const char *pszPath = u.pDirs->aHandles[i].offNativePath ? pInherit->pszStrings + u.pDirs->aHandles[i].offNativePath : NULL; … … 222 222 223 223 case __LIBC_SPM_INH_FHB_TYPE_SOCKET_44: 224 for (i = 0; i < c; i++ )224 for (i = 0; i < c; i++, iFH++) 225 225 { 226 226 int rc = TCPNAMEG44(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL, NULL); … … 237 237 238 238 case __LIBC_SPM_INH_FHB_TYPE_SOCKET_43: 239 for (i = 0; i < c; i++ )239 for (i = 0; i < c; i++, iFH++) 240 240 { 241 241 int rc = TCPNAMEG43(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL, NULL); -
trunk/libc/src/libc/sys/fs.c
r2328 r2672 141 141 142 142 /** 143 * The prefilled GEA2LIST construct for querying all the mode attribute. 144 */ 145 #pragma pack(1) 146 static const struct 147 { 148 ULONG cbList; 149 ULONG oNextEntryOffset; 150 BYTE cbName; 151 CHAR szName[sizeof(EA_MODE)]; 152 } gGEA2ListMode = 153 { 154 sizeof(gGEA2ListMode), 155 0, 156 sizeof(EA_MODE) - 1, 157 EA_MODE 158 }; 159 #pragma pack() 160 161 /** 143 162 * The prefilled FEA2LIST construct for setting all attributes during a creation operation. 144 163 */ … … 231 250 */ 232 251 __LIBC_PSPMINHERIT pInherit = __libc_spmInheritRequest(); 252 253 /* part 2, the umask. */ 254 __LIBC_PSPMINHFS2 pFS2; 255 if ( pInherit 256 && pInherit->cb > offsetof(__LIBC_SPMINHERIT, pFS2) 257 && (pFS2 = pInherit->pFS2) != NULL 258 && !(pFS2->fUMask & ~0777)) 259 { 260 LIBCLOG_MSG("Inherited fUMask=%04o\n", pFS2->fUMask); 261 __libc_gfsUMask = pFS2->fUMask & 0777; 262 } 263 264 /* part 1, the unixroot. */ 233 265 __LIBC_PSPMINHFS pFS; 234 266 if ( pInherit … … 320 352 * @returns 0 on success. 321 353 * @returns -1 on failure. 322 * @param ppFS Where to store the pointer to the inherit data. 323 * @param pcbFS Where to store the size of the inherit data. 324 */ 325 int __libc_back_fsInheritPack(__LIBC_PSPMINHFS *ppFS, size_t *pcbFS) 326 { 327 LIBCLOG_ENTER("ppFS=%p pcbFS=%p\n", (void *)ppFS, (void *)pcbFS); 354 * @param ppFS Where to store the pointer to the inherit data, part 1. 355 * @param pcbFS Where to store the size of the inherit data, part 1. 356 * @param ppFS2 Where to store the pointer to the inherit data, part 2. 357 * @param pcbFS2 Where to store the size of the inherit data, part 2. 358 */ 359 int __libc_back_fsInheritPack(__LIBC_PSPMINHFS *ppFS, size_t *pcbFS, __LIBC_PSPMINHFS2 *ppFS2, size_t *pcbFS2) 360 { 361 LIBCLOG_ENTER("ppFS=%p pcbFS=%p ppFS2=%p pcbFS2=%p\n", (void *)ppFS, (void *)pcbFS, (void *)ppFS2, (void *)pcbFS2); 328 362 329 363 *ppFS = NULL; 330 364 *pcbFS = 0; 365 *ppFS2 = NULL; 366 *pcbFS2 = 0; 331 367 332 368 if (__libc_back_fsMutexRequest()) … … 347 383 *pcbFS = cb; 348 384 *ppFS = pFS; 385 } 386 else 387 rc = -1; 388 } 389 390 if (!rc) 391 { 392 __LIBC_PSPMINHFS2 pFS2 = (__LIBC_PSPMINHFS2)malloc(sizeof(*pFS2)); 393 if (pFS2) 394 { 395 pFS2->cb = sizeof(*pFS2); 396 pFS2->fUMask = __libc_gfsUMask; 397 LIBCLOG_MSG("fUMask=%04o\n", pFS2->fUMask); 398 399 *pcbFS2 = sizeof(*pFS2); 400 *ppFS2 = pFS2; 349 401 } 350 402 else … … 446 498 LIBCLOG_ERROR_RETURN_INT(rc); 447 499 } 500 501 502 /** 503 * Checks if the specified path is a symlink or not. 504 * @returns true / false. 505 * @param pszNativePath Path to the potential symlink. 506 */ 507 static int fsIsSymlink(const char *pszNativePath) 508 { 509 char sz[16]; 510 return __libc_back_fsNativeSymlinkRead(pszNativePath, sz, sizeof(sz)) >= 0; 511 } 512 448 513 449 514 #if 0 //just testing, not useful. … … 570 635 /* 571 636 * Remove trailing slash if the path may be pointing to a directory. 637 * A symlink search is converted to a directory search if this is encountered. 572 638 */ 573 639 int cch = pszTrg - pszPath; 574 if ( (fFlags & BACKFS_FLAGS_RESOLVE_DIR)640 if ( (fFlags & (BACKFS_FLAGS_RESOLVE_DIR | BACKFS_FLAGS_RESOLVE_FULL_SYMLINK)) 575 641 && cch > 1 576 642 && pszTrg[-1] == '/' … … 580 646 pszPath[--cch] = '\0'; 581 647 if (pfFlags) 582 *pfFlags &= ~BACKFS_FLAGS_RESOLVE_DIR_MAYBE_; 648 { 649 *pfFlags &= ~(BACKFS_FLAGS_RESOLVE_DIR_MAYBE_ | BACKFS_FLAGS_RESOLVE_FULL_SYMLINK); 650 if (fFlags & BACKFS_FLAGS_RESOLVE_FULL_SYMLINK) 651 *pfFlags |= BACKFS_FLAGS_RESOLVE_DIR | BACKFS_FLAGS_RESOLVE_FULL; 652 } 583 653 } 584 654 … … 637 707 LIBCLOG_ENTER("pszUserPath=%p:{%s} pszNativePath=%p *pfInUnixTree=%p\n", 638 708 (void *)pszUserPath, pszUserPath, (void *)pszNativePath, (void *)pfInUnixTree); 639 const char *pszUserPathIn = pszUserPath; 640 char _achBuffer[SIZEOF_ACHBUFFER + 4]; 641 char *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3); 642 unsigned cLoopsLeft = 8; 643 int fInUnixTree = __libc_gfInUnixTree; 644 int rcRet = 0; 645 HDIR hDir = HDIR_CREATE; 709 const char *pszUserPathIn = pszUserPath; 710 char _achBuffer[SIZEOF_ACHBUFFER + 4]; 711 char *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3); 712 unsigned cLoopsLeft = 8; 713 int fInUnixTree = __libc_gfInUnixTree; 714 int rcRet = 0; 715 HDIR hDir = HDIR_CREATE; 716 __LIBC_PFSINFO pFsInfo = NULL; 717 int fUnixEAs; 646 718 FS_VAR() 647 719 FS_SAVE_LOAD(); … … 889 961 iRoot = psz - pszNativePath; 890 962 psz = strchr(psz, '/'); 963 964 /* We don't do UNIX EAs on UNCs */ 965 fUnixEAs = 0; 891 966 } 892 967 else … … 898 973 pszPrev = &pszNativePath[iRoot + 1]; 899 974 psz = strchr(pszPrev, '/'); 975 976 /* Unix EAs? */ 977 pFsInfo = __libc_back_fsInfoObjByPathCached(pszNativePath, pFsInfo); 978 LIBC_ASSERTM(pFsInfo, "%s\n", pszNativePath); 979 fUnixEAs = pFsInfo ? pFsInfo->fUnixEAs : 0; 900 980 } 901 981 LIBC_ASSERTM(pszPrev - pszNativePath >= iRoot, "iRoot=%d pszPrev offset %d pszNativePath=%s\n", iRoot, pszPrev - pszNativePath, pszNativePath); … … 973 1053 * This'll of course also provide proper verification of the path too. :-) 974 1054 * 975 * (This is a little bit messed up since we'll have to use wildcard for 976 * getting the caseing resolved.) 1055 * This is a little bit messed up since we'll have to use wildcard for 1056 * getting the casing resolved. 1057 * 1058 * The two find buffers are assumed to be equal down thru attrFile. 977 1059 */ 978 1060 //LIBC_ASSERT(psz - pszNativePath == cchNativePath); - figure this one. 979 PFILEFINDBUF4 pFindBuf = (PFILEFINDBUF4)pachBuffer; 1061 PFILEFINDBUF4 pFindBuf4 = (PFILEFINDBUF4)pachBuffer; 1062 PFILEFINDBUF3 pFindBuf3 = (PFILEFINDBUF3)pachBuffer; 980 1063 ULONG cFiles = 1; 981 1064 char chNext = psz[1]; … … 983 1066 psz[1] = '\0'; 984 1067 int rc = DosFindFirst((PCSZ)pszNativePath, &hDir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED, 985 p FindBuf, SIZEOF_ACHBUFFER, &cFiles, FIL_QUERYEASIZE);1068 pachBuffer, SIZEOF_ACHBUFFER, &cFiles, fUnixEAs ? FIL_QUERYEASIZE : FIL_STANDARD); 986 1069 psz[0] = '\0'; 987 1070 psz[1] = chNext; 988 1071 if (rc || cFiles == 0) 989 {990 1072 hDir = HDIR_CREATE; 991 } 992 while (!rc && cFiles == 1 && pFindBuf->cchName != psz - pszPrev) 993 rc = DosFindNext(hDir, pFindBuf, SIZEOF_ACHBUFFER, &cFiles); 1073 while (!rc && cFiles == 1 && (fUnixEAs ? pFindBuf4->cchName : pFindBuf3->cchName) != psz - pszPrev) 1074 rc = DosFindNext(hDir, pachBuffer, SIZEOF_ACHBUFFER, &cFiles); 994 1075 if (rc || cFiles == 0) 995 1076 { … … 1004 1085 break; 1005 1086 } 1006 memcpy(pszPrev, pFindBuf->achName, psz - pszPrev);1007 int fIsDirectory = (pFindBuf ->attrFile & FILE_DIRECTORY) != 0;1087 memcpy(pszPrev, fUnixEAs ? pFindBuf4->achName : pFindBuf3->achName, psz - pszPrev); 1088 int fIsDirectory = (pFindBuf4->attrFile & FILE_DIRECTORY) != 0; 1008 1089 1009 1090 /* 1010 * Try querying the symlink EA value 1011 * (This operation will reuse the achBuffer overwriting the pFindBuf data!)1091 * Try querying the symlink EA value. 1092 * (This operation will reuse the achBuffer overwriting the pFindBuf[3/4] data!) 1012 1093 * 1013 1094 * Yeah, we could do this in the same operation as the DosFindFirst() but … … 1015 1096 * returning the right things at some point, and besides it's return data 1016 1097 * is rather clumsily laid out. So, I decided not to try my luck on it. 1098 * 1099 * On second thought, we seems to end up having to use DosFindFirst in some 1100 * cases anyway... very nice. 1017 1101 */ 1018 if ( pFindBuf->cbList > sizeof(USHORT) * 2 + 1 1102 if ( fUnixEAs 1103 && pFindBuf4->cbList > sizeof(USHORT) * 2 + 1 1019 1104 && ( (fFlags & BACKFS_FLAGS_RESOLVE_FULL) 1020 || chSlash)) 1021 { 1022 EAOP2 EaOp; 1023 EaOp.fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink; 1024 EaOp.fpFEA2List = (PFEA2LIST)pachBuffer; 1025 EaOp.oError = 0; 1026 EaOp.fpFEA2List->cbList = SIZEOF_ACHBUFFER; 1027 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp)); 1105 || chSlash) 1106 && !fIsDirectory) 1107 { 1108 PEAOP2 pEaOp2 = (PEAOP2)pachBuffer; 1109 pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink; 1110 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1111 pEaOp2->oError = 0; 1112 pEaOp2->fpFEA2List->cbList = SIZEOF_ACHBUFFER - sizeof(*pEaOp2); 1113 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, pEaOp2, sizeof(*pEaOp2)); 1028 1114 if (rc) 1029 1115 { 1030 LIBCLOG_MSG("DosQueryPathInfo('%s',,,) -> %d resolving '%s'\n", pszNativePath, rc, pszUserPathIn); 1031 if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash) 1032 rcRet = 0; 1033 else 1034 rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc); 1035 break; 1116 cFiles = 1; 1117 pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink; 1118 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1119 pEaOp2->oError = 0; 1120 pEaOp2->fpFEA2List->cbList = SIZEOF_ACHBUFFER - sizeof(*pEaOp2); 1121 rc = DosFindFirst((PCSZ)pszNativePath, &hDir, 0, pEaOp2, pEaOp2->fpFEA2List->cbList + sizeof(*pEaOp2), &cFiles, FIL_QUERYEASFROMLIST); 1122 if (rc || cFiles == 0) 1123 { 1124 hDir = HDIR_CREATE; 1125 LIBCLOG_MSG("DosFindFirst('%s',,,pEaOp2,) -> %d resolving '%s'\n", pszNativePath, rc, pszUserPathIn); 1126 if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash) 1127 rcRet = 0; 1128 else 1129 rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc); 1130 break; 1131 } 1132 pEaOp2->fpFEA2List = (PFEA2LIST)((char *)pEaOp2 + sizeof(EAOP2) + offsetof(FILEFINDBUF3, cchName)); 1036 1133 } 1037 1134 … … 1039 1136 * Did we find any symlink EA? 1040 1137 */ 1041 if ( EaOp.fpFEA2List->cbList > sizeof(EaOp.fpFEA2List->list[0])1042 && EaOp.fpFEA2List->list[0].cbValue)1138 if ( pEaOp2->fpFEA2List->cbList > sizeof(pEaOp2->fpFEA2List->list[0]) 1139 && pEaOp2->fpFEA2List->list[0].cbValue) 1043 1140 { 1044 1141 /* Validate the EA. */ 1045 PUSHORT pusType = (PUSHORT)((char *)& EaOp.fpFEA2List->list[1] + EaOp.fpFEA2List->list[0].cbName);1142 PUSHORT pusType = (PUSHORT)((char *)&pEaOp2->fpFEA2List->list[1] + pEaOp2->fpFEA2List->list[0].cbName); 1046 1143 char *pszSymlink = (char *)&pusType[2]; 1047 1144 if ( pusType[0] != EAT_ASCII 1048 || pusType[1] > EaOp.fpFEA2List->list[0].cbValue1145 || pusType[1] > pEaOp2->fpFEA2List->list[0].cbValue 1049 1146 || !pusType[1] 1050 1147 || !*pszSymlink) 1051 1148 { 1052 1149 LIBCLOG_ERROR("Invalid symlink EA! type=%x len=%d cbValue=%d *pszSymlink=%c\n", 1053 pusType[0], pusType[1], EaOp.fpFEA2List->list[0].cbValue, *pszSymlink);1150 pusType[0], pusType[1], pEaOp2->fpFEA2List->list[0].cbValue, *pszSymlink); 1054 1151 rcRet = -EFTYPE; 1055 1152 break; … … 1150 1247 rcRet = 0; 1151 1248 if ( (fFlags & (BACKFS_FLAGS_RESOLVE_DIR | BACKFS_FLAGS_RESOLVE_DIR_MAYBE_)) == BACKFS_FLAGS_RESOLVE_DIR 1152 && !fIsDirectory) 1249 && !fIsDirectory 1250 && ( !fUnixEAs 1251 || pFindBuf4->cbList <= sizeof(USHORT) * 2 + 1 1252 || !fsIsSymlink(pszNativePath))) 1153 1253 rcRet = -ENOTDIR; 1154 1254 break; … … 1175 1275 1176 1276 /* 1177 * Cleanup find handle .1277 * Cleanup find handle and fs object. 1178 1278 */ 1179 1279 if (hDir != HDIR_CREATE) 1180 1280 DosFindClose(hDir); 1281 if (pFsInfo) 1282 __libc_back_fsInfoObjRelease(pFsInfo); 1181 1283 FS_RESTORE(); 1182 1284 … … 1403 1505 pStat->st_gid = u32; 1404 1506 else if (COMPARE_EANAME(__libc_gszModeEA)) 1405 pStat->st_mode = u32; 1507 { 1508 if ( S_ISDIR(u32) || S_ISCHR(u32) || S_ISBLK(u32) || S_ISREG(u32) 1509 || S_ISFIFO(u32) || S_ISLNK(u32) || S_ISSOCK(u32) || S_ISWHT(u32)) 1510 pStat->st_mode = u32; 1511 else 1512 LIBC_ASSERTM_FAILED("Invalid file mode EA: u32=0%o (st_mode=0%o)\n", u32, pStat->st_mode); 1513 } 1406 1514 else if (COMPARE_EANAME(__libc_gszRDevEA)) 1407 1515 pStat->st_rdev = u32; … … 1437 1545 } 1438 1546 1547 /* 1548 * Calc st_ino and st_dev if not found. 1549 */ 1550 if ((!pStat->st_ino || !pStat->st_dev) && pszNativePath) 1551 { 1552 ino_t Inode; 1553 dev_t Dev = __libc_back_fsPathCalcInodeAndDev(pszNativePath, &Inode); 1554 if (!pStat->st_ino) 1555 pStat->st_ino = Inode; 1556 if (!pStat->st_dev) 1557 pStat->st_dev = Dev; 1558 } 1559 1439 1560 LIBCLOG_RETURN_INT(0); 1561 } 1562 1563 1564 /** 1565 * Reads the unix file mode EA. 1566 * 1567 * @returns 0 on success. 1568 * @returns -ENOTSUP if the file mode EA is not present or if Unix EAs isn't supported on the volume. 1569 * @returns Negative errno on failure. 1570 * @param hFile File handle to the fs object. If no handle handy, set to -1. 1571 * @param pszNativePath Native path to the fs object. If handle is give this will be ignored. 1572 * @param pMode Where to store the mode mask. 1573 */ 1574 int __libc_back_fsUnixAttribsGetMode(int hFile, const char *pszNativePath, mode_t *pMode) 1575 { 1576 LIBCLOG_ENTER("hFile=%d pszNativePath=%p:{%s} pMode=%p\n", hFile, (void *)pszNativePath, pszNativePath, (void *)pMode); 1577 1578 /* Try come up with an accurate max estimate of a maximum result. */ 1579 char achBuffer[sizeof(EAOP2) + sizeof(FILEFINDBUF3) + sizeof(gGEA2ListMode) + 1 * (sizeof(USHORT) * 2 + sizeof(BYTE)) + 1 * sizeof(uint32_t) + 0x30]; 1580 char *pachBuffer = (char *)((uintptr_t)&achBuffer[3] & ~3); 1581 PEAOP2 pEaOp2 = (PEAOP2)pachBuffer; 1582 int rc = -1000; 1583 1584 *pMode = 0; 1585 1586 /** @todo the following query is generic! It's repeated 3 times already in this file (only the gea list and buffer size varies). */ 1587 /* 1588 * Issue the query. 1589 */ 1590 if (hFile >= 0) 1591 { 1592 pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListMode; 1593 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1594 pEaOp2->oError = 0; 1595 pEaOp2->fpFEA2List->cbList = sizeof(achBuffer) - 4 - sizeof(EAOP2); 1596 rc = DosQueryFileInfo(hFile, FIL_QUERYEASFROMLIST, pEaOp2, sizeof(EAOP2)); 1597 } 1598 if (rc && pszNativePath) 1599 { 1600 pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListMode; 1601 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1602 pEaOp2->oError = 0; 1603 pEaOp2->fpFEA2List->cbList = sizeof(achBuffer) - 4 - sizeof(EAOP2); 1604 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, pEaOp2, sizeof(EAOP2)); 1605 if (rc == ERROR_SHARING_VIOLATION || rc == ERROR_ACCESS_DENIED || rc == ERROR_INVALID_ACCESS) 1606 { 1607 HDIR hDir = HDIR_CREATE; 1608 ULONG cFiles = 1; 1609 pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListMode; 1610 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1611 pEaOp2->oError = 0; 1612 pEaOp2->fpFEA2List->cbList = sizeof(achBuffer) - 4 - sizeof(EAOP2); 1613 rc = DosFindFirst((PCSZ)pszNativePath, &hDir, 0, pEaOp2, pEaOp2->fpFEA2List->cbList + sizeof(*pEaOp2), &cFiles, FIL_QUERYEASFROMLIST); 1614 if (!rc) 1615 { 1616 DosFindClose(hDir); 1617 pEaOp2->fpFEA2List = (PFEA2LIST)((char *)pEaOp2 + sizeof(EAOP2) + offsetof(FILEFINDBUF3, cchName)); 1618 } 1619 } 1620 } 1621 if (rc) 1622 { 1623 LIBC_ASSERTM(rc == ERROR_ACCESS_DENIED || rc == ERROR_SHARING_VIOLATION || rc == ERROR_EAS_NOT_SUPPORTED, 1624 "Bogus EAs? rc=%d oError=%ld\n", rc, pEaOp2->oError); 1625 rc = -__libc_native2errno(rc); 1626 LIBCLOG_ERROR_RETURN_INT(rc); 1627 } 1628 1629 /* 1630 * Parse the result. 1631 * There is only one EA here, so this is gonna be pretty simple... 1632 */ 1633 rc = -ENOTSUP; 1634 PFEA2 pFea2 = &pEaOp2->fpFEA2List->list[0]; 1635 if ( pEaOp2->fpFEA2List->cbList > sizeof(*pFea2) 1636 && pFea2->cbValue > 0 1637 && pFea2->cbName == sizeof(EA_MODE) - 1 1638 && !memcmp(EA_MODE, pFea2->szName, sizeof(EA_MODE) - 1) 1639 ) 1640 { 1641 PUSHORT pusType = (PUSHORT)&pFea2->szName[pFea2->cbName + 1]; 1642 if ( pusType[0] == EAT_BINARY 1643 && pusType[1] == sizeof(uint32_t) 1644 ) 1645 { 1646 uint32_t u32 = *(uint32_t *)(pusType + 2); 1647 if ( S_ISDIR(u32) || S_ISCHR(u32) || S_ISBLK(u32) || S_ISREG(u32) 1648 || S_ISFIFO(u32) || S_ISLNK(u32) || S_ISSOCK(u32) || S_ISWHT(u32)) 1649 { 1650 *pMode = u32; 1651 rc = 0; 1652 } 1653 else 1654 LIBC_ASSERTM_FAILED("Invalid file mode EA: u32=0%o\n", u32); 1655 } 1656 else 1657 LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' type=%#x len=%#x, expected type=%#x and len=4.\n", 1658 pFea2->szName, pusType[0], pusType[1], EAT_BINARY); 1659 } 1660 1661 LIBCLOG_RETURN_MSG(rc, "ret %d *pMode=#%x\n", rc, *pMode); 1440 1662 } 1441 1663 … … 1489 1711 /* init the structure */ 1490 1712 pFsInfo->fZeroNewBytes = 0; 1713 pFsInfo->fUnixEAs = 0; 1491 1714 pFsInfo->Dev = Dev; 1492 1715 pFsInfo->szName[0] = '\0'; … … 1504 1727 if ( !strcmp(pFsInfo->szName, "JFS") 1505 1728 || !strcmp(pFsInfo->szName, "HPFS") 1506 || !strcmp(pFsInfo->szName, "FAT") 1507 || !strcmp(pFsInfo->szName, "LAN")) 1508 pFsInfo->fZeroNewBytes = 1; /* RAMFS does not do this. */ 1509 LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d\n", 1510 pFsInfo->Dev, pFsInfo->szMountpoint, pFsInfo->szName, pFsInfo->fZeroNewBytes); 1729 || !strcmp(pFsInfo->szName, "FAT")) 1730 { 1731 pFsInfo->fZeroNewBytes = 1; 1732 pFsInfo->fUnixEAs = 1; 1733 } 1734 else if (!strcmp(pFsInfo->szName, "LAN")) 1735 { 1736 /* should find a way of getting the remote fs... */ 1737 pFsInfo->fZeroNewBytes = 1; /* for performance reasons, assume it zeros. */ 1738 pFsInfo->fUnixEAs = 0; 1739 } 1740 else if (!strcmp(pFsInfo->szName, "RAMFS")) 1741 { 1742 pFsInfo->fZeroNewBytes = 0; 1743 pFsInfo->fUnixEAs = 1; /* but it doesn't zero */ 1744 } 1745 /*else if (!strcmp(pFsInfo->szName, "FAT32")) 1746 { 1747 pFsInfo->fZeroNewBytes = 0; 1748 pFsInfo->fUnixEAs = 0; 1749 }*/ 1750 else 1751 { 1752 pFsInfo->fZeroNewBytes = 0; 1753 pFsInfo->fUnixEAs = 0; 1754 } 1755 1756 LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d fUnixEAs=%d\n", 1757 pFsInfo->Dev, pFsInfo->szMountpoint, pFsInfo->szName, pFsInfo->fZeroNewBytes, 1758 pFsInfo->fUnixEAs); 1511 1759 FS_RESTORE(); 1512 1760 } … … 1546 1794 1547 1795 1548 #if 01549 1796 /** 1550 1797 * Gets the fs info object for the specfied path. … … 1569 1816 return __libc_back_fsInfoObjByDev(Dev); 1570 1817 } 1571 #endif 1818 1819 1820 /** 1821 * Gets the fs info object for the specfied path, with cache. 1822 * 1823 * @returns Pointer to info object for the path, if it got one. 1824 * @param pszNativePath The native path as returned by the resolver. 1825 * @param pCached An cached fs info object reference. Can be NULL. 1826 */ 1827 __LIBC_PFSINFO __libc_back_fsInfoObjByPathCached(const char *pszNativePath, __LIBC_PFSINFO pCached) 1828 { 1829 /* 1830 * Calc device. 1831 */ 1832 dev_t Dev; 1833 char chDrv = *pszNativePath; 1834 if (chDrv == '/' || chDrv == '\\') 1835 Dev = makedev('U', 0); /* U as in UNC */ 1836 else 1837 { 1838 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1839 Dev = makedev('V', chDrv); /* V as in Volume */ 1840 } 1841 if (!pCached) 1842 return __libc_back_fsInfoObjByDev(Dev); 1843 if (pCached->Dev == Dev) 1844 return pCached; 1845 __libc_back_fsInfoObjRelease(pCached); 1846 return __libc_back_fsInfoObjByDev(Dev); 1847 } 1572 1848 1573 1849 … … 1602 1878 { 1603 1879 int cRefs = __atomic_decrement_s32(&pFsInfo->cRefs); 1604 LIBC_ASSERT(cRefs > 1); (void)cRefs; 1605 } 1880 LIBC_ASSERT(cRefs >= 0); (void)cRefs; 1881 } 1882 } 1883 1884 1885 /** 1886 * Checks if the path supports Unix EAs or not. 1887 * 1888 * @returns true / false. 1889 * @param pszNativePath The native path to check. 1890 */ 1891 int __libc_back_fsInfoSupportUnixEAs(const char *pszNativePath) 1892 { 1893 if (__libc_gfNoUnix) 1894 return 0; 1895 1896 __LIBC_PFSINFO pFsInfo = __libc_back_fsInfoObjByPath(pszNativePath); 1897 const int fUnixEAs = pFsInfo && pFsInfo->fUnixEAs; 1898 __libc_back_fsInfoObjRelease(pFsInfo); 1899 return fUnixEAs; 1606 1900 } 1607 1901 -
trunk/libc/src/libc/sys/logstrict.c
r2260 r2672 218 218 /* 219 219 * Open the file. 220 * Make sure the filehandle is above the frequently used range (esp. std handles). 220 221 */ 221 222 rc = DosOpen((PCSZ)pszFilename, &pInst->hFile, &ulAction, 0, FILE_NORMAL, … … 228 229 FS_RESTORE(); 229 230 return NULL; 231 } 232 if (pInst->hFile < 10) 233 { 234 int i; 235 HFILE ah[10]; 236 for (i = 0; i < 10; i++) 237 { 238 ah[i] = -1; 239 rc = DosDupHandle(pInst->hFile, &ah[i]); 240 if (rc) 241 break; 242 } 243 if (i-- > 0) 244 { 245 DosClose(pInst->hFile); 246 pInst->hFile = ah[i]; 247 while (i-- > 0) 248 DosClose(ah[i]); 249 } 230 250 } 231 251 … … 1848 1868 /* argsize */ 1849 1869 chArgSize = *pszFormat; 1850 if (chArgSize != 'l' && chArgSize != 'L' && chArgSize != 'H') 1870 if ( chArgSize != 'l' && chArgSize != 'L' && chArgSize != 'h' && chArgSize != 'H' 1871 && chArgSize != 'j' && chArgSize != 'z' && chArgSize != 't') 1851 1872 chArgSize = 0; 1852 else if (*++pszFormat == 'l' && chArgSize == 'l')1873 else 1853 1874 { 1854 chArgSize = 'L';1855 1875 pszFormat++; 1876 if (*pszFormat == 'l' && chArgSize == 'l') 1877 { 1878 chArgSize = 'L'; 1879 pszFormat++; 1880 } 1881 else if (*pszFormat == 'h' && chArgSize == 'h') 1882 { 1883 chArgSize = 'H'; 1884 pszFormat++; 1885 } 1856 1886 } 1857 1887 … … 1988 2018 else if (chArgSize == 'h') 1989 2019 ulValue = va_arg(args, signed /*short*/ int); /* the great GCC pedantically saith use int. */ 2020 else if (chArgSize == 'H') 2021 ulValue = va_arg(args, /* int8_t */ int); /* the great GCC pedantically saith use int. */ 2022 else if (chArgSize == 'j') 2023 ulValue = va_arg(args, intmax_t); 2024 else if (chArgSize == 'z') 2025 ulValue = va_arg(args, size_t); 2026 else if (chArgSize == 't') 2027 ulValue = va_arg(args, ptrdiff_t); 1990 2028 else 1991 2029 ulValue = va_arg(args, signed int); -
trunk/libc/src/libc/sys/signals.c
r2427 r2672 2967 2967 if (*pfDone) 2968 2968 { 2969 rc = -EINTR; 2969 rc = __libc_back_signalSemRequest(); 2970 if (!rc) 2971 rc = -EINTR; 2970 2972 break; 2971 2973 } … … 2975 2977 * We returned from the wait, but did we do so for the right reason? 2976 2978 */ 2977 if (__libc_back_signalSemRequest()) 2978 rc = -EDEADLK; 2979 int rc2 = __libc_back_signalSemRequest(); 2980 if (rc2 < 0) 2981 rc = rc2; 2979 2982 else if (*pfDone) 2980 2983 rc = -EINTR; -
trunk/libc/src/libsocket/recvfrom.c
r1517 r2672 30 30 #include "libc-alias.h" 31 31 #include <errno.h> 32 #include <netinet/in.h> 32 33 #include <sys/socket.h> 33 34 #include <sys/fcntl.h> … … 47 48 rc = __libsocket_recvfrom(pFHSocket->iSocket, buf, len, flags, from, fromlen); 48 49 if (rc >= 0) 50 { 51 if (from && fromlen) 52 { 53 #ifdef TCPV40HDRS 54 if (*fromlen > sizeof(struct sockaddr_in) && from->sa_family == AF_INET) 55 *fromlen = sizeof(struct sockaddr_in); 56 #else 57 if (*fromlen > from->sa_len) 58 *fromlen = from->sa_len; 59 #endif 60 } 49 61 LIBCLOG_RETURN_INT(rc); 62 } 50 63 __libc_TcpipUpdateErrno(); 51 64 } -
trunk/libc/src/libsocket/recvmsg.c
r1454 r2672 31 31 #include <errno.h> 32 32 #include <sys/socket.h> 33 #include <netinet/in.h> 33 34 #include <sys/fcntl.h> 34 35 #include <emx/io.h> … … 46 47 rc = __libsocket_recvmsg(pFHSocket->iSocket, msg, flags); 47 48 if (rc >= 0) 49 { 50 /* Workaround for missing msg_namelen update. Required if a IPV6 sized buffer is given. 51 * (This problem hasn't been explored well enough, so this workaround is rather cautious.) 52 */ 53 if (msg) 54 { 55 struct sockaddr_in *pAddr = (struct sockaddr_in *)msg->msg_name; 56 #ifndef TCPV40HDRS 57 if (pAddr && msg->msg_namelen > pAddr->sin_len) 58 msg->msg_namelen = pAddr->sin_len; 59 #else 60 61 if ( pAddr 62 && pAddr->sin_family == AF_INET 63 && msg->msg_namelen > sizeof(struct sockaddr_in)) 64 msg->msg_namelen = sizeof(struct sockaddr_in); 65 #endif 66 67 } 48 68 LIBCLOG_RETURN_INT(rc); 69 } 49 70 __libc_TcpipUpdateErrno(); 50 71 } -
trunk/libc/tests/libc/Makefile
r2508 r2672 32 32 ifeq ($(TARGET),innoteklibc) 33 33 SKIPPED := 34 EXPECTED := smoketests/usleep-1.c \ 35 smoketests/fchmod-1.c 34 EXPECTED := smoketests/usleep-1.c 36 35 _TARGET_OK := ok 37 36 endif … … 81 80 smoketests/strnlen-1.c \ 82 81 smoketests/strtof-1.c \ 82 smoketests/symlink-1.c \ 83 83 smoketests/sysctl-1.c \ 84 84 smoketests/socket-1.c \ … … 95 95 smoketests/fstat-1.c \ 96 96 smoketests/fchmod-1.c \ 97 smoketests/nonblock-1.c 97 smoketests/nonblock-1.c \ 98 smoketests/fclose-2.c \ 99 smoketests/basename-dirname-1.c \ 100 smoketests/fcloseall-1.c 98 101 99 102 # smoketests/weak-export-1.c - dll … … 121 124 emxomf -m__text -o $(OUTDIR)/smoketests/asmstub-omf.obj $(OUTDIR)/smoketests/asmstub-omf.o 122 125 gcc -Zomf -lend -s -nostdlib -o $@ $(OUTDIR)/smoketests/asmstub-omf.obj 123 124 125 BUGS := \126 bugs/19-limits.c127 126 128 127 SUBTESTS := \ -
trunk/libc/tests/libc/smoketests/fchmod-1.c
r2311 r2672 13 13 if (!rc) 14 14 { 15 if ((st.st_mode & 0777) != Mode)15 if ((st.st_mode & (0777 | S_IFMT)) != Mode) 16 16 { 17 17 printf("Invalid mode 0%o, expected 0%o\n", st.st_mode & 0777, Mode); … … 35 35 if (fh >= 0) 36 36 { 37 check_mode(fh, 0766 );37 check_mode(fh, 0766 | S_IFREG); 38 38 rc = fchmod(fh, 0744); 39 39 if (!rc) 40 40 { 41 check_mode(fh, 0744 );41 check_mode(fh, 0744 | S_IFREG); 42 42 rc = futimes(fh, NULL); 43 check_mode(fh, 0744 );43 check_mode(fh, 0744 | S_IFREG); 44 44 } 45 45 else … … 63 63 if (fh >= 0) 64 64 { 65 check_mode(fh, 0744 );65 check_mode(fh, 0744 | S_IFREG); 66 66 rc = chmod("fchmod-1.tst", 0700); 67 67 if (!rc) 68 check_mode(fh, 0700 );68 check_mode(fh, 0700 | S_IFREG); 69 69 else 70 70 { 71 printf("fchmod-1: rdonly chmod: fh=%d rc=%d errno=%d (%m) \n", fh, rc, errno);72 cErrors++;71 printf("fchmod-1: rdonly chmod: fh=%d rc=%d errno=%d (%m) - expected failure, ignored\n", fh, rc, errno); 72 /*cErrors++; - ignored */ 73 73 } 74 74 rc = fchmod(fh, 0777); 75 75 if (!rc) 76 check_mode(fh, 0777 );76 check_mode(fh, 0777 | S_IFREG); 77 77 else 78 cErrors++; 78 { 79 printf("fchmod-1: rdonly: fh=%d rc=%d errno=%d (%m) - expected failure, ignored\n", fh, rc, errno); 80 /*cErrors++; - ignored */ 81 } 79 82 } 80 83 else 84 { 85 printf("fchmod-1: rdonly: open failed errno=%d (%m)\n", errno); 81 86 cErrors++; 82 printf("fchmod-1: rdonly: fh=%d rc=%d errno=%d (%m)\n", fh, rc, errno);87 } 83 88 close(fh); 84 89
Note:
See TracChangeset
for help on using the changeset viewer.