Lines Matching defs:to_name
185 char *p, *to_name;
397 no_target = stat(to_name = argv[argc - 1], &to_sb);
399 for (; *argv != to_name; ++argv)
400 install(*argv, to_name, iflags | DIRECTORY);
417 errx(EXIT_FAILURE, "%s: not a regular file", to_name);
421 to_name);
431 (void)chflags(to_name,
435 backup(to_name);
437 (void)unlink(to_name);
439 install(*argv, to_name, iflags);
465 do_link(char *from_name, char *to_name)
471 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
477 ret = rename(tmpl, to_name);
479 * file may still exist when from_name and to_name point
485 ret = link(from_name, to_name);
488 (void)printf("install: link %s -> %s\n", from_name, to_name);
498 do_symlink(char *from_name, char *to_name)
503 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
510 if (rename(tmpl, to_name) == -1) {
513 err(EXIT_FAILURE, "%s: rename", to_name);
516 if (symlink(from_name, to_name) == -1)
517 err(EXIT_FAILURE, "symlink %s -> %s", from_name, to_name);
520 (void)printf("install: symlink %s -> %s\n", from_name, to_name);
528 makelink(char *from_name, char *to_name)
535 if (do_link(from_name, to_name) == -1) {
537 err(EXIT_FAILURE, "link %s -> %s", from_name, to_name);
539 if (stat(to_name, &to_sb))
540 err(EXIT_FAILURE, "%s: stat", to_name);
587 metadata_log(to_name, "file", NULL, NULL,
604 do_symlink(src, to_name);
606 metadata_log(to_name, "link", NULL, src, NULL, 0);
618 * The last component of to_name may be a symlink,
621 cp = xdirname(to_name);
629 cp = xbasename(to_name);
646 do_symlink(lnk, to_name);
648 metadata_log(to_name, "link", NULL, lnk, NULL, 0);
656 do_symlink(from_name, to_name);
658 metadata_log(to_name, "link", NULL, from_name, NULL, 0);
666 install(char *from_name, char *to_name, u_int flags)
701 to_name,
703 to_name = pathbuf;
719 if (stat(to_name, &to_sb) == 0 &&
721 (void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));
724 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
725 oto_name = to_name;
726 to_name = tmpl;
730 backup(to_name);
732 (void)unlink(to_name);
736 makelink(from_name, dorename ? oto_name : to_name);
742 if ((to_fd = mkstemp(to_name)) == -1)
743 err(EXIT_FAILURE, "%s: mkstemp", to_name);
745 if ((to_fd = open(to_name,
747 err(EXIT_FAILURE, "%s: open", to_name);
752 (void)unlink(to_name);
756 copy(from_fd, from_name, to_fd, to_name, from_sb.st_size);
761 strip(to_name);
768 if ((to_fd = open(to_name, O_RDONLY, S_IRUSR | S_IWUSR)) < 0)
769 err(EXIT_FAILURE, "stripping %s", to_name);
775 err(EXIT_FAILURE, "%s: fstat", to_name);
778 copy(to_fd, to_name, -1, NULL, size);
783 afterinstall(afterinstallcmd, to_name, 1);
790 if ((to_fd = open(to_name, O_RDONLY, S_IRUSR | S_IWUSR)) < 0)
791 err(EXIT_FAILURE, "running after install command on %s", to_name);
801 (void)unlink(to_name);
802 errc(EXIT_FAILURE, serrno, "%s: chown/chgrp", to_name);
809 (void)unlink(to_name);
810 errc(EXIT_FAILURE, serrno, "%s: chmod", to_name);
819 warn("%s: futimes", to_name);
821 if (utimes(to_name, tv) == -1)
822 warn("%s: utimes", to_name);
829 if (rename(to_name, oto_name) == -1)
830 err(EXIT_FAILURE, "%s: rename", to_name);
831 to_name = oto_name;
834 (void)printf("install: %s -> %s\n", from_name, to_name);
841 if (!dounpriv && chflags(to_name,
845 warn("%s: chflags", to_name);
849 metadata_log(to_name, "file", tv, NULL, digestresult, size);
860 copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size)
925 (void)unlink(to_name);
927 to_name);
958 (void)unlink(to_name);
961 "%s: write", to_name);
988 (void)unlink(to_name);
1013 run(const char *command, const char *flags, const char *to_name, int errunlink)
1026 flags ? " " : "", to_name);
1034 cmd = __UNCONST(to_name);
1058 (void)unlink(to_name);
1084 if (cmd != to_name)
1088 (void)unlink(to_name);
1096 strip(const char *to_name)
1107 run(stripprog, stripArgs, to_name, 1);
1116 afterinstall(const char *command, const char *to_name, int errunlink)
1118 run(command, NULL, to_name, errunlink);
1123 * backup file "to_name" to to_name.suffix
1128 backup(const char *to_name)
1141 (void)snprintf(bname, FILENAME_MAX, "%s%s", to_name,
1147 (void)snprintf(bname, FILENAME_MAX, "%s%s", to_name, suffix);
1150 if (rename(to_name, bname) == 0) {
1152 (void)printf("install: %s -> %s\n", to_name, bname);