Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/xinstall/xinstall.c
Show First 20 Lines • Show All 530 Lines • ▼ Show 20 Lines | if (ret == 0) { | ||||
err(EX_OSERR, "%s", to_name); | err(EX_OSERR, "%s", to_name); | ||||
} | } | ||||
if (target_sb->st_flags & NOCHANGEBITS) | if (target_sb->st_flags & NOCHANGEBITS) | ||||
(void)chflags(to_name, target_sb->st_flags & | (void)chflags(to_name, target_sb->st_flags & | ||||
~NOCHANGEBITS); | ~NOCHANGEBITS); | ||||
if (verbose) | if (verbose) | ||||
printf("install: link %s -> %s\n", | printf("install: link %s -> %s\n", | ||||
from_name, to_name); | from_name, to_name); | ||||
unlink(to_name); | |||||
ret = rename(tmpl, to_name); | ret = rename(tmpl, to_name); | ||||
/* | /* | ||||
* If rename has posix semantics, then the temporary | * If rename has posix semantics, then the temporary | ||||
* file may still exist when from_name and to_name point | * file may still exist when from_name and to_name point | ||||
* to the same file, so unlink it unconditionally. | * to the same file, so unlink it unconditionally. | ||||
*/ | */ | ||||
(void)unlink(tmpl); | (void)unlink(tmpl); | ||||
} | } | ||||
Show All 27 Lines | if (safecopy && target_sb != NULL) { | ||||
if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == -1) { | if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == -1) { | ||||
(void)unlink(tmpl); | (void)unlink(tmpl); | ||||
err(EX_OSERR, "%s", to_name); | err(EX_OSERR, "%s", to_name); | ||||
} | } | ||||
if (target_sb->st_flags & NOCHANGEBITS) | if (target_sb->st_flags & NOCHANGEBITS) | ||||
(void)chflags(to_name, target_sb->st_flags & | (void)chflags(to_name, target_sb->st_flags & | ||||
~NOCHANGEBITS); | ~NOCHANGEBITS); | ||||
unlink(to_name); | |||||
if (verbose) | if (verbose) | ||||
printf("install: symlink %s -> %s\n", | printf("install: symlink %s -> %s\n", | ||||
from_name, to_name); | from_name, to_name); | ||||
if (rename(tmpl, to_name) == -1) { | if (rename(tmpl, to_name) == -1) { | ||||
/* Remove temporary link before exiting. */ | /* Remove temporary link before exiting. */ | ||||
(void)unlink(tmpl); | (void)unlink(tmpl); | ||||
err(EX_OSERR, "%s: rename", to_name); | err(EX_OSERR, "%s: rename", to_name); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 851 Lines • Show Last 20 Lines |