Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2013 17:36:56 -0600
From:      Brooks Davis <brooks@freebsd.org>
To:        arch@freebsd.org
Subject:   [CFT] switch makefs to use NetBSD mtree
Message-ID:  <20130117233656.GB55912@lor.one-eyed-alien.net>

next in thread | raw e-mail | index | archive | help

--St7VIuEGZ6dlpu13
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

The following patch switches makefs to use NetBSD's mtree's file parsing
code which adds support for full pathnames.  It also replaces the adhoc
compatibility code with libnetbsd.  Before applying it you
should cd to usr.sbin/makefs and run "rm -rf getid.c compat".

Please review or test it out and let me know if it works for you.

The patch can also be found at:
http://people.freebsd.org/~brooks/patches/makefs-nmtree.diff

Thanks
Brooks

Modify the makefs build to use NetBSD's mtree's parsing code rather than
FreeBSD's so that full pathnames are supported in mtree files.

Also use libnetbsd instead of the existing compat layer.

Sponsored by:	DARPA, AFRL

Before applying this patch run: rm -rf getid.c compat

Index: walk.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- walk.c	(revision 245563)
+++ walk.c	(working copy)
@@ -305,7 +305,7 @@
 	if ((fp =3D fopen(specfile, "r")) =3D=3D NULL)
 		err(1, "Can't open `%s'", specfile);
 	TIMER_START(start);
-	root =3D mtree_readspec(fp);
+	root =3D spec(fp);
 	TIMER_RESULTS(start, "spec");
 	if (fclose(fp) =3D=3D EOF)
 		err(1, "Can't close `%s'", specfile);
@@ -321,33 +321,6 @@
=20
 }
=20
-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, int specon=
ly)
 {
Index: makefs.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- makefs.h	(revision 245563)
+++ makefs.h	(working copy)
@@ -279,22 +279,4 @@
 struct fs;
 void   ffs_fragacct_swap(struct fs *, int, int32_t [], int, int);
=20
-/*
- * Declarations for compat routines.
- */
-long long strsuftoll(const char *, const char *, long long, long long);
-long long strsuftollx(const char *, const char *,
-                       long long, long long, char *, size_t);
-
-struct passwd;
-int uid_from_user(const char *, uid_t *);
-int pwcache_userdb(int (*)(int), void (*)(void),
-               struct passwd * (*)(const char *), struct passwd * (*)(uid_=
t));
-struct group;
-int gid_from_group(const char *, gid_t *);
-int pwcache_groupdb(int (*)(int), void (*)(void),
-               struct group * (*)(const char *), struct group * (*)(gid_t)=
);
-
-int setup_getid(const char *dir);
-
 #endif	/* _MAKEFS_H */
Index: Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Makefile	(revision 245563)
+++ Makefile	(working copy)
@@ -5,7 +5,6 @@
 CFLAGS+=3D-I${.CURDIR}
=20
 SRCS=3D	cd9660.c ffs.c \
-	getid.c \
 	makefs.c \
 	mtree.c \
 	walk.c
@@ -15,19 +14,28 @@
=20
 .include "${.CURDIR}/cd9660/Makefile.inc"
 .include "${.CURDIR}/ffs/Makefile.inc"
-.include "${.CURDIR}/compat/Makefile.inc"
=20
 CFLAGS+=3D-DHAVE_STRUCT_STAT_ST_FLAGS=3D1
 CFLAGS+=3D-DHAVE_STRUCT_STAT_ST_GEN=3D1
=20
-.PATH:	${.CURDIR}/../mtree
-CFLAGS+=3D-I${.CURDIR}/../mtree
-SRCS+=3D	misc.c spec.c
+.PATH: ${.CURDIR}/../../contrib/mtree
+CFLAGS+=3D-I${.CURDIR}/../../contrib/mtree
+SRCS+=3D	getid.c misc.c spec.c
=20
+.PATH: ${.CURDIR}/../../contrib/mknod
+CFLAGS+=3D-I${.CURDIR}/../../contrib/mknod
+SRCS+=3D	pack_dev.c
+
 .PATH:	${.CURDIR}/../../sys/ufs/ffs
 SRCS+=3D	ffs_tables.c
=20
-DPADD=3D  ${LIBSBUF}
-LDADD=3D  -lsbuf
+CFLAGS+=3D	-I${.CURDIR}/../../lib/libnetbsd
+LIBNETBSDDIR=3D	${.OBJDIR}/../../lib/libnetbsd
+LIBNETBSD=3D	${LIBNETBSDDIR}/libnetbsd.a
+DPADD+=3D		${LIBNETBSD}
+LDADD+=3D		${LIBNETBSD}
=20
+DPADD+=3D  ${LIBSBUF} ${LIBUTIL}
+LDADD+=3D  -lsbuf -lutil
+
 .include <bsd.prog.mk>

--St7VIuEGZ6dlpu13
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iD8DBQFQ+IsYXY6L6fI4GtQRAiK3AKC310eWc9sUkuLz6HiaJ0DU2yPLIACfQimL
joZ+EApTT8kqBqK+KO9vV/Q=
=YWqL
-----END PGP SIGNATURE-----

--St7VIuEGZ6dlpu13--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130117233656.GB55912>