Allow symlinks to be created if they appear in the mtree specification.

PR:	bin/14171
This commit is contained in:
Josef Karthauser 2000-07-13 22:28:39 +00:00
parent 0f4a1f9b5c
commit 94401addc5
2 changed files with 20 additions and 5 deletions

View File

@ -109,7 +109,7 @@ was specified.
The checksum is seeded with the specified value.
.It Fl U
Modify the owner, group, and permissions of existing files to match
the specification and create any missing directories.
the specification and create any missing directories or symbolic links.
User, group, and permissions must all be specified for missing directories
to be created.
Exit with a status of 0 on success, 1 if any error occurred;

View File

@ -165,6 +165,7 @@ miss(p, tail)
{
register int create;
register char *tp;
const char *type;
for (; p; p = p->next) {
if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
@ -172,18 +173,32 @@ miss(p, tail)
(void)strcpy(tail, p->name);
if (!(p->flags & F_VISIT))
(void)printf("missing: %s", path);
if (p->type != F_DIR) {
if (p->type != F_DIR && p->type != F_LINK) {
putchar('\n');
continue;
}
create = 0;
if (p->type == F_LINK)
type = "symlink";
else
type = "directory";
if (!(p->flags & F_VISIT) && uflag) {
if (!(p->flags & (F_UID | F_UNAME)))
(void)printf(" (directory not created: user not specified)");
(void)printf(" (%s not created: user not specified)", type);
else if (!(p->flags & (F_GID | F_GNAME)))
(void)printf(" (directory not created: group not specified)");
else if (!(p->flags & F_MODE))
(void)printf(" (%s not created: group not specified)", type);
else if (p->type == F_LINK) {
if (symlink(p->slink, path))
(void)printf(" (symlink not created: %s)\n",
strerror(errno));
else
(void)printf(" (created)\n");
if (lchown(path, p->st_uid, p->st_gid))
(void)printf("%s: user/group not modified: %s\n",
path, strerror(errno));
continue;
} else if (!(p->flags & F_MODE))
(void)printf(" (directory not created: mode not specified)");
else if (mkdir(path, S_IRWXU))
(void)printf(" (directory not created: %s)",