Lines Matching refs:to_name

170 	const char *to_name;  in main()  local
366 to_name = argv[argc - 1]; in main()
367 no_target = stat(to_name, &to_sb); in main()
370 if (lstat(to_name, &to_sb) != 0) in main()
371 err(EX_OSERR, "%s vanished", to_name); in main()
375 to_name); in main()
377 install(*argv, to_name, fset, iflags); in main()
381 for (; *argv != to_name; ++argv) in main()
382 install(*argv, to_name, fset, iflags | DIRECTORY); in main()
402 errc(EX_CANTCREAT, EFTYPE, "%s", to_name); in main()
406 *argv, to_name); in main()
409 install(*argv, to_name, fset, iflags); in main()
559 do_link(const char *from_name, const char *to_name, in do_link() argument
566 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name); in do_link()
572 if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == in do_link()
575 err(EX_OSERR, "%s", to_name); in do_link()
579 (void)chflags(to_name, target_sb->st_flags & in do_link()
584 from_name, to_name); in do_link()
585 ret = rename(tmpl, to_name); in do_link()
597 from_name, to_name); in do_link()
598 return (link(from_name, to_name)); in do_link()
607 do_symlink(const char *from_name, const char *to_name, in do_symlink() argument
613 (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name); in do_symlink()
621 if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == -1) { in do_symlink()
623 err(EX_OSERR, "%s", to_name); in do_symlink()
627 (void)chflags(to_name, target_sb->st_flags & in do_symlink()
632 from_name, to_name); in do_symlink()
633 if (rename(tmpl, to_name) == -1) { in do_symlink()
636 err(EX_OSERR, "%s: rename", to_name); in do_symlink()
641 from_name, to_name); in do_symlink()
642 if (symlink(from_name, to_name) == -1) in do_symlink()
643 err(EX_OSERR, "symlink %s -> %s", from_name, to_name); in do_symlink()
652 makelink(const char *from_name, const char *to_name, in makelink() argument
662 if (do_link(from_name, to_name, target_sb) == -1) { in makelink()
664 err(EX_OSERR, "link %s -> %s", from_name, to_name); in makelink()
666 if (stat(to_name, &to_sb)) in makelink()
667 err(EX_OSERR, "%s: stat", to_name); in makelink()
695 metadata_log(to_name, "file", NULL, NULL, in makelink()
712 do_symlink(src, to_name, target_sb); in makelink()
714 metadata_log(to_name, "link", NULL, src, NULL, 0); in makelink()
721 do_symlink(from_name, to_name, target_sb); in makelink()
723 metadata_log(to_name, "link", NULL, from_name, NULL, 0); in makelink()
735 to_name_copy = strdup(to_name); in makelink()
737 err(EX_OSERR, "%s: strdup", to_name); in makelink()
782 do_symlink(lnk, to_name, target_sb); in makelink()
784 metadata_log(to_name, "link", NULL, lnk, NULL, 0); in makelink()
792 do_symlink(from_name, to_name, target_sb); in makelink()
794 metadata_log(to_name, "link", NULL, from_name, NULL, 0); in makelink()
802 install(const char *from_name, const char *to_name, u_long fset, u_int flags) in install() argument
827 to_name, in install()
828 to_name[strlen(to_name) - 1] == '/' ? "" : "/", in install()
830 to_name = pathbuf; in install()
836 if (*to_name == '\0') in install()
839 target = (lstat(to_name, &to_sb) == 0); in install()
842 makelink(from_name, to_name, target ? &to_sb : NULL); in install()
847 errc(EX_CANTCREAT, EFTYPE, "%s", to_name); in install()
854 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0) in install()
855 err(EX_OSERR, "%s", to_name); in install()
861 to_name, (size_t)to_sb.st_size, &digestresult)); in install()
869 to_fd = create_tempfile(to_name, tempfile, in install()
896 err(EX_OSERR, "stripping %s", to_name); in install()
906 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0) in install()
907 err(EX_OSERR, "%s", to_name); in install()
917 to_name, (size_t)to_sb.st_size, &digestresult) in install()
945 (void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS); in install()
948 if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", to_name, in install()
949 suffix) != strlen(to_name) + strlen(suffix)) { in install()
952 to_name); in install()
955 (void)printf("install: %s -> %s\n", to_name, backup); in install()
960 (void)chflags(to_name, to_sb.st_flags); in install()
966 if (link(to_name, backup) < 0) { in install()
971 (void)chflags(to_name, to_sb.st_flags); in install()
974 err(EX_OSERR, "link: %s to %s", to_name, in install()
979 (void)printf("install: %s -> %s\n", from_name, to_name); in install()
980 if (rename(tempfile, to_name) < 0) { in install()
985 tempfile, to_name); in install()
990 if ((to_fd = open(to_name, O_RDONLY, 0)) < 0) in install()
991 err(EX_OSERR, "%s", to_name); in install()
1000 (void)utimensat(AT_FDCWD, to_name, tsb, 0); in install()
1005 (void)unlink(to_name); in install()
1007 err(EX_OSERR, "%s", to_name); in install()
1028 (void)unlink(to_name); in install()
1030 err(EX_OSERR,"%s: chown/chgrp", to_name); in install()
1037 (void)unlink(to_name); in install()
1039 err(EX_OSERR, "%s: chmod", to_name); in install()
1056 warn("%s: chflags", to_name); in install()
1059 (void)unlink(to_name); in install()
1061 err(EX_OSERR, "%s: chflags", to_name); in install()
1071 metadata_log(to_name, "file", tsb, NULL, digestresult, to_sb.st_size); in install()
1083 int to_fd, const char *to_name __unused, size_t to_len, in compare()
1178 copy(int from_fd, const char *from_name, int to_fd, const char *to_name, in copy() argument
1194 err(EX_OSERR, "lseek: %s", to_name); in copy()
1207 (void)unlink(to_name); in copy()
1209 err(EX_OSERR, "%s", to_name); in copy()
1233 (void)unlink(to_name); in copy()
1238 to_name, (uintmax_t)nw, in copy()
1242 err(EX_OSERR, "%s", to_name); in copy()
1249 (void)unlink(to_name); in copy()
1258 (void)unlink(to_name); in copy()
1260 err(EX_OSERR, "fsync failed for %s", to_name); in copy()
1274 strip(const char *to_name, int to_fd, const char *from_name, char **dresp) in strip() argument
1288 args[1] = to_name; in strip()
1292 args[2] = to_name; in strip()
1307 (void)unlink(to_name); in strip()
1314 (void)unlink(to_name); in strip()
1321 (void)unlink(to_name); in strip()
1323 stripbin, to_name); in strip()
1327 (void)unlink(to_name); in strip()
1329 err(EX_OSERR, "fsync failed for %s", to_name); in strip()
1332 *dresp = digest_file(to_name); in strip()