Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makefs v7fs(7th edition(V7) file system) support.
details: https://anonhg.NetBSD.org/src/rev/504d70e04304
branches: trunk
changeset: 767428:504d70e04304
user: uch <uch%NetBSD.org@localhost>
date: Mon Jul 18 08:58:38 2011 +0000
description:
v7fs(7th edition(V7) file system) support.
diffstat:
usr.sbin/makefs/Makefile | 5 +-
usr.sbin/makefs/README | 3 +-
usr.sbin/makefs/makefs.8 | 18 +-
usr.sbin/makefs/makefs.c | 6 +-
usr.sbin/makefs/makefs.h | 6 +-
usr.sbin/makefs/v7fs.c | 181 +++++++++++++++++++++
usr.sbin/makefs/v7fs/Makefile.inc | 18 ++
usr.sbin/makefs/v7fs/v7fs_estimate.c | 277 ++++++++++++++++++++++++++++++++
usr.sbin/makefs/v7fs/v7fs_populate.c | 299 +++++++++++++++++++++++++++++++++++
usr.sbin/makefs/v7fs_makefs.h | 48 +++++
10 files changed, 853 insertions(+), 8 deletions(-)
diffs (truncated from 977 to 300 lines):
diff -r 737c23368df6 -r 504d70e04304 usr.sbin/makefs/Makefile
--- a/usr.sbin/makefs/Makefile Mon Jul 18 07:44:30 2011 +0000
+++ b/usr.sbin/makefs/Makefile Mon Jul 18 08:58:38 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.25 2009/04/22 15:23:05 lukem Exp $
+# $NetBSD: Makefile,v 1.26 2011/07/18 08:58:38 uch Exp $
#
WARNS?= 3 # XXX -Wsign-compare
@@ -6,7 +6,7 @@
.include <bsd.own.mk>
PROG= makefs
-SRCS= cd9660.c ffs.c \
+SRCS= cd9660.c ffs.c v7fs.c \
getid.c \
makefs.c misc.c \
pack_dev.c \
@@ -22,6 +22,7 @@
.include "${.CURDIR}/cd9660/Makefile.inc"
.include "${.CURDIR}/ffs/Makefile.inc"
+.include "${.CURDIR}/v7fs/Makefile.inc"
.if (${HOSTPROG:U} == "")
DPADD+= ${LIBUTIL}
diff -r 737c23368df6 -r 504d70e04304 usr.sbin/makefs/README
--- a/usr.sbin/makefs/README Mon Jul 18 07:44:30 2011 +0000
+++ b/usr.sbin/makefs/README Mon Jul 18 08:58:38 2011 +0000
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.4 2009/01/03 08:25:35 lukem Exp $
+$NetBSD: README,v 1.5 2011/07/18 08:58:38 uch Exp $
makefs - build a file system image from a directory tree
@@ -17,6 +17,7 @@
the following file system types can be built:
ffs BSD fast file system
cd9660 ISO 9660 file system
+ v7fs 7th edition(V7) file system
Support for the following file systems maybe be added in the future
ext2fs Linux EXT2 file system
diff -r 737c23368df6 -r 504d70e04304 usr.sbin/makefs/makefs.8
--- a/usr.sbin/makefs/makefs.8 Mon Jul 18 07:44:30 2011 +0000
+++ b/usr.sbin/makefs/makefs.8 Mon Jul 18 08:58:38 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: makefs.8,v 1.33 2011/05/22 21:51:39 christos Exp $
+.\" $NetBSD: makefs.8,v 1.34 2011/07/18 08:58:38 uch Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -191,6 +191,8 @@
BSD fast file system (default).
.It Sy cd9660
ISO 9660 file system.
+.It Sy v7fs
+7th Edition(V7) file system.
.El
.It Fl x
Exclude file system nodes not explicitly listed in the specfile.
@@ -327,6 +329,16 @@
.It Sy volumeid
Volume set identifier of the image.
.El
+.Ss V7FS-specific options
+The following keywords are supported:
+.Pp
+.Bl -tag -width optimization -offset indent -compact
+.It Sy pdp
+PDP endian.
+.It Sy progress
+Display a progress meter for the file system construction and file
+popuration.
+.El
.Sh SEE ALSO
.Xr strsuftoll 3 ,
.Xr installboot 8 ,
@@ -346,4 +358,6 @@
.An Ryan Gabrys ,
.An Alan Perez-Rathke ,
.An Ram Vedam
-(cd9660 support)
+(cd9660 support),
+.An UCHIYAMA Yasushi
+(v7fs support)
diff -r 737c23368df6 -r 504d70e04304 usr.sbin/makefs/makefs.c
--- a/usr.sbin/makefs/makefs.c Mon Jul 18 07:44:30 2011 +0000
+++ b/usr.sbin/makefs/makefs.c Mon Jul 18 08:58:38 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.c,v 1.26 2006/10/22 21:11:56 christos Exp $ */
+/* $NetBSD: makefs.c,v 1.27 2011/07/18 08:58:38 uch Exp $ */
/*
* Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.26 2006/10/22 21:11:56 christos Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.27 2011/07/18 08:58:38 uch Exp $");
#endif /* !__lint */
#include <assert.h>
@@ -73,6 +73,8 @@
{ "ffs", ffs_prep_opts, ffs_parse_opts, ffs_cleanup_opts, ffs_makefs },
{ "cd9660", cd9660_prep_opts, cd9660_parse_opts, cd9660_cleanup_opts,
cd9660_makefs},
+ { "v7fs", v7fs_prep_opts, v7fs_parse_opts, v7fs_cleanup_opts,
+ v7fs_makefs },
{ .type = NULL },
};
diff -r 737c23368df6 -r 504d70e04304 usr.sbin/makefs/makefs.h
--- a/usr.sbin/makefs/makefs.h Mon Jul 18 07:44:30 2011 +0000
+++ b/usr.sbin/makefs/makefs.h Mon Jul 18 08:58:38 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.h,v 1.20 2008/12/28 21:51:46 christos Exp $ */
+/* $NetBSD: makefs.h,v 1.21 2011/07/18 08:58:38 uch Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -170,6 +170,10 @@
void cd9660_cleanup_opts(fsinfo_t *);
void cd9660_makefs(const char *, const char *, fsnode *, fsinfo_t *);
+void v7fs_prep_opts(fsinfo_t *);
+int v7fs_parse_opts(const char *, fsinfo_t *);
+void v7fs_cleanup_opts(fsinfo_t *);
+void v7fs_makefs(const char *, const char *, fsnode *, fsinfo_t *);
extern u_int debug;
extern struct timespec start_time;
diff -r 737c23368df6 -r 504d70e04304 usr.sbin/makefs/v7fs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/makefs/v7fs.c Mon Jul 18 08:58:38 2011 +0000
@@ -0,0 +1,181 @@
+/* $NetBSD: v7fs.c,v 1.1 2011/07/18 08:58:38 uch Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by UCHIYAMA Yasushi.
+ *
+ * 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.
+ *
+ * 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(__RCSID) && !defined(__lint)
+__RCSID("$NetBSD: v7fs.c,v 1.1 2011/07/18 08:58:38 uch Exp $");
+#endif /* !__lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "makefs.h"
+#include "v7fs.h"
+#include "v7fs_impl.h"
+#include "v7fs_makefs.h"
+#include "newfs_v7fs.h"
+#include "progress.h"
+
+static v7fs_opt_t v7fs_opts;
+static bool progress_bar_enable;
+bool verbose;
+
+void
+v7fs_prep_opts(fsinfo_t *fsopts)
+{
+
+ fsopts->fs_specific = &v7fs_opts;
+}
+
+void
+v7fs_cleanup_opts(fsinfo_t *fsopts)
+{
+ /*NO-OP*/
+}
+
+int
+v7fs_parse_opts(const char *option, fsinfo_t *fsopts)
+{
+ static option_t v7fs_options[] = {
+ { "pdp", &v7fs_opts.pdp_endian, false, true, "PDP endian" },
+ { "progress", &v7fs_opts.progress, false, true,
+ "Progress bar" },
+ { .name = NULL }
+ };
+
+ set_option(v7fs_options, option, "1");
+
+ return 1;
+}
+
+void
+v7fs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
+{
+ struct v7fs_mount_device v7fs_mount;
+ int fd, endian, error = 1;
+
+ verbose = debug;
+ if ((progress_bar_enable = v7fs_opts.progress)) {
+ progress_switch(progress_bar_enable);
+ progress_init();
+ progress(&(struct progress_arg){ .cdev = image });
+ }
+
+ /* Determine filesystem image size */
+ v7fs_estimate(dir, root, fsopts);
+ printf("Calculated size of `%s': %lld bytes, %ld inodes\n",
+ image, (long long)fsopts->size, (long)fsopts->inodes);
+
+ if ((fd = open(image, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) {
+ err(EXIT_FAILURE, "%s", image);
+ }
+ if (lseek(fd, fsopts->size - 1, SEEK_SET) == -1) {
+ goto err_exit;
+ }
+ if (write(fd, &fd, 1) != 1) {
+ goto err_exit;
+ }
+ if (lseek(fd, 0, SEEK_SET) == -1) {
+ goto err_exit;
+ }
+ fsopts->fd = fd;
+ v7fs_mount.device.fd = fd;
+
+#if !defined BYTE_ORDER
+#error
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+ if (fsopts->needswap)
+ endian = BIG_ENDIAN;
+ else
+ endian = LITTLE_ENDIAN;
+#else
+ if (fsopts->needswap)
+ endian = LITTLE_ENDIAN;
+ else
+ endian = BIG_ENDIAN;
+#endif
+ if (v7fs_opts.pdp_endian) {
+ endian = PDP_ENDIAN;
+ }
+
+ v7fs_mount.endian = endian;
+ v7fs_mount.sectors = fsopts->size >> V7FS_BSHIFT;
+ if (v7fs_newfs(&v7fs_mount, fsopts->inodes) != 0) {
+ goto err_exit;
+ }
+
+ if (v7fs_populate(dir, root, fsopts, &v7fs_mount) != 0) {
+ error = 2; /* some files couldn't add */
+ goto err_exit;
+ }
+
+ close(fd);
+ return;
+
+ err_exit:
+ close(fd);
+ err(error, "%s", image);
+}
+
+void
+progress(const struct progress_arg *p)
+{
+ static struct progress_arg Progress;
+ static char cdev[32];
+ static char label[32];
+
+ if (!progress_bar_enable)
Home |
Main Index |
Thread Index |
Old Index