1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-22 11:17:19 +00:00

First step toward proper mtree integration:

o use mtree code directly from ../mtree; s/spec(fp)/mtree_readspec(fp)/
  (assume this will eventually go in usr.sbin)
o nuke st_rdev use; there's no reason to create filesystems with device nodes
o shim missing compat bits for inotype and nodetoino
o remove now unneeded compat/mtree bits, pack_dev.?, and stat_flags.?
o temporarily move getid.c code up to compat to keep this building
This commit is contained in:
Sam Leffler 2008-12-17 21:54:08 +00:00
parent 4eb58ef463
commit e86288c353
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/makefs/; revision=186256
7 changed files with 54 additions and 595 deletions

View File

@ -10,20 +10,20 @@ CFLAGS+=-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
CFLAGS+=-I.
SRCS= ffs.c makefs.c walk.c
.PATH: ffs
.PATH: ${.CURDIR}/ffs
CFLAGS+=-Iffs
SRCS+= buf.c ffs_alloc.c ffs_balloc.c mkfs.c ufs_bmap.c
.PATH: sys/ufs/ffs
.PATH: ${.CURDIR}/sys/ufs/ffs
CFLAGS+=-Isys -Isys/ufs
SRCS+= ffs_bswap.c ffs_subr.c ffs_tables.c
.PATH: ${.CURDIR}/compat/mtree
CFLAGS+=-Icompat/mtree
SRCS+= getid.c misc.c spec.c
.PATH: ${.CURDIR}/../mtree
CFLAGS+=-I../mtree
SRCS+= misc.c spec.c
.PATH: compat
.PATH: ${.CURDIR}/compat
CFLAGS+=-Icompat
SRCS+= fparseln.c getmode.c pack_dev.c pwcache.c stat_flags.c strsuftoll.c
SRCS+= fparseln.c getid.c getmode.c pwcache.c strsuftoll.c
.include <bsd.prog.mk>

View File

@ -82,6 +82,7 @@
#include <time.h>
#include <unistd.h>
#include "mtree.h"
#include "extern.h"
static struct group * gi_getgrnam(const char *);

View File

