svn commit: r186256 - in projects/makefs: . compat compat/mtree

Sam Leffler sam at FreeBSD.org
Wed Dec 17 13:54:09 PST 2008


Author: sam
Date: Wed Dec 17 21:54:08 2008
New Revision: 186256
URL: http://svn.freebsd.org/changeset/base/186256

Log:
  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

Added:
  projects/makefs/compat/getid.c   (contents, props changed)
     - copied, changed from r186109, projects/makefs/compat/mtree/getid.c
Deleted:
  projects/makefs/compat/mtree/getid.c
  projects/makefs/compat/pack_dev.c
  projects/makefs/compat/pack_dev.h
  projects/makefs/compat/stat_flags.c
  projects/makefs/compat/stat_flags.h
Modified:
  projects/makefs/Makefile
  projects/makefs/walk.c

Modified: projects/makefs/Makefile
==============================================================================
--- projects/makefs/Makefile	Wed Dec 17 21:04:43 2008	(r186255)
+++ projects/makefs/Makefile	Wed Dec 17 21:54:08 2008	(r186256)
@@ -10,20 +10,20 @@ CFLAGS+=-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE
 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>

Copied and modified: projects/makefs/compat/getid.c (from r186109, projects/makefs/compat/mtree/getid.c)
==============================================================================
--- projects/makefs/compat/mtree/getid.c	Mon Dec 15 02:06:02 2008	(r186109, copy source)
+++ projects/makefs/compat/getid.c	Wed Dec 17 21:54:08 2008	(r186256)
@@ -82,6 +82,7 @@
 #include <time.h>
 #include <unistd.h>
 
+#include "mtree.h"
 #include "extern.h"
 
 static	struct group *	gi_getgrnam(const char *);

Modified: projects/makefs/walk.c
==============================================================================
--- projects/makefs/walk.c	Wed Dec 17 21:04:43 2008	(r186255)
+++ projects/makefs/walk.c	Wed Dec 17 21:54:08 2008	(r186256)
@@ -92,7 +92,9 @@ __RCSID("$NetBSD: walk.c,v 1.17 2004/06/
 #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, con
 	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, con
 	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 *spe
 			    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 *s
 		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 *ro
 /*
  * 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");
+	if (S_ISDIR(mode))
+		return ("dir");
 	if (S_ISLNK(mode))
-		return ("symlink");	/* inotype() returns "link"...  */
-	return (inotype(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");
 }
 
 


More information about the svn-src-projects mailing list