Changeset 2497 for branches/libc-0.6
- Timestamp:
- Dec 18, 2005, 12:25:44 PM (20 years ago)
- Location:
- branches/libc-0.6/src/emx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/libc-0.6/src/emx/ChangeLog.LIBC
r2496 r2497 5 5 2005-12-18: knut st. osmundsen <bird-gccos2-spam@anduin.net> 6 6 - libc: 7 o #24: Fixed chdir() crash in fts.c. 8 o #24: Fixed dirfd() problem in fts.c which prevent us from getting 9 any results in child directories. 7 10 o #22: Added DosFindFirst() as fallback when DosQueryPathInfo() fails 8 11 to query the symlink EA in the path resolver. This problem occurs -
branches/libc-0.6/src/emx/src/lib/bsd/gen/fts.c
r2496 r2497 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 }
Note:
See TracChangeset
for help on using the changeset viewer.