@ -1,297 +0,0 @@
/* $NetBSD: pack_dev.c,v 1.8 2004/05/11 17:09:58 christos Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: pack_dev.c,v 1.8 2004/05/11 17:09:58 christos Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "pack_dev.h"
static pack_t pack_netbsd;
static pack_t pack_freebsd;
static pack_t pack_8_8;
static pack_t pack_12_20;
static pack_t pack_14_18;
static pack_t pack_8_24;
static pack_t pack_bsdos;
static int compare_format(const void *, const void *);
static const char iMajorError[] = "invalid major number";
static const char iMinorError[] = "invalid minor number";
static const char tooManyFields[] = "too many fields for format";
/* exported */
portdev_t
pack_native(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev(numbers[0], numbers[1]);
if (major(dev) != numbers[0])
*error = iMajorError;
else if (minor(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
static portdev_t
pack_netbsd(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_netbsd(numbers[0], numbers[1]);
if (major_netbsd(dev) != numbers[0])
*error = iMajorError;
else if (minor_netbsd(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
#define major_freebsd(x) ((int32_t)(((x) & 0x0000ff00) >> 8))
#define minor_freebsd(x) ((int32_t)(((x) & 0xffff00ff) >> 0))
#define makedev_freebsd(x,y) ((portdev_t)((((x) << 8) & 0x0000ff00) | \
(((y) << 0) & 0xffff00ff)))
static portdev_t
pack_freebsd(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_freebsd(numbers[0], numbers[1]);
if (major_freebsd(dev) != numbers[0])
*error = iMajorError;
if (minor_freebsd(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
#define major_8_8(x) ((int32_t)(((x) & 0x0000ff00) >> 8))
#define minor_8_8(x) ((int32_t)(((x) & 0x000000ff) >> 0))
#define makedev_8_8(x,y) ((portdev_t)((((x) << 8) & 0x0000ff00) | \
(((y) << 0) & 0x000000ff)))
static portdev_t
pack_8_8(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_8_8(numbers[0], numbers[1]);
if (major_8_8(dev) != numbers[0])
*error = iMajorError;
if (minor_8_8(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
#define major_12_20(x) ((int32_t)(((x) & 0xfff00000) >> 20))
#define minor_12_20(x) ((int32_t)(((x) & 0x000fffff) >> 0))
#define makedev_12_20(x,y) ((portdev_t)((((x) << 20) & 0xfff00000) | \
(((y) << 0) & 0x000fffff)))
static portdev_t
pack_12_20(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_12_20(numbers[0], numbers[1]);
if (major_12_20(dev) != numbers[0])
*error = iMajorError;
if (minor_12_20(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
#define major_14_18(x) ((int32_t)(((x) & 0xfffc0000) >> 18))
#define minor_14_18(x) ((int32_t)(((x) & 0x0003ffff) >> 0))
#define makedev_14_18(x,y) ((portdev_t)((((x) << 18) & 0xfffc0000) | \
(((y) << 0) & 0x0003ffff)))
static portdev_t
pack_14_18(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_14_18(numbers[0], numbers[1]);
if (major_14_18(dev) != numbers[0])
*error = iMajorError;
if (minor_14_18(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
#define major_8_24(x) ((int32_t)(((x) & 0xff000000) >> 24))
#define minor_8_24(x) ((int32_t)(((x) & 0x00ffffff) >> 0))
#define makedev_8_24(x,y) ((portdev_t)((((x) << 24) & 0xff000000) | \
(((y) << 0) & 0x00ffffff)))
static portdev_t
pack_8_24(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_8_24(numbers[0], numbers[1]);
if (major_8_24(dev) != numbers[0])
*error = iMajorError;
if (minor_8_24(dev) != numbers[1])
*error = iMinorError;
} else
*error = tooManyFields;
return (dev);
}
#define major_12_12_8(x) ((int32_t)(((x) & 0xfff00000) >> 20))
#define unit_12_12_8(x) ((int32_t)(((x) & 0x000fff00) >> 8))
#define subunit_12_12_8(x) ((int32_t)(((x) & 0x000000ff) >> 0))
#define makedev_12_12_8(x,y,z) ((portdev_t)((((x) << 20) & 0xfff00000) | \
(((y) << 8) & 0x000fff00) | \
(((z) << 0) & 0x000000ff)))
static portdev_t
pack_bsdos(int n, u_long numbers[], const char **error)
{
portdev_t dev = 0;
if (n == 2) {
dev = makedev_12_20(numbers[0], numbers[1]);
if (major_12_20(dev) != numbers[0])
*error = iMajorError;
if (minor_12_20(dev) != numbers[1])
*error = iMinorError;
} else if (n == 3) {
dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]);
if (major_12_12_8(dev) != numbers[0])
*error = iMajorError;
if (unit_12_12_8(dev) != numbers[1])
*error = "invalid unit number";
if (subunit_12_12_8(dev) != numbers[2])
*error = "invalid subunit number";
} else
*error = tooManyFields;
return (dev);
}
/* list of formats and pack functions */
/* this list must be sorted lexically */
struct format {
const char *name;
pack_t *pack;
} formats[] = {
{"386bsd", pack_8_8},
{"4bsd", pack_8_8},
{"bsdos", pack_bsdos},
{"freebsd", pack_freebsd},
{"hpux", pack_8_24},
{"isc", pack_8_8},
{"linux", pack_8_8},
{"native", pack_native},
{"netbsd", pack_netbsd},
{"osf1", pack_12_20},
{"sco", pack_8_8},
{"solaris", pack_14_18},
{"sunos", pack_8_8},
{"svr3", pack_8_8},
{"svr4", pack_14_18},
{"ultrix", pack_8_8},
};
static int
compare_format(const void *key, const void *element)
{
const char *name;
const struct format *format;
name = key;
format = element;
return (strcmp(name, format->name));
}
pack_t *
pack_find(const char *name)
{
struct format *format;
format = bsearch(name, formats,
sizeof(formats)/sizeof(formats[0]),
sizeof(formats[0]), compare_format);
if (format == 0)
return (NULL);
return (format->pack);
}

View File

@ -1,59 +0,0 @@
/* $NetBSD: pack_dev.h,v 1.6 2004/05/11 17:09:58 christos Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#ifndef _PACK_DEV_H
#define _PACK_DEV_H
#ifdef __CYGWIN__
typedef __dev32_t portdev_t;
#else
typedef dev_t portdev_t;
#endif
typedef portdev_t pack_t(int, u_long [], const char **);
pack_t *pack_find(const char *);
pack_t pack_native;
#define major_netbsd(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
#define minor_netbsd(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
(((x) & 0x000000ff) >> 0)))
#define makedev_netbsd(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
(((y) << 12) & 0xfff00000) | \
(((y) << 0) & 0x000000ff)))
#endif /* _PACK_DEV_H */

View File

@ -1,185 +0,0 @@
/* $NetBSD: stat_flags.c,v 1.19 2004/05/25 14:54:55 hannken Exp $ */
/*-
* Copyright (c) 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.
*/
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#else
#define HAVE_STRUCT_STAT_ST_FLAGS 1
#endif
#include <sys/cdefs.h>
#if !defined(lint)
#if 0
static char sccsid[] = "@(#)stat_flags.c 8.2 (Berkeley) 7/28/94";
#else
__RCSID("$NetBSD: stat_flags.c,v 1.19 2004/05/25 14:54:55 hannken Exp $");
#endif
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <fts.h>
#include <stddef.h>
#include <string.h>
#include "stat_flags.h"
#define SAPPEND(s) do { \
if (prefix != NULL) \
(void)strlcat(string, prefix, sizeof(string)); \
(void)strlcat(string, s, sizeof(string)); \
prefix = ","; \
} while (/* CONSTCOND */ 0)
/*
* flags_to_string --
* Convert stat flags to a comma-separated string. If no flags
* are set, return the default string.
*/
char *
flags_to_string(u_long flags, const char *def)
{
static char string[128];
const char *prefix;
string[0] = '\0';
prefix = NULL;
#if HAVE_STRUCT_STAT_ST_FLAGS
if (flags & UF_APPEND)
SAPPEND("uappnd");
if (flags & UF_IMMUTABLE)
SAPPEND("uchg");
if (flags & UF_NODUMP)
SAPPEND("nodump");
if (flags & UF_OPAQUE)
SAPPEND("opaque");
if (flags & SF_APPEND)
SAPPEND("sappnd");
if (flags & SF_ARCHIVED)
SAPPEND("arch");
if (flags & SF_IMMUTABLE)
SAPPEND("schg");
#ifdef SF_SNAPSHOT
if (flags & SF_SNAPSHOT)
SAPPEND("snap");
#endif
#endif
if (prefix == NULL)
strlcpy(string, def, sizeof(string));
return (string);
}
#define TEST(a, b, f) { \
if (!strcmp(a, b)) { \
if (clear) { \
if (clrp) \
*clrp |= (f); \
if (setp) \
*setp &= ~(f); \
} else { \
if (setp) \
*setp |= (f); \
if (clrp) \
*clrp &= ~(f); \
} \
break; \
} \
}
/*
* string_to_flags --
* Take string of arguments and return stat flags. Return 0 on
* success, 1 on failure. On failure, stringp is set to point
* to the offending token.
*/
int
string_to_flags(char **stringp, u_long *setp, u_long *clrp)
{
int clear;
char *string, *p;
if (setp)
*setp = 0;
if (clrp)
*clrp = 0;
#if HAVE_STRUCT_STAT_ST_FLAGS
string = *stringp;
while ((p = strsep(&string, "\t ,")) != NULL) {
clear = 0;
*stringp = p;
if (*p == '\0')
continue;
if (p[0] == 'n' && p[1] == 'o') {
clear = 1;
p += 2;
}
switch (p[0]) {
case 'a':
TEST(p, "arch", SF_ARCHIVED);
TEST(p, "archived", SF_ARCHIVED);
return (1);
case 'd':
clear = !clear;
TEST(p, "dump", UF_NODUMP);
return (1);
case 'n':
/*
* Support `nonodump'. Note that
* the state of clear is not changed.
*/
TEST(p, "nodump", UF_NODUMP);
return (1);
case 'o':
TEST(p, "opaque", UF_OPAQUE);
return (1);
case 's':
TEST(p, "sappnd", SF_APPEND);
TEST(p, "sappend", SF_APPEND);
TEST(p, "schg", SF_IMMUTABLE);
TEST(p, "schange", SF_IMMUTABLE);
TEST(p, "simmutable", SF_IMMUTABLE);
return (1);
case 'u':
TEST(p, "uappnd", UF_APPEND);
TEST(p, "uappend", UF_APPEND);
TEST(p, "uchg", UF_IMMUTABLE);
TEST(p, "uchange", UF_IMMUTABLE);
TEST(p, "uimmutable", UF_IMMUTABLE);
return (1);
default:
return (1);
}
}
#endif
return (0);
}

View File

@ -1,35 +0,0 @@
/* $NetBSD: stat_flags.h,v 1.4 2003/08/07 09:05:16 agc Exp $ */
/*-
* Copyright (c) 1991, 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.
*
* @(#)extern.h 8.1 (Berkeley) 5/31/93
*/
char *flags_to_string(u_long, const char *);
int string_to_flags(char **, u_long *, u_long *);

58
walk.c
View File

@ -92,7 +92,9 @@ __RCSID("$NetBSD: walk.c,v 1.17 2004/06/20 22:20:18 jmc Exp $");
#include <unistd.h>
#include "makefs.h"
#include "mtree.h"
#include "extern.h" /* NB: mtree */
static void apply_specdir(const char *, NODE *, fsnode *);
static void apply_specentry(const char *, NODE *, fsnode *);
@ -228,7 +230,7 @@ apply_specfile(const char *specfile, const char *dir, fsnode *parent)
if ((fp = fopen(specfile, "r")) == NULL)
err(1, "Can't open `%s'", specfile);
TIMER_START(start);
root = spec(fp);
root = mtree_readspec(fp);
TIMER_RESULTS(start, "spec");
if (fclose(fp) == EOF)
err(1, "Can't close `%s'", specfile);
@ -243,6 +245,32 @@ apply_specfile(const char *specfile, const char *dir, fsnode *parent)
apply_specdir(dir, root, parent);
}
static u_int
nodetoino(u_int type)
{
switch (type) {
case F_BLOCK:
return S_IFBLK;
case F_CHAR:
return S_IFCHR;
case F_DIR:
return S_IFDIR;
case F_FIFO:
return S_IFIFO;
case F_FILE:
return S_IFREG;
case F_LINK:
return S_IFLNK;
case F_SOCK:
return S_IFSOCK;
default:
printf("unknown type %d", type);
abort();
}
/* NOTREACHED */
}
static void
apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode)
{
@ -306,9 +334,6 @@ apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode)
curnode->flags & F_GNAME, "group");
NODETEST(curnode->flags & F_UID ||
curnode->flags & F_UNAME, "user");
if (curnode->type == F_BLOCK || curnode->type == F_CHAR)
NODETEST(curnode->flags & F_DEV,
"device number");
#undef NODETEST
if (debug & DEBUG_APPLY_SPECFILE)
@ -425,11 +450,6 @@ apply_specentry(const char *dir, NODE *specnode, fsnode *dirnode)
dirnode->inode->st.st_flags = specnode->st_flags;
}
#endif
if (specnode->flags & F_DEV) {
ASEPRINT("rdev", "%#x",
dirnode->inode->st.st_rdev, specnode->st_rdev);
dirnode->inode->st.st_rdev = specnode->st_rdev;
}
#undef ASEPRINT
dirnode->flags |= FSNODE_F_HASSPEC;
@ -479,15 +499,29 @@ dump_fsnodes(const char *dir, fsnode *root)
/*
* inode_type --
* for a given inode type `mode', return a descriptive string.
* for most cases, uses inotype() from mtree/misc.c
*/
const char *
inode_type(mode_t mode)
{
if (S_ISREG(mode))
return ("file");
if (S_ISLNK(mode))
return ("symlink"); /* inotype() returns "link"... */
return (inotype(mode));
return ("symlink");
if (S_ISDIR(mode))
return ("dir");
if (S_ISLNK(mode))
return ("link");
if (S_ISFIFO(mode))
return ("fifo");
if (S_ISSOCK(mode))
return ("socket");
/* XXX should not happen but handle them */
if (S_ISCHR(mode))
return ("char");
if (S_ISBLK(mode))
return ("block");
return ("unknown");
}