fts-compat.c (17141) | fts-compat.c (23668) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) | 1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) |
35static char sccsid[] = "@(#)fts.c 8.4 (Berkeley) 4/16/94"; | 35static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; |
36#endif /* LIBC_SCCS and not lint */ 37 38#include <sys/param.h> 39#include <sys/stat.h> 40 41#include <dirent.h> 42#include <errno.h> 43#include <fcntl.h> --- 507 unchanged lines hidden (view full) --- 551 int type; 552{ 553 register struct dirent *dp; 554 register FTSENT *p, *head; 555 register int nitems; 556 FTSENT *cur, *tail; 557 DIR *dirp; 558 void *adjaddr; | 36#endif /* LIBC_SCCS and not lint */ 37 38#include <sys/param.h> 39#include <sys/stat.h> 40 41#include <dirent.h> 42#include <errno.h> 43#include <fcntl.h> --- 507 unchanged lines hidden (view full) --- 551 int type; 552{ 553 register struct dirent *dp; 554 register FTSENT *p, *head; 555 register int nitems; 556 FTSENT *cur, *tail; 557 DIR *dirp; 558 void *adjaddr; |
559 int cderrno, descend, len, level, maxlen, nlinks, saved_errno; | 559 int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno; |
560 char *cp; 561 562 /* Set current node pointer. */ 563 cur = sp->fts_cur; 564 565 /* 566 * Open the directory for reading. If this fails, we're done. 567 * If being called from fts_read, set the fts_info field. 568 */ | 560 char *cp; 561 562 /* Set current node pointer. */ 563 cur = sp->fts_cur; 564 565 /* 566 * Open the directory for reading. If this fails, we're done. 567 * If being called from fts_read, set the fts_info field. 568 */ |
569 if ((dirp = opendir(cur->fts_accpath)) == NULL) { | 569#ifdef FTS_WHITEOUT 570 if (ISSET(FTS_WHITEOUT)) 571 oflag = DTF_NODUP|DTF_REWIND; 572 else 573 oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; 574#else 575#define __opendir2(path, flag) opendir(path) 576#endif 577 if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { |
570 if (type == BREAD) { 571 cur->fts_info = FTS_DNR; 572 cur->fts_errno = errno; 573 } 574 return (NULL); 575 } 576 577 /* --- 88 unchanged lines hidden (view full) --- 666 adjaddr = sp->fts_path; 667 maxlen = sp->fts_pathlen - sp->fts_cur->fts_pathlen - 1; 668 } 669 670 p->fts_pathlen = len + dp->d_namlen + 1; 671 p->fts_parent = sp->fts_cur; 672 p->fts_level = level; 673 | 578 if (type == BREAD) { 579 cur->fts_info = FTS_DNR; 580 cur->fts_errno = errno; 581 } 582 return (NULL); 583 } 584 585 /* --- 88 unchanged lines hidden (view full) --- 674 adjaddr = sp->fts_path; 675 maxlen = sp->fts_pathlen - sp->fts_cur->fts_pathlen - 1; 676 } 677 678 p->fts_pathlen = len + dp->d_namlen + 1; 679 p->fts_parent = sp->fts_cur; 680 p->fts_level = level; 681 |
682#ifdef FTS_WHITEOUT 683 if (dp->d_type == DT_WHT) 684 p->fts_flags |= FTS_ISW; 685#endif 686 |
|
674 if (cderrno) { 675 if (nlinks) { 676 p->fts_info = FTS_NS; 677 p->fts_errno = cderrno; 678 } else 679 p->fts_info = FTS_NSOK; 680 p->fts_accpath = cur->fts_accpath; 681 } else if (nlinks == 0 --- 88 unchanged lines hidden (view full) --- 770 register dev_t dev; 771 register ino_t ino; 772 struct stat *sbp, sb; 773 int saved_errno; 774 775 /* If user needs stat info, stat buffer already allocated. */ 776 sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; 777 | 687 if (cderrno) { 688 if (nlinks) { 689 p->fts_info = FTS_NS; 690 p->fts_errno = cderrno; 691 } else 692 p->fts_info = FTS_NSOK; 693 p->fts_accpath = cur->fts_accpath; 694 } else if (nlinks == 0 --- 88 unchanged lines hidden (view full) --- 783 register dev_t dev; 784 register ino_t ino; 785 struct stat *sbp, sb; 786 int saved_errno; 787 788 /* If user needs stat info, stat buffer already allocated. */ 789 sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; 790 |
791#ifdef FTS_WHITEOUT 792 /* check for whiteout */ 793 if (p->fts_flags & FTS_ISW) { 794 if (sbp != &sb) { 795 memset(sbp, '\0', sizeof (*sbp)); 796 sbp->st_mode = S_IFWHT; 797 } 798 return (FTS_W); 799 } 800#endif 801 |
|
778 /* 779 * If doing a logical walk, or application requested FTS_FOLLOW, do 780 * a stat(2). If that fails, check for a non-existent symlink. If 781 * fail, set the errno from the stat call. 782 */ 783 if (ISSET(FTS_LOGICAL) || follow) { 784 if (stat(p->fts_accpath, sbp)) { 785 saved_errno = errno; --- 186 unchanged lines hidden --- | 802 /* 803 * If doing a logical walk, or application requested FTS_FOLLOW, do 804 * a stat(2). If that fails, check for a non-existent symlink. If 805 * fail, set the errno from the stat call. 806 */ 807 if (ISSET(FTS_LOGICAL) || follow) { 808 if (stat(p->fts_accpath, sbp)) { 809 saved_errno = errno; --- 186 unchanged lines hidden --- |