summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree/verify.c
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2000-07-13 22:28:39 +0000
committerjoe <joe@FreeBSD.org>2000-07-13 22:28:39 +0000
commitceabf93e2a4d7e9ebf4d757c0122035027eabf6e (patch)
treef95c02c1b56885bef8f47fe92893226c43e96278 /usr.sbin/mtree/verify.c
parentdad66a4f4f293b19db9c7939efff27a7bc8fc69a (diff)
downloadFreeBSD-src-ceabf93e2a4d7e9ebf4d757c0122035027eabf6e.zip
FreeBSD-src-ceabf93e2a4d7e9ebf4d757c0122035027eabf6e.tar.gz
Allow symlinks to be created if they appear in the mtree specification.
PR: bin/14171
Diffstat (limited to 'usr.sbin/mtree/verify.c')
-rw-r--r--usr.sbin/mtree/verify.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c
index 25b33aa..d25797b 100644
--- a/usr.sbin/mtree/verify.c
+++ b/usr.sbin/mtree/verify.c
@@ -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)",
OpenPOWER on IntegriCloud