Lines Matching refs:to_name

152 	const char *to_name;
339 to_name = argv[argc - 1];
340 no_target = stat(to_name, &to_sb);
343 if (lstat(to_name, &to_sb) != 0)
344 err(EX_OSERR, "%s vanished", to_name);
348 err(EX_USAGE, "%s", to_name);
350 install(*argv, to_name, fset, iflags);
354 for (; *argv != to_name; ++argv)
355 install(*argv, to_name, fset, iflags | DIRECTORY);
376 err(EX_OSERR, "%s", to_name);
381 "%s and %s are the same file", *argv, to_name);
383 install(*argv, to_name, fset, iflags);
517 do_link(const char *from_name, const char *to_name,
524 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
530 if (target_sb->st_mode & S_IFDIR && rmdir(to_name) ==
533 err(EX_OSERR, "%s", to_name);
536 (void)chflags(to_name, target_sb->st_flags &
538 unlink(to_name);
539 ret = rename(tmpl, to_name);
542 * file may still exist when from_name and to_name point
549 return (link(from_name, to_name));
557 do_symlink(const char *from_name, const char *to_name,
563 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
571 if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == -1) {
573 err(EX_OSERR, "%s", to_name);
576 (void)chflags(to_name, target_sb->st_flags &
578 unlink(to_name);
580 if (rename(tmpl, to_name) == -1) {
583 err(EX_OSERR, "%s: rename", to_name);
586 if (symlink(from_name, to_name) == -1)
587 err(EX_OSERR, "symlink %s -> %s", from_name, to_name);
596 makelink(const char *from_name, const char *to_name,
604 if (do_link(from_name, to_name, target_sb) == -1) {
606 err(EX_OSERR, "link %s -> %s", from_name, to_name);
608 if (stat(to_name, &to_sb))
609 err(EX_OSERR, "%s: stat", to_name);
637 metadata_log(to_name, "file", NULL, NULL,
654 do_symlink(src, to_name, target_sb);
656 metadata_log(to_name, "link", NULL, src, NULL, 0);
668 * The last component of to_name may be a symlink,
671 cp = dirname(to_name);
679 cp = basename(to_name);
696 do_symlink(lnk, to_name, target_sb);
698 metadata_log(to_name, "link", NULL, lnk, NULL, 0);
706 do_symlink(from_name, to_name, target_sb);
708 metadata_log(to_name, "link", NULL, from_name, NULL, 0);
716 install(const char *from_name, const char *to_name, u_long fset, u_int flags)
742 to_name,
744 to_name = pathbuf;
752 target = (stat(to_name, &to_sb) == 0);
754 target = (lstat(to_name, &to_sb) == 0);
758 if (to_sb.st_mode & S_IFDIR && rmdir(to_name) == -1)
759 err(EX_OSERR, "%s", to_name);
761 (void)chflags(to_name,
763 unlink(to_name);
765 makelink(from_name, to_name, target ? &to_sb : NULL);
772 warn("%s", to_name);
784 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0)
785 err(EX_OSERR, "%s", to_name);
791 to_name, (size_t)to_sb.st_size, &digestresult));
800 to_fd = create_tempfile(to_name, tempfile,
805 if ((to_fd = create_newfile(to_name, target,
807 err(EX_OSERR, "%s", to_name);
810 from_name, to_name);
814 tempcopy ? tempfile : to_name, from_sb.st_size);
820 strip(tempcopy ? tempfile : to_name);
827 to_fd = open(tempcopy ? tempfile : to_name, O_RDONLY, 0);
829 err(EX_OSERR, "stripping %s", to_name);
839 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0)
840 err(EX_OSERR, "%s", to_name);
850 to_name, (size_t)to_sb.st_size, &digestresult)
881 (void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS);
883 if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", to_name,
884 suffix) != strlen(to_name) + strlen(suffix)) {
887 to_name);
890 (void)printf("install: %s -> %s\n", to_name, backup);
891 if (rename(to_name, backup) < 0) {
895 err(EX_OSERR, "rename: %s to %s", to_name,
900 (void)printf("install: %s -> %s\n", from_name, to_name);
901 if (rename(tempfile, to_name) < 0) {
906 tempfile, to_name);
911 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0)
912 err(EX_OSERR, "%s", to_name);
923 (void)utimes(to_name, tvb);
928 (void)unlink(to_name);
930 err(EX_OSERR, "%s", to_name);
950 (void)unlink(to_name);
952 err(EX_OSERR,"%s: chown/chgrp", to_name);
959 (void)unlink(to_name);
961 err(EX_OSERR, "%s: chmod", to_name);
978 warn("%s: chflags", to_name);
981 (void)unlink(to_name);
983 err(EX_OSERR, "%s: chflags", to_name);
992 metadata_log(to_name, "file", tvb, NULL, digestresult, to_sb.st_size);
1002 int to_fd, const char *to_name __unused, size_t to_len,
1144 copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
1157 err(EX_OSERR, "lseek: %s", to_name);
1173 (void)unlink(to_name);
1177 to_name, (uintmax_t)nw, (uintmax_t)size);
1180 err(EX_OSERR, "%s", to_name);
1191 (void)unlink(to_name);
1195 to_name, (uintmax_t)nw,
1199 err(EX_OSERR, "%s", to_name);
1206 (void)unlink(to_name);
1219 strip(const char *to_name)
1227 (void)unlink(to_name);
1234 execlp(stripbin, stripbin, to_name, (char *)NULL);
1239 (void)unlink(to_name);