Lines Matching defs:to_name

150 	const char *to_name;
338 to_name = argv[argc - 1];
339 no_target = stat(to_name, &to_sb);
342 if (lstat(to_name, &to_sb) != 0)
343 err(EX_OSERR, "%s vanished", to_name);
347 err(EX_USAGE, "%s", to_name);
349 install(*argv, to_name, fset, iflags);
353 for (; *argv != to_name; ++argv)
354 install(*argv, to_name, fset, iflags | DIRECTORY);
375 err(EX_OSERR, "%s", to_name);
380 "%s and %s are the same file", *argv, to_name);
382 install(*argv, to_name, fset, iflags);
516 do_link(const char *from_name, const char *to_name,
523 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
529 if (target_sb->st_mode & S_IFDIR && rmdir(to_name) ==
532 err(EX_OSERR, "%s", to_name);
535 (void)chflags(to_name, target_sb->st_flags &
539 from_name, to_name);
540 ret = rename(tmpl, to_name);
543 * file may still exist when from_name and to_name point
552 from_name, to_name);
553 return (link(from_name, to_name));
562 do_symlink(const char *from_name, const char *to_name,
568 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
576 if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == -1) {
578 err(EX_OSERR, "%s", to_name);
581 (void)chflags(to_name, target_sb->st_flags &
585 from_name, to_name);
586 if (rename(tmpl, to_name) == -1) {
589 err(EX_OSERR, "%s: rename", to_name);
594 from_name, to_name);
595 if (symlink(from_name, to_name) == -1)
596 err(EX_OSERR, "symlink %s -> %s", from_name, to_name);
605 makelink(const char *from_name, const char *to_name,
613 if (do_link(from_name, to_name, target_sb) == -1) {
615 err(EX_OSERR, "link %s -> %s", from_name, to_name);
617 if (stat(to_name, &to_sb))
618 err(EX_OSERR, "%s: stat", to_name);
646 metadata_log(to_name, "file", NULL, NULL,
663 do_symlink(src, to_name, target_sb);
665 metadata_log(to_name, "link", NULL, src, NULL, 0);
674 do_symlink(from_name, to_name, target_sb);
676 metadata_log(to_name, "link", NULL, from_name, NULL, 0);
685 * The last component of to_name may be a symlink,
688 cp = dirname(to_name);
696 cp = basename(to_name);
713 do_symlink(lnk, to_name, target_sb);
715 metadata_log(to_name, "link", NULL, lnk, NULL, 0);
723 do_symlink(from_name, to_name, target_sb);
725 metadata_log(to_name, "link", NULL, from_name, NULL, 0);
733 install(const char *from_name, const char *to_name, u_long fset, u_int flags)
759 to_name,
761 to_name = pathbuf;
768 target = (lstat(to_name, &to_sb) == 0);
772 if (to_sb.st_mode & S_IFDIR && rmdir(to_name) == -1)
773 err(EX_OSERR, "%s", to_name);
775 (void)chflags(to_name,
777 unlink(to_name);
779 makelink(from_name, to_name, target ? &to_sb : NULL);
785 warn("%s", to_name);
797 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0)
798 err(EX_OSERR, "%s", to_name);
804 to_name, (size_t)to_sb.st_size, &digestresult));
813 to_fd = create_tempfile(to_name, tempfile,
818 if ((to_fd = create_newfile(to_name, target,
820 err(EX_OSERR, "%s", to_name);
823 from_name, to_name);
827 tempcopy ? tempfile : to_name, from_sb.st_size);
833 strip(tempcopy ? tempfile : to_name);
840 to_fd = open(tempcopy ? tempfile : to_name, O_RDONLY, 0);
842 err(EX_OSERR, "stripping %s", to_name);
852 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0)
853 err(EX_OSERR, "%s", to_name);
863 to_name, (size_t)to_sb.st_size, &digestresult)
890 (void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS);
892 if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", to_name,
893 suffix) != strlen(to_name) + strlen(suffix)) {
896 to_name);
899 (void)printf("install: %s -> %s\n", to_name, backup);
903 (void)chflags(to_name, to_sb.st_flags);
908 if (link(to_name, backup) < 0) {
912 (void)chflags(to_name, to_sb.st_flags);
914 err(EX_OSERR, "link: %s to %s", to_name,
919 (void)printf("install: %s -> %s\n", from_name, to_name);
920 if (rename(tempfile, to_name) < 0) {
925 tempfile, to_name);
930 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0)
931 err(EX_OSERR, "%s", to_name);
940 (void)utimensat(AT_FDCWD, to_name, tsb, 0);
945 (void)unlink(to_name);
947 err(EX_OSERR, "%s", to_name);
967 (void)unlink(to_name);
969 err(EX_OSERR,"%s: chown/chgrp", to_name);
976 (void)unlink(to_name);
978 err(EX_OSERR, "%s: chmod", to_name);
995 warn("%s: chflags", to_name);
998 (void)unlink(to_name);
1000 err(EX_OSERR, "%s: chflags", to_name);
1009 metadata_log(to_name, "file", tsb, NULL, digestresult, to_sb.st_size);
1019 int to_fd, const char *to_name __unused, size_t to_len,
1171 copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
1185 err(EX_OSERR, "lseek: %s", to_name);
1201 (void)unlink(to_name);
1205 to_name, (uintmax_t)nw, (uintmax_t)size);
1208 err(EX_OSERR, "%s", to_name);
1219 (void)unlink(to_name);
1223 to_name, (uintmax_t)nw,
1227 err(EX_OSERR, "%s", to_name);
1234 (void)unlink(to_name);
1247 strip(const char *to_name)
1258 args[1] = to_name;
1263 (void)unlink(to_name);
1269 (void)unlink(to_name);
1274 (void)unlink(to_name);
1276 stripbin, to_name);