Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makefs Implement `makefs -t udf'.
details: https://anonhg.NetBSD.org/src/rev/856d46b231ac
branches: trunk
changeset: 789051:856d46b231ac
user: reinoud <reinoud%NetBSD.org@localhost>
date: Mon Aug 05 14:41:57 2013 +0000
description:
Implement `makefs -t udf'.
Formatting options may be enhanced to make it more in line with newfs_udf on
say labeling.
diffstat:
usr.sbin/makefs/Makefile | 6 +-
usr.sbin/makefs/makefs.8 | 30 +-
usr.sbin/makefs/makefs.c | 5 +-
usr.sbin/makefs/makefs.h | 4 +-
usr.sbin/makefs/udf.c | 1252 ++++++++++++++++++++++++++++++++++++++
usr.sbin/makefs/udf/Makefile.inc | 20 +
6 files changed, 1311 insertions(+), 6 deletions(-)
diffs (truncated from 1413 to 300 lines):
diff -r 760f1bfd4444 -r 856d46b231ac usr.sbin/makefs/Makefile
--- a/usr.sbin/makefs/Makefile Mon Aug 05 14:28:48 2013 +0000
+++ b/usr.sbin/makefs/Makefile Mon Aug 05 14:41:57 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.35 2013/01/27 20:05:46 christos Exp $
+# $NetBSD: Makefile,v 1.36 2013/08/05 14:41:57 reinoud Exp $
#
WARNS?= 5
@@ -6,7 +6,7 @@
.include <bsd.own.mk>
PROG= makefs
-SRCS= cd9660.c chfs.c ffs.c v7fs.c msdos.c \
+SRCS= cd9660.c chfs.c ffs.c v7fs.c msdos.c udf.c\
getid.c \
makefs.c misc.c \
pack_dev.c \
@@ -26,6 +26,7 @@
.include "${.CURDIR}/ffs/Makefile.inc"
.include "${.CURDIR}/v7fs/Makefile.inc"
.include "${.CURDIR}/msdos/Makefile.inc"
+.include "${.CURDIR}/udf/Makefile.inc"
.if !defined(HOSTPROG)
DPADD+= ${LIBUTIL}
@@ -33,3 +34,4 @@
.endif
.include <bsd.prog.mk>
+# DO NOT DELETE
diff -r 760f1bfd4444 -r 856d46b231ac usr.sbin/makefs/makefs.8
--- a/usr.sbin/makefs/makefs.8 Mon Aug 05 14:28:48 2013 +0000
+++ b/usr.sbin/makefs/makefs.8 Mon Aug 05 14:41:57 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: makefs.8,v 1.45 2013/02/03 06:16:53 christos Exp $
+.\" $NetBSD: makefs.8,v 1.46 2013/08/05 14:41:57 reinoud Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -215,6 +215,8 @@
FAT12, FAT16, or FAT32 file system.
.It Sy v7fs
7th Edition(V7) file system.
+.It Sy udf
+ISO/Ecma UDF file system.
.El
.It Fl x
Exclude file system nodes not explicitly listed in the specfile.
@@ -388,6 +390,32 @@
Display a progress meter for the file system construction and file
population.
.El
+.Ss UDF-specific options
+.Sy udf
+images have ffs-specific optional parameters that may be provided.
+Each of the options consists of a keyword, an equal sign
+.Pq Ql = ,
+and a value.
+The following keywords are supported:
+.Pp
+.Bl -tag -width optimization -offset indent -compact
+.It Sy T
+disctype. It can have the values
+.Bl -tag -width 3n -offset indent -compact
+.It cdrom,
+.It dvdrom
+create a read-only fs
+.It dvdram,
+.It bdre,
+.It disk
+create a rewriteable fs without sparing
+.It cdr,
+.It dvdr
+create a rewritable fs on once recordable media using a VAT
+.It cdrw,
+.It dvdrw
+create a rewritable fs with sparing for defective sectors
+.It
.Sh SEE ALSO
.Xr strsuftoll 3 ,
.Xr installboot 8 ,
diff -r 760f1bfd4444 -r 856d46b231ac usr.sbin/makefs/makefs.c
--- a/usr.sbin/makefs/makefs.c Mon Aug 05 14:28:48 2013 +0000
+++ b/usr.sbin/makefs/makefs.c Mon Aug 05 14:41:57 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.c,v 1.49 2013/02/03 06:16:53 christos Exp $ */
+/* $NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud 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.49 2013/02/03 06:16:53 christos Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $");
#endif /* !__lint */
#include <assert.h>
@@ -81,6 +81,7 @@
ENTRY(chfs),
ENTRY(v7fs),
ENTRY(msdos),
+ ENTRY(udf),
{ .type = NULL },
};
diff -r 760f1bfd4444 -r 856d46b231ac usr.sbin/makefs/makefs.h
--- a/usr.sbin/makefs/makefs.h Mon Aug 05 14:28:48 2013 +0000
+++ b/usr.sbin/makefs/makefs.h Mon Aug 05 14:41:57 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.h,v 1.34 2013/02/03 06:16:53 christos Exp $ */
+/* $NetBSD: makefs.h,v 1.35 2013/08/05 14:41:57 reinoud Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -92,6 +92,7 @@
uint32_t nlink; /* number of links to this entry */
enum fi_flags flags; /* flags used by fs specific code */
struct stat st; /* stat entry */
+ void *fsuse; /* for storing FS dependent info */
} fsinode;
typedef struct _fsnode {
@@ -194,6 +195,7 @@
DECLARE_FUN(chfs);
DECLARE_FUN(v7fs);
DECLARE_FUN(msdos);
+DECLARE_FUN(udf);
extern u_int debug;
extern struct timespec start_time;
diff -r 760f1bfd4444 -r 856d46b231ac usr.sbin/makefs/udf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/makefs/udf.c Mon Aug 05 14:41:57 2013 +0000
@@ -0,0 +1,1252 @@
+/* $NetBSD: udf.c,v 1.1 2013/08/05 14:41:57 reinoud Exp $ */
+
+/*
+ * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: udf.c,v 1.1 2013/08/05 14:41:57 reinoud Exp $");
+#endif /* not lint */
+
+#define _EXPOSE_MMC
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <assert.h>
+#include <err.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/cdio.h>
+#include <sys/stat.h>
+#include <util.h>
+
+#include "makefs.h"
+#include "udf_create.h"
+#include "udf_write.h"
+#include "newfs_udf.h"
+
+
+/*
+ * Note: due to the setup of the newfs code, the current state of the program
+ * and its options are helt in a few global variables. The FS specific parts
+ * are in a global `context' structure.
+ */
+
+/* global variables describing disc and format requests */
+int fd; /* device: file descriptor */
+char *dev; /* device: name */
+struct mmc_discinfo mmc_discinfo; /* device: disc info */
+
+char *format_str; /* format: string representation */
+int format_flags; /* format: attribute flags */
+int media_accesstype; /* derived from current mmc cap */
+int check_surface; /* for rewritables */
+int imagefile_secsize; /* for files */
+
+int display_progressbar;
+
+int wrtrack_skew;
+float meta_fract = (float) UDF_META_PERC / 100.0;
+
+int mmc_profile; /* emulated profile */
+int req_enable, req_disable;
+
+
+/* --------------------------------------------------------------------- */
+
+int
+udf_write_sector(void *sector, uint32_t location)
+{
+ uint64_t wpos;
+ ssize_t ret;
+
+ wpos = (uint64_t) location * context.sector_size;
+ ret = pwrite(fd, sector, context.sector_size, wpos);
+ if (ret == -1)
+ return errno;
+ if (ret < context.sector_size)
+ return EIO;
+ return 0;
+}
+
+
+/* not implemented for files */
+int
+udf_surface_check(void)
+{
+ return 0;
+}
+
+
+/*
+ * mmc_discinfo and mmc_trackinfo readers modified from origional in udf main
+ * code in sys/fs/udf/
+ */
+
+#ifdef DEBUG
+static void
+udf_dump_discinfo(struct mmc_discinfo *di)
+{
+ char bits[128];
+
+ printf("Device/media info :\n");
+ printf("\tMMC profile 0x%02x\n", di->mmc_profile);
+ printf("\tderived class %d\n", di->mmc_class);
+ printf("\tsector size %d\n", di->sector_size);
+ printf("\tdisc state %d\n", di->disc_state);
+ printf("\tlast ses state %d\n", di->last_session_state);
+ printf("\tbg format state %d\n", di->bg_format_state);
+ printf("\tfrst track %d\n", di->first_track);
+ printf("\tfst on last ses %d\n", di->first_track_last_session);
+ printf("\tlst on last ses %d\n", di->last_track_last_session);
+ printf("\tlink block penalty %d\n", di->link_block_penalty);
+ snprintb(bits, sizeof(bits), MMC_DFLAGS_FLAGBITS, (uint64_t) di->disc_flags);
+ printf("\tdisc flags %s\n", bits);
+ printf("\tdisc id %x\n", di->disc_id);
+ printf("\tdisc barcode %"PRIx64"\n", di->disc_barcode);
+
+ printf("\tnum sessions %d\n", di->num_sessions);
+ printf("\tnum tracks %d\n", di->num_tracks);
+
+ snprintb(bits, sizeof(bits), MMC_CAP_FLAGBITS, di->mmc_cur);
+ printf("\tcapabilities cur %s\n", bits);
+ snprintb(bits, sizeof(bits), MMC_CAP_FLAGBITS, di->mmc_cap);
+ printf("\tcapabilities cap %s\n", bits);
+ printf("\n");
+ printf("\tlast_possible_lba %d\n", di->last_possible_lba);
+ printf("\n");
+}
+#else
+#define udf_dump_discinfo(a);
+#endif
+
+/* --------------------------------------------------------------------- */
+
+static int
+udf_emulate_discinfo(fsinfo_t *fsopts, struct mmc_discinfo *di,
+ int mmc_emuprofile)
+{
+ off_t sectors;
+
+ memset(di, 0, sizeof(struct mmc_discinfo));
+
+ /* file support */
+ if ((mmc_emuprofile != 0x01) && (fsopts->sectorsize != 2048))
+ warnx("cd/dvd/bd sectorsize is not set to default 2048");
Home |
Main Index |
Thread Index |
Old Index