/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
for (; p; p = p->next) {
if (p->flags & F_OPT && !(p->flags & F_VISIT))
continue;
if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
continue;
strcpy(tail, p->name);
if (!(p->flags & F_VISIT)) {
/* Don't print missing message if file exists as a
symbolic link and the -q flag is set. */
struct stat statbuf;
if (qflag && stat(path, &statbuf) == 0 &&
S_ISDIR(statbuf.st_mode))
p->flags |= F_VISIT;
else
(void)printf("%s missing", path);
}
switch (p->type) {
case F_BLOCK:
case F_CHAR:
type = "device";
break;
case F_DIR:
type = "directory";
break;
case F_LINK:
type = "symlink";
break;
default:
putchar('\n');
continue;
}
create = 0;
if (!(p->flags & F_VISIT) && uflag) {
if (mtree_Wflag || p->type == F_LINK)
goto createit;
if (!(p->flags & (F_UID | F_UNAME)))
printf(
" (%s not created: user not specified)", type);
else if (!(p->flags & (F_GID | F_GNAME)))
printf(
" (%s not created: group not specified)", type);
else if (!(p->flags & F_MODE))
printf(
" (%s not created: mode not specified)", type);
else
createit:
switch (p->type) {
case F_BLOCK:
case F_CHAR:
if (mtree_Wflag)
continue;
if (!(p->flags & F_DEV))
printf(
" (%s not created: device not specified)",
type);
else if (mknod(path,
p->st_mode | nodetoino(p->type),
p->st_rdev) == -1)
printf(" (%s not created: %s)\n",
type, strerror(errno));
else
create = 1;
break;
case F_LINK:
if (!(p->flags & F_SLINK))
printf(
" (%s not created: link not specified)\n",
type);
else if (symlink(p->slink, path))
printf(
" (%s not created: %s)\n",
type, strerror(errno));
else
create = 1;
break;
case F_DIR:
if (mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO))
printf(" (not created: %s)",
strerror(errno));
else
create = 1;
break;
default:
mtree_err("can't create create %s",
nodetype(p->type));
}
}
if (create)
printf(" (created)");
if (p->type == F_DIR) {
if (!(p->flags & F_VISIT))
putchar('\n');
for (tp = tail; *tp; ++tp)
continue;
*tp = '/';
miss(p->child, tp + 1);
*tp = '\0';
} else
putchar('\n');