Lines Matching +full:look +full:- +full:up

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
69 static int dirfd = -1; /* storage for setting created dir time/mode */
71 static int ffd = -1; /* tmp file for file time table name storage */
95 * 0 if created, -1 if failure
105 return(-1); in lnk_start()
112 * Looks up entry in hard link hash table. If found, it copies the name
119 * if found returns 1; if not found returns 0; -1 on error
130 return(-1); in chk_lnk()
134 if ((arcn->type == PAX_DIR) || (arcn->sb.st_nlink <= 1)) in chk_lnk()
138 * hash inode number and look for this file in chk_lnk()
140 indx = ((unsigned)arcn->sb.st_ino) % L_TAB_SZ; in chk_lnk()
147 if ((pt->ino == arcn->sb.st_ino) && in chk_lnk()
148 (pt->dev == arcn->sb.st_dev)) in chk_lnk()
150 ppt = &(pt->fow); in chk_lnk()
151 pt = pt->fow; in chk_lnk()
161 arcn->ln_nlen = l_strncpy(arcn->ln_name, pt->name, in chk_lnk()
162 sizeof(arcn->ln_name) - 1); in chk_lnk()
163 arcn->ln_name[arcn->ln_nlen] = '\0'; in chk_lnk()
164 if (arcn->type == PAX_REG) in chk_lnk()
165 arcn->type = PAX_HRG; in chk_lnk()
167 arcn->type = PAX_HLK; in chk_lnk()
173 if (--pt->nlink <= 1) { in chk_lnk()
174 *ppt = pt->fow; in chk_lnk()
175 free(pt->name); in chk_lnk()
187 if ((pt->name = strdup(arcn->name)) != NULL) { in chk_lnk()
188 pt->dev = arcn->sb.st_dev; in chk_lnk()
189 pt->ino = arcn->sb.st_ino; in chk_lnk()
190 pt->nlink = arcn->sb.st_nlink; in chk_lnk()
191 pt->fow = ltab[indx]; in chk_lnk()
199 return(-1); in chk_lnk()
205 * a potential source for hard links. We ended up not using the file, so
219 * do not bother to look if it could not be in the database in purg_lnk()
221 if ((arcn->sb.st_nlink <= 1) || (arcn->type == PAX_DIR) || in purg_lnk()
222 (arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) in purg_lnk()
228 indx = ((unsigned)arcn->sb.st_ino) % L_TAB_SZ; in purg_lnk()
238 if ((pt->ino == arcn->sb.st_ino) && in purg_lnk()
239 (pt->dev == arcn->sb.st_dev)) in purg_lnk()
241 ppt = &(pt->fow); in purg_lnk()
242 pt = pt->fow; in purg_lnk()
250 *ppt = pt->fow; in purg_lnk()
251 free(pt->name); in purg_lnk()
280 * free up each entry on this chain in lnk_end()
284 pt = ppt->fow; in lnk_end()
285 free(ppt->name); in lnk_end()
296 * files stored in an archive during a write phase when -u is set. We only
300 * An append with an -u must read the archive and store the modification time
309 * looked up more than once...). So caching is just a waste of memory. The
320 * 0 if the table and file was created ok, -1 otherwise
331 return(-1); in ftime_start()
342 return(-1); in ftime_start()
351 * looks up entry in file time hash table. If not found, the file is
358 * -1 on error
376 * hash the pathname and look up in table in chk_ftime()
378 namelen = arcn->nlen; in chk_ftime()
379 indx = st_hash(arcn->name, namelen, F_TAB_SZ); in chk_ftime()
383 * only read up the path names if the lengths match, speeds in chk_ftime()
384 * up the search a lot in chk_ftime()
387 if (pt->namelen == namelen) { in chk_ftime()
392 if (lseek(ffd,pt->seek,SEEK_SET) != pt->seek) { in chk_ftime()
395 return(-1); in chk_ftime()
400 return(-1); in chk_ftime()
406 if (!strncmp(ckname, arcn->name, namelen)) in chk_ftime()
413 pt = pt->fow; in chk_ftime()
420 if (arcn->sb.st_mtime > pt->mtime) { in chk_ftime()
424 pt->mtime = arcn->sb.st_mtime; in chk_ftime()
442 if ((pt->seek = lseek(ffd, (off_t)0, SEEK_END)) >= 0) { in chk_ftime()
443 if (write(ffd, arcn->name, namelen) == namelen) { in chk_ftime()
444 pt->mtime = arcn->sb.st_mtime; in chk_ftime()
445 pt->namelen = namelen; in chk_ftime()
446 pt->fow = ftab[indx]; in chk_ftime()
458 return(-1); in chk_ftime()
477 * 0 if successful, -1 otherwise
487 return(-1); in name_start()
498 * 0 if added, -1 otherwise
516 * look to see if we have already mapped this file, if so we in add_name()
522 * look down the has chain for the file in add_name()
524 while ((pt != NULL) && (strcmp(oname, pt->oname) != 0)) in add_name()
525 pt = pt->fow; in add_name()
532 if (strcmp(nname, pt->nname) == 0) in add_name()
535 free(pt->nname); in add_name()
536 if ((pt->nname = strdup(nname)) == NULL) { in add_name()
538 return(-1); in add_name()
548 if ((pt->oname = strdup(oname)) != NULL) { in add_name()
549 if ((pt->nname = strdup(nname)) != NULL) { in add_name()
550 pt->fow = ntab[indx]; in add_name()
554 free(pt->oname); in add_name()
559 return(-1); in add_name()
564 * look up a link name to see if it points at a file that has been
578 * look the name up in the hash table in sub_name()
588 if (strcmp(oname, pt->oname) == 0) { in sub_name()
593 *onamelen = l_strncpy(oname, pt->nname, onamesize - 1); in sub_name()
597 pt = pt->fow; in sub_name()
631 * which can be truncated. This really can foul up an archive. With truncation
632 * we end up creating links between files that are really not links (after
650 * 0 if successful, -1 otherwise
660 return(-1); in dev_start()
672 * 0 if added ok, -1 otherwise
678 if (chk_dev(arcn->sb.st_dev, 1) == NULL) in add_dev()
679 return(-1); in add_dev()
705 * look to see if this device is already in the table in chk_dev()
709 while ((pt != NULL) && (pt->dev != dev)) in chk_dev()
710 pt = pt->fow; in chk_dev()
728 * chain. Note we do not assign remaps values here, so the pt->list in chk_dev()
735 pt->dev = dev; in chk_dev()
736 pt->list = NULL; in chk_dev()
737 pt->fow = dtab[indx]; in chk_dev()
751 * 0 if all ok, -1 otherwise.
771 if ((arcn->sb.st_dev & (dev_t)dev_mask) != arcn->sb.st_dev) in map_dev()
773 if ((nino = arcn->sb.st_ino & (ino_t)ino_mask) != arcn->sb.st_ino) { in map_dev()
775 trunc_bits = arcn->sb.st_ino & (ino_t)(~ino_mask); in map_dev()
779 * see if this device is already being mapped, look up the device in map_dev()
782 if ((pt = chk_dev(arcn->sb.st_dev, 0)) != NULL) { in map_dev()
786 for (dpt = pt->list; dpt != NULL; dpt = dpt->fow) in map_dev()
787 if (dpt->trunc_bits == trunc_bits) in map_dev()
795 arcn->sb.st_dev = dpt->dev; in map_dev()
796 arcn->sb.st_ino = nino; in map_dev()
810 if ((pt = chk_dev(arcn->sb.st_dev, 1)) == NULL) in map_dev()
825 dpt->trunc_bits = 0; in map_dev()
826 dpt->dev = arcn->sb.st_dev; in map_dev()
827 dpt->fow = pt->list; in map_dev()
828 pt->list = dpt; in map_dev()
833 * look for a device number not being used. We must watch for wrap in map_dev()
841 * for this format we are hosed, so we give up. Otherwise we in map_dev()
857 dpt->trunc_bits = trunc_bits; in map_dev()
858 dpt->dev = lastdev; in map_dev()
859 dpt->fow = pt->list; in map_dev()
860 pt->list = dpt; in map_dev()
861 arcn->sb.st_dev = lastdev; in map_dev()
862 arcn->sb.st_ino = nino; in map_dev()
867 arcn->name); in map_dev()
875 * The pax -t flag requires that access times of archive files be the same
881 * and modification times are stored during the fts pre-order visit (done
883 * fts post-order visit (after all the descendants have been visited). In the
884 * case of premature exit from a subtree (like from the effects of -n), any
893 * 0 is created ok, -1 otherwise.
903 return(-1); in atdir_start()
925 * for each non-empty hash table entry reset all the directories in atdir_end()
934 * not read by pax. Read time reset is controlled by -t. in atdir_end()
936 for (; pt != NULL; pt = pt->fow) in atdir_end()
937 set_ftime(pt->name, pt->mtime, pt->atime, 1); in atdir_end()
960 * different args to pax and the -n option is aborting fts out of a in add_atdir()
961 * subtree before all the post-order visits have been made. in add_atdir()
966 if ((pt->ino == ino) && (pt->dev == dev)) in add_atdir()
968 pt = pt->fow; in add_atdir()
982 if ((pt->name = strdup(fname)) != NULL) { in add_atdir()
983 pt->dev = dev; in add_atdir()
984 pt->ino = ino; in add_atdir()
985 pt->mtime = mtime; in add_atdir()
986 pt->atime = atime; in add_atdir()
987 pt->fow = atab[indx]; in add_atdir()
1000 * look up a directory by inode and device number to obtain the access
1006 * 0 if found, -1 if not found.
1017 return(-1); in get_atdir()
1023 return(-1); in get_atdir()
1027 if ((pt->ino == ino) && (pt->dev == dev)) in get_atdir()
1032 ppt = &(pt->fow); in get_atdir()
1033 pt = pt->fow; in get_atdir()
1040 return(-1); in get_atdir()
1045 *ppt = pt->fow; in get_atdir()
1046 *mtime = pt->mtime; in get_atdir()
1047 *atime = pt->atime; in get_atdir()
1048 free(pt->name); in get_atdir()
1059 * actions of extracting (and creating the destination subtree during -rw copy)
1078 * set up the directory time and file mode storage for directories CREATED
1081 * 0 if ok, -1 otherwise
1088 if (dirfd != -1) in dir_start()
1101 return(-1); in dir_start()
1138 dblk.mode = psb->st_mode & 0xffff; in add_dir()
1139 dblk.mtime = psb->st_mtime; in add_dir()
1140 dblk.atime = psb->st_atime; in add_dir()
1173 * just give up. in proc_dir()
1175 if (lseek(dirfd, -((off_t)sizeof(dblk)), SEEK_CUR) < 0) in proc_dir()
1197 dirfd = -1; in proc_dir()
1234 * only look at the tail up to MAXKEYLEN, we do not need to waste in st_hash()
1239 pt = &(name[len - MAXKEYLEN]); in st_hash()
1252 * add up the value of the string in unsigned integer sized pieces in st_hash()