Lines Matching +defs:temp +defs:file

116  * Database of all file path accessed during a run.
120 char *file;
128 return strcmp(a->file, b->file);
137 filepath_add(struct filepath_tree *tree, char *file, int id, time_t mtime,
147 if ((fp->file = strdup(file)) == NULL)
153 free(fp->file);
166 * Lookup a file path in the tree and return the object if found or NULL.
169 filepath_find(struct filepath_tree *tree, char *file)
171 struct filepath needle = { .file = file };
177 * Returns true if file exists in the tree.
180 filepath_exists(struct filepath_tree *tree, char *file)
182 return filepath_find(tree, file) != NULL;
186 * Returns true if file exists and the id bit is set and ok flag is true.
189 filepath_valid(struct filepath_tree *tree, char *file, int id)
193 if ((fp = filepath_find(tree, file)) == NULL)
205 free((void *)fp->file);
273 repo_mkpath(int fd, char *file)
278 slash = strrchr(file, '/');
281 if (mkpathat(fd, file) == -1) {
282 warn("mkpath %s", file);
336 * Build TA file name based on the repo info.
337 * If temp is set add Xs for mkostemp.
342 const char *file;
346 file = strrchr(tr->uri[0], '/');
347 assert(file);
349 if (asprintf(&nfile, "%s%s", tr->basedir, file) == -1)
384 char *temp;
387 temp = ta_filename(tr);
388 fd = open(temp,
392 warn("open: %s", temp);
393 free(temp);
398 free(temp);
526 * Build local file name base on the URI and the rrdprepo info.
548 * Build RRDP state file name based on the repo info.
549 * If temp is set add Xs for mkostemp.
552 rrdp_state_filename(const struct rrdprepo *rr, int temp)
557 temp ? ".XXXXXXXX" : "") == -1)
651 * Parse the RRDP state file if it exists and set the session struct
661 char *line = NULL, *file;
671 file = rrdp_state_filename(rr, 0);
672 if ((fd = open(file, O_RDONLY)) == -1) {
674 warn("%s: open state file", rr->basedir);
675 free(file);
679 free(file);
695 warnx("%s: state file: serial is %s: %s",
703 warnx("%s: state file: last_reset is %s: %s",
716 warnx("%s: state file: too many deltas: %d",
728 warn("%s: error reading state file", rr->basedir);
760 * Carefully write the RRDP session state file back.
766 char *temp, *file;
774 file = rrdp_state_filename(rr, 0);
775 temp = rrdp_state_filename(rr, 1);
777 if ((fd = mkostemp(temp, O_CLOEXEC)) == -1)
784 /* write session state file out */
805 if (rename(temp, file) == -1) {
806 warn("%s: rename %s to %s", rr->basedir, temp, file);
807 unlink(temp);
810 free(temp);
811 free(file);
815 warn("%s: save state to %s", rr->basedir, temp);
818 unlink(temp);
819 free(temp);
820 free(file);
929 * Write a file into the temporary RRDP dir but only after checking
930 * its hash (if required). The function also makes sure that the file
951 /* check hash of original file for updates and deletes */
957 /* try to open file first in rrdp then in valid repo */
966 warnx("%s: bad file digest for %s", rr->notifyuri, fn);
983 /* add new file to rrdp dir */
1110 * Handle responses from the http process. For TA file, either rename
1111 * or delete the temporary file. For RRDP requests relay the request
1130 /* Move downloaded TA file into place, or unlink on failure. */
1485 repostats_new_files_inc(struct repo *rp, const char *file)
1487 if (strncmp(file, ".rsync/", strlen(".rsync/")) == 0 ||
1488 strncmp(file, ".rrdp/", strlen(".rrdp/")) == 0)
1637 * remove the file referenced by the URI.
1652 if (!rrdp_uri_valid(rr, fp->file)) {
1654 fp->file);
1658 /* try to remove file from rrdp repo ... */
1659 fn = rrdp_filename(rr, fp->file, 0);
1672 fn = rrdp_filename(rr, fp->file, 1);
1683 warnx("%s: referenced file supposed to be "
1707 if (strncmp(fp->file, ".rsync/", rsyncsz) != 0 &&
1708 strncmp(fp->file, ".rrdp/", rrdpsz) != 0 &&
1709 strncmp(fp->file, ".ta/", tasz) != 0)
1710 continue; /* not a temporary file path */
1712 if (strncmp(fp->file, ".rsync/", rsyncsz) == 0) {
1713 fn = fp->file + rsyncsz;
1714 } else if (strncmp(fp->file, ".ta/", tasz) == 0) {
1715 fn = fp->file + 1; /* just skip the '.' */
1717 base = strchr(fp->file + rrdpsz, '/');
1722 * Adjust file last modification time in order to
1736 ret = utimensat(AT_FDCWD, fp->file, ts, 0);
1738 warn("utimensat %s", fp->file);
1749 base = fp->file;
1750 if ((fp->file = strdup(fn)) == NULL)
1761 warnx("%s: file already present in "
1762 "validated cache", fp->file);
1764 free(fp->file);
1770 if (rename(base, fp->file) == -1)
1771 warn("rename to %s", fp->file);
1833 * If the file exists in the rrdp dir
1834 * that file is newer and needs to be kept
1835 * so unlink this file instead of moving
1836 * it over the file in the rrdp dir.
1962 /* first move temp files which have been used to valid dir */
2000 * Do not remove base directory itself and the .state file.