* Copyright (c) 1989 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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
static char sccsid
[] = "@(#)spec.c 5.14 (Berkeley) 3/2/91";
extern NODE
*root
; /* root of the tree */
static int lineno
; /* current spec line number */
register NODE
*centry
, *last
;
bzero((void *)&ginfo
, sizeof(ginfo
));
for (lineno
= 1; fgets(buf
, sizeof(buf
), stdin
); ++lineno
) {
if (!(p
= index(buf
, '\n'))) {
"mtree: line %d too long.\n", lineno
);
for (p
= buf
; *p
&& isspace(*p
); ++p
);
/* grab file name, "$", "set", or "unset" */
if (!(p
= strtok(p
, "\n\t ")))
if (strcmp(p
+ 1, "set"))
if (strcmp(p
+ 1, "unset"))
"mtree: file names may not contain slashes.\n");
/* don't go up, if haven't gone down */
if (last
->type
!= F_DIR
|| last
->flags
& F_DONE
) {
centry
= emalloc(sizeof(NODE
) + strlen(p
));
(void)strcpy(centry
->name
, p
);
centry
->flags
|= F_MAGIC
;
} else if (last
->type
== F_DIR
&& !(last
->flags
& F_DONE
)) {
last
= last
->child
= centry
;
centry
->parent
= last
->parent
;
last
= last
->next
= centry
;
while (kw
= strtok((char *)NULL
, "= \t\n")) {
ip
->flags
|= type
= key(kw
);
val
= strtok((char *)NULL
, " \t\n");
ip
->st_gid
= getgroup(val
);
if (!(m
= setmode(val
))) {
"mtree: invalid file mode %s.\n", val
);
ip
->st_mode
= getmode(m
, 0);
ip
->st_nlink
= atoi(val
);
ip
->st_uid
= getowner(val
);
if (!(ip
->slink
= strdup(val
)))
ip
->st_mtime
= atol(val
);
if (!strcmp(val
, "block"))
if (!strcmp(val
, "char"))
if (!strcmp(val
, "file"))
if (!strcmp(val
, "fifo"))
if (!strcmp(val
, "link"))
if (!strcmp(val
, "socket"))
"mtree: unknown file type %s.\n", val
);
while (p
= strtok((char *)NULL
, "\n\t "))
if (!strcmp(p
, "ignore"))
(void)fprintf(stderr
, "mtree: unknown keyword %s.\n", p
);
if ((val
= atoi(p
)) >= 0)
(void)fprintf(stderr
, "mtree: illegal uid value %s.\n", p
);
} else if (pw
= getpwnam(p
))
(void)fprintf(stderr
, "mtree: unknown user %s.\n", p
);
if ((val
= atoi(p
)) >= 0)
(void)fprintf(stderr
, "mtree: illegal gid value %s.\n", p
);
} else if (gr
= getgrnam(p
))
(void)fprintf(stderr
, "mtree: unknown group %s.\n", p
);
(void)fprintf(stderr
, "mtree: no parent node.\n");
"mtree: line %d of the specification is incorrect.\n", lineno
);
if (!(p
= malloc((u_int
)size
)))
(void)fprintf(stderr
, "mtree: %s.\n", strerror(ENOMEM
));