CVS commit: src/sbin/newfs_udf

2018-12-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec  9 17:52:48 UTC 2018

Modified Files:
src/sbin/newfs_udf: udf_create.c

Log Message:
Address of packed member might not be aligned.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/newfs_udf/udf_create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_create.c
diff -u src/sbin/newfs_udf/udf_create.c:1.25 src/sbin/newfs_udf/udf_create.c:1.26
--- src/sbin/newfs_udf/udf_create.c:1.25	Tue Jun 16 19:18:55 2015
+++ src/sbin/newfs_udf/udf_create.c	Sun Dec  9 12:52:48 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.25 2015/06/16 23:18:55 christos Exp $ */
+/* $NetBSD: udf_create.c,v 1.26 2018/12/09 17:52:48 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf_create.c,v 1.25 2015/06/16 23:18:55 christos Exp $");
+__RCSID("$NetBSD: udf_create.c,v 1.26 2018/12/09 17:52:48 christos Exp $");
 
 #include 
 #include 
@@ -1720,10 +1720,10 @@ udf_extattr_append_internal(union dscrpt
 	struct extfile_entry   *efe;
 	struct extattrhdr_desc *extattrhdr;
 	struct impl_extattr_entry *implext;
-	uint32_t impl_attr_loc, appl_attr_loc, l_ea, a_l, exthdr_len;
-	uint32_t *l_eap, l_ad;
+	uint32_t impl_attr_loc, appl_attr_loc, l_ea, l_ad, a_l;
 	uint16_t *spos;
 	uint8_t *bpos, *data;
+	void *l_eap;
 
 	if (udf_rw16(dscr->tag.id) == TAGID_FENTRY) {
 		fe= &dscr->fe;
@@ -1741,20 +1741,22 @@ udf_extattr_append_internal(union dscrpt
 
 	/* should have a header! */
 	extattrhdr = (struct extattrhdr_desc *) data;
-	l_ea = udf_rw32(*l_eap);
+	memcpy(&l_ea, l_eap, sizeof(l_ea));
+	l_ea = udf_rw32(l_ea);
 	if (l_ea == 0) {
+		uint32_t exthdr_len;
 		assert(l_ad == 0);
 		/* create empty extended attribute header */
-		exthdr_len = sizeof(struct extattrhdr_desc);
+		l_ea = sizeof(struct extattrhdr_desc);
+		exthdr_len = udf_rw32(l_ea);
 
 		udf_inittag(&extattrhdr->tag, TAGID_EXTATTR_HDR, /* loc */ 0);
-		extattrhdr->impl_attr_loc = udf_rw32(exthdr_len);
-		extattrhdr->appl_attr_loc = udf_rw32(exthdr_len);
+		extattrhdr->impl_attr_loc = exthdr_len;
+		extattrhdr->appl_attr_loc = exthdr_len;
 		extattrhdr->tag.desc_crc_len = udf_rw16(8);
 
 		/* record extended attribute header length */
-		l_ea = exthdr_len;
-		*l_eap = udf_rw32(l_ea);
+		memcpy(l_eap, &exthdr_len, sizeof(exthdr_len));
 	}
 
 	/* extract locations */
@@ -1787,7 +1789,7 @@ udf_extattr_append_internal(union dscrpt
 	assert(appl_attr_loc == l_ea);
 
 	/* append the attribute at the end of the current space */
-	bpos = data + udf_rw32(*l_eap);
+	bpos = data + l_ea;
 	a_l  = udf_rw32(extattr->a_l);
 
 	/* update impl. attribute locations */
@@ -1802,7 +1804,8 @@ udf_extattr_append_internal(union dscrpt
 	/* copy and advance */
 	memcpy(bpos, extattr, a_l);
 	l_ea += a_l;
-	*l_eap = udf_rw32(l_ea);
+	l_ea = udf_rw32(l_ea);
+	memcpy(l_eap, &l_ea, sizeof(l_ea));
 
 	/* do the `dance` again backwards */
 	if (context.dscrver != 2) {



CVS commit: src/sbin/newfs_udf

2016-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar  9 19:48:24 UTC 2016

Modified Files:
src/sbin/newfs_udf: newfs_udf.c

Log Message:
PR/50920: David Binderman: fix leak


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.18 src/sbin/newfs_udf/newfs_udf.c:1.19
--- src/sbin/newfs_udf/newfs_udf.c:1.18	Fri Aug  9 11:11:08 2013
+++ src/sbin/newfs_udf/newfs_udf.c	Wed Mar  9 14:48:24 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.18 2013/08/09 15:11:08 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.19 2016/03/09 19:48:24 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -121,11 +121,13 @@ udf_write_sector(void *sector, uint64_t 
 	if ((seekpos == NULL) || (seekpos->sectornr != location)) {
 		pos = calloc(1, sizeof(struct wrsect));
 		if (pos == NULL)
-			return ENOMEM;
+			return errno;
 		/* allocate space for copy of sector data */
 		pos->sector_data = calloc(1, context.sector_size);
-		if (pos->sector_data == NULL)
-			return ENOMEM;
+		if (pos->sector_data == NULL) {
+			free(pos);
+			return errno;
+		}
 		pos->sectornr = location;
 
 		if (seekpos) {



CVS commit: src/sbin/newfs_udf

2015-01-02 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jan  2 21:01:12 UTC 2015

Modified Files:
src/sbin/newfs_udf: udf_write.c

Log Message:
Fix volumesetname to comply to UDF 2.01 [2.2.2.5]


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_udf/udf_write.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_write.c
diff -u src/sbin/newfs_udf/udf_write.c:1.8 src/sbin/newfs_udf/udf_write.c:1.9
--- src/sbin/newfs_udf/udf_write.c:1.8	Sun Aug 25 14:13:47 2013
+++ src/sbin/newfs_udf/udf_write.c	Fri Jan  2 21:01:12 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_write.c,v 1.8 2013/08/25 14:13:47 reinoud Exp $ */
+/* $NetBSD: udf_write.c,v 1.9 2015/01/02 21:01:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf_write.c,v 1.8 2013/08/25 14:13:47 reinoud Exp $");
+__RCSID("$NetBSD: udf_write.c,v 1.9 2015/01/02 21:01:12 reinoud Exp $");
 
 #include 
 #include 
@@ -317,6 +317,7 @@ udf_derive_format(int req_enable, int re
 int
 udf_proces_names(void)
 {
+	struct timeval time_of_day;
 	uint32_t primary_nr;
 	uint64_t volset_nr;
 
@@ -335,8 +336,9 @@ udf_proces_names(void)
 		if (mmc_discinfo.disc_flags & MMC_DFLAGS_BARCODEVALID) {
 			volset_nr = mmc_discinfo.disc_barcode;
 		} else {
-			volset_nr  =  (uint32_t) random();
-			volset_nr |= ((uint64_t) random()) << 32;
+			(void)gettimeofday(&time_of_day, NULL);
+			volset_nr  =  (uint64_t) random();
+			volset_nr |= ((uint64_t) time_of_day.tv_sec) << 32;
 		}
 		context.volset_name = calloc(128,1);
 		sprintf(context.volset_name, "%016"PRIx64, volset_nr);



CVS commit: src/sbin/newfs_udf

2013-08-25 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Aug 25 14:13:47 UTC 2013

Modified Files:
src/sbin/newfs_udf: udf_write.c

Log Message:
Add the blockingnr determination for the -rom versions


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/newfs_udf/udf_write.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_write.c
diff -u src/sbin/newfs_udf/udf_write.c:1.7 src/sbin/newfs_udf/udf_write.c:1.8
--- src/sbin/newfs_udf/udf_write.c:1.7	Tue Aug  6 08:18:08 2013
+++ src/sbin/newfs_udf/udf_write.c	Sun Aug 25 14:13:47 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_write.c,v 1.7 2013/08/06 08:18:08 reinoud Exp $ */
+/* $NetBSD: udf_write.c,v 1.8 2013/08/25 14:13:47 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf_write.c,v 1.7 2013/08/06 08:18:08 reinoud Exp $");
+__RCSID("$NetBSD: udf_write.c,v 1.8 2013/08/25 14:13:47 reinoud Exp $");
 
 #include 
 #include 
@@ -473,10 +473,12 @@ udf_do_newfs_prefix(void)
 	if (blockingnr <= 1) {
 		/* paranoia on blockingnr */
 		switch (mmc_discinfo.mmc_profile) {
+		case 0x08 : /* CDROM */
 		case 0x09 : /* CD-R*/
 		case 0x0a : /* CD-RW   */
 			blockingnr = 32;	/* UDF requirement */
 			break;
+		case 0x10 : /* DVDROM */
 		case 0x11 : /* DVD-R (DL) */
 		case 0x12 : /* DVD-RAM */
 		case 0x1b : /* DVD+R  */
@@ -485,6 +487,7 @@ udf_do_newfs_prefix(void)
 		case 0x14 : /* DVD-RW sequential */
 			blockingnr = 16;	/* SCSI definition */
 			break;
+		case 0x40 : /* BDROM */
 		case 0x41 : /* BD-R Sequential recording (SRM) */
 		case 0x42 : /* BD-R Random recording (RRM) */
 		case 0x43 : /* BD-RE */



CVS commit: src/sbin/newfs_udf

2013-08-10 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Sat Aug 10 23:25:35 UTC 2013

Modified Files:
src/sbin/newfs_udf: udf_create.c

Log Message:
Fix tool build under Mac OS X by using gettimeofday(2) instead of
clock_gettime(2). This needs a proper auto-config check.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sbin/newfs_udf/udf_create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_create.c
diff -u src/sbin/newfs_udf/udf_create.c:1.22 src/sbin/newfs_udf/udf_create.c:1.23
--- src/sbin/newfs_udf/udf_create.c:1.22	Tue Aug  6 13:15:30 2013
+++ src/sbin/newfs_udf/udf_create.c	Sat Aug 10 23:25:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.22 2013/08/06 13:15:30 reinoud Exp $ */
+/* $NetBSD: udf_create.c,v 1.23 2013/08/10 23:25:35 tron Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf_create.c,v 1.22 2013/08/06 13:15:30 reinoud Exp $");
+__RCSID("$NetBSD: udf_create.c,v 1.23 2013/08/10 23:25:35 tron Exp $");
 
 #include 
 #include 
@@ -646,7 +646,15 @@ udf_set_timestamp_now(struct timestamp *
 {
 	struct timespec now;
 
-	clock_gettime(CLOCK_REALTIME, &now);
+#ifdef CLOCK_REALTIME
+	(void)clock_gettime(CLOCK_REALTIME, &now);
+#else
+	struct timeval time_of_day;
+
+	(void)gettimeofday(&time_of_day, NULL);
+	now.tv_sec = time_of_day.tv_sec;
+	now.tv_nsec = time_of_day.tv_usec * 1000;
+#endif
 	udf_timespec_to_timestamp(&now, timestamp);
 }
 



CVS commit: src/sbin/newfs_udf

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 12:49:13 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.c udf_create.c udf_create.h

Log Message:
Oops, forgot to export a_udf_version() that checks if the input string is a
valid UDF version notation.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/newfs_udf/newfs_udf.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/newfs_udf/udf_create.c
cvs rdiff -u -r1.5 -r1.6 src/sbin/newfs_udf/udf_create.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.15 src/sbin/newfs_udf/newfs_udf.c:1.16
--- src/sbin/newfs_udf/newfs_udf.c:1.15	Mon Aug  5 14:11:30 2013
+++ src/sbin/newfs_udf/newfs_udf.c	Tue Aug  6 12:49:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.15 2013/08/05 14:11:30 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.16 2013/08/06 12:49:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -635,62 +635,7 @@ udf_do_newfs(void)
 	return error;
 }
 
-/* - */
-
-
-/* version can be specified as 0xabc or a.bc */
-static int
-parse_udfversion(const char *pos, uint32_t *version) {
-	int hex = 0;
-	char c1, c2, c3, c4;
-
-	*version = 0;
-	if (*pos == '0') {
-		pos++;
-		/* expect hex format */
-		hex = 1;
-		if (*pos++ != 'x')
-			return 1;
-	}
-
-	c1 = *pos++;
-	if (c1 < '0' || c1 > '9')
-		return 1;
-	c1 -= '0';
-
-	c2 = *pos++;
-	if (!hex) {
-		if (c2 != '.')
-			return 1;
-		c2 = *pos++;
-	}
-	if (c2 < '0' || c2 > '9')
-		return 1;
-	c2 -= '0';
-
-	c3 = *pos++;
-	if (c3 < '0' || c3 > '9')
-		return 1;
-	c3 -= '0';
-
-	c4 = *pos++;
-	if (c4 != 0)
-		return 1;
-
-	*version = c1 * 0x100 + c2 * 0x10 + c3;
-	return 0;
-}
-
-
-static int
-a_udf_version(const char *s, const char *id_type)
-{
-	uint32_t version;
 
-	if (parse_udfversion(s, &version))
-		errx(1, "unknown %s id %s; specify as hex or float", id_type, s);
-	return version;
-}
 
 /* - */
 

Index: src/sbin/newfs_udf/udf_create.c
diff -u src/sbin/newfs_udf/udf_create.c:1.20 src/sbin/newfs_udf/udf_create.c:1.21
--- src/sbin/newfs_udf/udf_create.c:1.20	Mon Aug  5 17:12:04 2013
+++ src/sbin/newfs_udf/udf_create.c	Tue Aug  6 12:49:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.20 2013/08/05 17:12:04 joerg Exp $ */
+/* $NetBSD: udf_create.c,v 1.21 2013/08/06 12:49:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf_create.c,v 1.20 2013/08/05 17:12:04 joerg Exp $");
+__RCSID("$NetBSD: udf_create.c,v 1.21 2013/08/06 12:49:13 reinoud Exp $");
 
 #include 
 #include 
@@ -103,6 +103,62 @@ udf_init_create_context(void)
 }
 
 
+/* version can be specified as 0xabc or a.bc */
+static int
+parse_udfversion(const char *pos, uint32_t *version) {
+	int hex = 0;
+	char c1, c2, c3, c4;
+
+	*version = 0;
+	if (*pos == '0') {
+		pos++;
+		/* expect hex format */
+		hex = 1;
+		if (*pos++ != 'x')
+			return 1;
+	}
+
+	c1 = *pos++;
+	if (c1 < '0' || c1 > '9')
+		return 1;
+	c1 -= '0';
+
+	c2 = *pos++;
+	if (!hex) {
+		if (c2 != '.')
+			return 1;
+		c2 = *pos++;
+	}
+	if (c2 < '0' || c2 > '9')
+		return 1;
+	c2 -= '0';
+
+	c3 = *pos++;
+	if (c3 < '0' || c3 > '9')
+		return 1;
+	c3 -= '0';
+
+	c4 = *pos++;
+	if (c4 != 0)
+		return 1;
+
+	*version = c1 * 0x100 + c2 * 0x10 + c3;
+	return 0;
+}
+
+
+/* parse a given string for an udf version */
+int
+a_udf_version(const char *s, const char *id_type)
+{
+	uint32_t version;
+
+	if (parse_udfversion(s, &version))
+		errx(1, "unknown %s id %s; specify as hex or float", id_type, s);
+	return version;
+}
+
+
 static uint32_t
 udf_space_bitmap_len(uint32_t part_size)
 {

Index: src/sbin/newfs_udf/udf_create.h
diff -u src/sbin/newfs_udf/udf_create.h:1.5 src/sbin/newfs_udf/udf_create.h:1.6
--- src/sbin/newfs_udf/udf_create.h:1.5	Mon Aug  5 17:12:04 2013
+++ src/sbin/newfs_udf/udf_create.h	Tue Aug  6 12:49:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.h,v 1.5 2013/08/05 17:12:04 joerg Exp $ */
+/* $NetBSD: udf_create.h,v 1.6 2013/08/06 12:49:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -216,6 +216,8 @@ extern struct udf_disclayout layout;
 
 /* prototypes */
 void udf_init_create_context(void);
+int a_udf_version(const char *s, const char *id_type);
+
 int udf_calculate_disc_layout(int format_flags, int min_udf,
 	uint32_t wrtrack_skew,
 	uint32_t first_lba, uint32_t last_lba,



CVS commit: src/sbin/newfs_udf

2013-08-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  6 12:15:21 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Fix article.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.17 src/sbin/newfs_udf/newfs_udf.8:1.18
--- src/sbin/newfs_udf/newfs_udf.8:1.17	Tue Aug  6 12:14:43 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Tue Aug  6 12:15:20 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.17 2013/08/06 12:14:43 wiz Exp $
+.\" $NetBSD: newfs_udf.8,v 1.18 2013/08/06 12:15:20 wiz Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -80,7 +80,7 @@ Prepend
 .Ar discid
 with volsetname separated with a ':' if wanted.
 For strict conformance and interchange, don't set this manually unless it has
-an unique hex number in the first 8 character positions.
+a unique hex number in the first 8 character positions.
 .It Fl p Ar percentage
 Percentage of partition to be initially reserved for metadata on the Metadata
 partition.



CVS commit: src/sbin/newfs_udf

2013-08-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  6 12:14:43 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Sort sections. Remove superfluous Ed.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.16 src/sbin/newfs_udf/newfs_udf.8:1.17
--- src/sbin/newfs_udf/newfs_udf.8:1.16	Tue Aug  6 11:57:25 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Tue Aug  6 12:14:43 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.16 2013/08/06 11:57:25 reinoud Exp $
+.\" $NetBSD: newfs_udf.8,v 1.17 2013/08/06 12:14:43 wiz Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -165,19 +165,6 @@ native sectorsize of 512 :
 .Bd -literal -offset indent
 newfs_udf -L "My USB stick" /dev/rsd0d
 .Ed
-.Sh BUGS
-The
-.Ar P
-and the
-.Ar S
-arguments have changed meaning.
-The meaning of
-.Ar S
-has been merged into
-.Ar P
-since
-.Nx 6.1 .
-.Ed
 .Sh SEE ALSO
 .Xr disktab 5 ,
 .Xr disklabel 8 ,
@@ -190,3 +177,15 @@ command first appeared in
 .Nx 5.0 .
 .Sh AUTHORS
 .An Reinoud Zandijk Aq Mt rein...@netbsd.org
+.Sh BUGS
+The
+.Ar P
+and the
+.Ar S
+arguments have changed meaning.
+The meaning of
+.Ar S
+has been merged into
+.Ar P
+since
+.Nx 6.1 .



CVS commit: src/sbin/newfs_udf

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 11:57:25 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Clarify volumeset name restrictions when specifying it in newfs_udf(8)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.15 src/sbin/newfs_udf/newfs_udf.8:1.16
--- src/sbin/newfs_udf/newfs_udf.8:1.15	Tue Aug  6 11:38:51 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Tue Aug  6 11:57:25 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.15 2013/08/06 11:38:51 reinoud Exp $
+.\" $NetBSD: newfs_udf.8,v 1.16 2013/08/06 11:57:25 reinoud Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -75,10 +75,12 @@ its causing problems.
 .It Fl P Ar discid
 Set the physical disc label to the specified
 .Ar discid .
+.Pp
 Prepend
 .Ar discid
 with volsetname separated with a ':' if wanted.
-For strict conformance and interchange, don't set this manually.
+For strict conformance and interchange, don't set this manually unless it has
+an unique hex number in the first 8 character positions.
 .It Fl p Ar percentage
 Percentage of partition to be initially reserved for metadata on the Metadata
 partition.



CVS commit: src/sbin/newfs_udf

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 11:38:51 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Fix misplaced BUGS section and fix layout


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.14 src/sbin/newfs_udf/newfs_udf.8:1.15
--- src/sbin/newfs_udf/newfs_udf.8:1.14	Mon Aug  5 14:28:48 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Tue Aug  6 11:38:51 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.14 2013/08/05 14:28:48 wiz Exp $
+.\" $NetBSD: newfs_udf.8,v 1.15 2013/08/06 11:38:51 reinoud Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -163,18 +163,6 @@ native sectorsize of 512 :
 .Bd -literal -offset indent
 newfs_udf -L "My USB stick" /dev/rsd0d
 .Ed
-.Sh SEE ALSO
-.Xr disktab 5 ,
-.Xr disklabel 8 ,
-.Xr mmcformat 8 ,
-.Xr newfs 8
-.Sh HISTORY
-The
-.Nm
-command first appeared in
-.Nx 5.0 .
-.Sh AUTHORS
-.An Reinoud Zandijk Aq Mt rein...@netbsd.org
 .Sh BUGS
 The
 .Ar P
@@ -187,3 +175,16 @@ has been merged into
 .Ar P
 since
 .Nx 6.1 .
+.Ed
+.Sh SEE ALSO
+.Xr disktab 5 ,
+.Xr disklabel 8 ,
+.Xr mmcformat 8 ,
+.Xr newfs 8
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Nx 5.0 .
+.Sh AUTHORS
+.An Reinoud Zandijk Aq Mt rein...@netbsd.org



CVS commit: src/sbin/newfs_udf

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 20:52:08 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.h udf_write.c udf_write.h

Log Message:
Fix newfs(8) to compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_udf/newfs_udf.h
cvs rdiff -u -r1.5 -r1.6 src/sbin/newfs_udf/udf_write.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_udf/udf_write.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.h
diff -u src/sbin/newfs_udf/newfs_udf.h:1.2 src/sbin/newfs_udf/newfs_udf.h:1.3
--- src/sbin/newfs_udf/newfs_udf.h:1.2	Mon Aug  5 17:12:04 2013
+++ src/sbin/newfs_udf/newfs_udf.h	Mon Aug  5 20:52:08 2013
@@ -41,9 +41,7 @@
 /* global variables describing disc and format requests */
 extern int	 fd;/* device: file descriptor */
 extern char	*dev;/* device: name		   */
-#if !HAVE_NBTOOL_CONFIG_H
 extern struct mmc_discinfo mmc_discinfo;	/* device: disc info	   */
-#endif
 
 extern char	*format_str;			/* format: string representation */
 extern int	 format_flags;			/* format: attribute flags	 */
@@ -61,9 +59,7 @@ struct udf_disclayout layout;
 
 /* prototypes */
 int udf_write_sector(void *sector, uint32_t location);
-#if !HAVE_NBTOOL_CONFIG_H
 int udf_update_trackinfo(struct mmc_discinfo *di, struct mmc_trackinfo *ti);
-#endif
 
 /* tmp */
 int writeout_write_queue(void);

Index: src/sbin/newfs_udf/udf_write.c
diff -u src/sbin/newfs_udf/udf_write.c:1.5 src/sbin/newfs_udf/udf_write.c:1.6
--- src/sbin/newfs_udf/udf_write.c:1.5	Mon Aug  5 17:12:04 2013
+++ src/sbin/newfs_udf/udf_write.c	Mon Aug  5 20:52:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_write.c,v 1.5 2013/08/05 17:12:04 joerg Exp $ */
+/* $NetBSD: udf_write.c,v 1.6 2013/08/05 20:52:08 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,9 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf_write.c,v 1.5 2013/08/05 17:12:04 joerg Exp $");
-
-#define _EXPOSE_MMC
+__RCSID("$NetBSD: udf_write.c,v 1.6 2013/08/05 20:52:08 reinoud Exp $");
 
 #include 
 #include 
@@ -43,8 +41,12 @@ __RCSID("$NetBSD: udf_write.c,v 1.5 2013
 #include 
 #include 
 #include 
+
 #if !HAVE_NBTOOL_CONFIG_H
+#define _EXPOSE_MMC
 #include 
+#else
+#include "udf/cdio_mmc_structs.h"
 #endif
 
 #include "udf_create.h"
@@ -54,7 +56,6 @@ __RCSID("$NetBSD: udf_write.c,v 1.5 2013
 
 union dscrptr *terminator_dscr;
 
-
 static int
 udf_write_phys(void *blob, uint32_t location, uint32_t sects)
 {
@@ -175,7 +176,6 @@ udf_data_alloc(int nblk, struct long_ad 
 int
 udf_derive_format(int req_enable, int req_disable, int force)
 {
-#if !HAVE_NBTOOL_CONFIG_H
 	/* disc writability, formatted, appendable */
 	if ((mmc_discinfo.mmc_cur & MMC_CAP_RECORDABLE) == 0) {
 		(void)printf("Can't newfs readonly device\n");
@@ -199,10 +199,8 @@ udf_derive_format(int req_enable, int re
 			return EROFS;
 		}
 	}
-#endif
 
 	/* determine UDF format */
-#if !HAVE_NBTOOL_CONFIG_H
 	format_flags = 0;
 	if (mmc_discinfo.mmc_cur & MMC_CAP_REWRITABLE) {
 		/* all rewritable media */
@@ -235,13 +233,6 @@ udf_derive_format(int req_enable, int re
 			format_flags |= FORMAT_WORM;
 		}
 	}
-#else
-	format_flags = FORMAT_REWRITABLE;
-	if (context.min_udf >= 0x0250) {
-		/* standard dictates meta as default */
-		format_flags |= FORMAT_META;
-	}
-#endif
 
 	/* enable/disable requests */
 	if (req_disable & FORMAT_META) {
@@ -257,7 +248,6 @@ udf_derive_format(int req_enable, int re
 
 	/* determine partition/media access type */
 	media_accesstype = UDF_ACCESSTYPE_NOT_SPECIFIED;
-#if !HAVE_NBTOOL_CONFIG_H
 	if (mmc_discinfo.mmc_cur & MMC_CAP_REWRITABLE) {
 		media_accesstype = UDF_ACCESSTYPE_OVERWRITABLE;
 		if (mmc_discinfo.mmc_cur & MMC_CAP_ERASABLE)
@@ -268,9 +258,6 @@ udf_derive_format(int req_enable, int re
 	}
 	if (mmc_discinfo.mmc_cur & MMC_CAP_PSEUDOOVERWRITE)
 		media_accesstype = UDF_ACCESSTYPE_PSEUDO_OVERWITE;
-#else
-	media_accesstype = UDF_ACCESSTYPE_OVERWRITABLE;
-#endif
 
 	/* patch up media accesstype */
 	if (req_enable & FORMAT_READONLY) {
@@ -336,30 +323,21 @@ udf_proces_names(void)
 	if (context.logvol_name == NULL)
 		context.logvol_name = strdup("anonymous");
 	if (context.primary_name == NULL) {
-#if !HAVE_NBTOOL_CONFIG_H
 		if (mmc_discinfo.disc_flags & MMC_DFLAGS_DISCIDVALID) {
 			primary_nr = mmc_discinfo.disc_id;
 		} else {
 			primary_nr = (uint32_t) random();
 		}
-#else
-		primary_nr = (uint32_t) random();
-#endif
 		context.primary_name = calloc(32, 1);
 		sprintf(context.primary_name, "%08"PRIx32, primary_nr);
 	}
 	if (context.volset_name == NULL) {
-#if !HAVE_NBTOOL_CONFIG_H
 		if (mmc_discinfo.disc_flags & MMC_DFLAGS_BARCODEVALID) {
 			volset_nr = mmc_discinfo.disc_barcode;
 		} else {
 			volset_nr  =  (uint32_t) random();
 			volset_nr |= ((uint64_t) random()) << 32;
 		}
-#else
-		volset_nr  =  (uint32_t) random();
-		volset_nr |= ((uint64_t) random()) << 32;
-#endif
 		cont

CVS commit: src/sbin/newfs_udf

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 16:44:58 UTC 2013

Modified Files:
src/sbin/newfs_udf: udf_create.c udf_write.c

Log Message:
Fix memset() arguments to use the right type for sizeof() and streamline its
use of sizeof() to allways use the right type.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/newfs_udf/udf_create.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_udf/udf_write.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_create.c
diff -u src/sbin/newfs_udf/udf_create.c:1.18 src/sbin/newfs_udf/udf_create.c:1.19
--- src/sbin/newfs_udf/udf_create.c:1.18	Mon Aug  5 14:11:30 2013
+++ src/sbin/newfs_udf/udf_create.c	Mon Aug  5 16:44:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.18 2013/08/05 14:11:30 reinoud Exp $ */
+/* $NetBSD: udf_create.c,v 1.19 2013/08/05 16:44:58 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: udf_create.c,v 1.18 2013/08/05 14:11:30 reinoud Exp $");
+__RCSID("$NetBSD: udf_create.c,v 1.19 2013/08/05 16:44:58 reinoud Exp $");
 #endif /* not lint */
 
 #include 
@@ -1550,7 +1550,7 @@ udf_create_fid(uint32_t diroff, struct f
 	uint32_t endfid;
 	uint32_t fidsize, lb_rest;
 
-	memset(fid, 0, sizeof(struct fileid_desc *));
+	memset(fid, 0, sizeof(*fid));
 	udf_inittag(&fid->tag, TAGID_FID, udf_rw32(ref->loc.lb_num));
 	fid->file_version_num = udf_rw16(1);	/* UDF 2.3.4.1 */
 	fid->file_char = file_char;
@@ -1993,7 +1993,7 @@ udf_append_meta_mapping_to_efe(struct ex
 	max_len = (max_len / layout.meta_blockingnr) * layout.meta_blockingnr;
 	max_len = max_len * context.sector_size;
 
-	memset(&mapping, 0, sizeof(struct short_ad));
+	memset(&mapping, 0, sizeof(mapping));
 	while (len) {
 		part_len = MIN(len, max_len);
 		mapping.lb_num   = udf_rw32(lb_num);
@@ -2227,7 +2227,7 @@ udf_create_VAT(union dscrptr **vat_dscr)
 
 	assert((layout.rootdir < 2) && (layout.fsd < 2));
 
-	memset(&dataloc, 0, sizeof(struct long_ad));
+	memset(&dataloc, 0, sizeof(dataloc));
 	dataloc.len = udf_rw32(context.vat_size);
 	dataloc.loc.part_num = udf_rw16(context.data_part);
 	dataloc.loc.lb_num   = udf_rw32(layout.vat);

Index: src/sbin/newfs_udf/udf_write.c
diff -u src/sbin/newfs_udf/udf_write.c:1.3 src/sbin/newfs_udf/udf_write.c:1.4
--- src/sbin/newfs_udf/udf_write.c:1.3	Mon Aug  5 14:11:30 2013
+++ src/sbin/newfs_udf/udf_write.c	Mon Aug  5 16:44:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_write.c,v 1.3 2013/08/05 14:11:30 reinoud Exp $ */
+/* $NetBSD: udf_write.c,v 1.4 2013/08/05 16:44:58 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: udf_write.c,v 1.3 2013/08/05 14:11:30 reinoud Exp $");
+__RCSID("$NetBSD: udf_write.c,v 1.4 2013/08/05 16:44:58 reinoud Exp $");
 #endif /* not lint */
 
 #define _EXPOSE_MMC
@@ -127,7 +127,7 @@ udf_write_dscr_virt(union dscrptr *dscr,
 void
 udf_metadata_alloc(int nblk, struct long_ad *pos)
 {
-	memset(pos, 0, sizeof(struct long_ad));
+	memset(pos, 0, sizeof(*pos));
 	pos->len	  = udf_rw32(nblk * context.sector_size);
 	pos->loc.lb_num   = udf_rw32(context.metadata_alloc_pos);
 	pos->loc.part_num = udf_rw16(context.metadata_part);
@@ -144,7 +144,7 @@ udf_metadata_alloc(int nblk, struct long
 void
 udf_data_alloc(int nblk, struct long_ad *pos)
 {
-	memset(pos, 0, sizeof(struct long_ad));
+	memset(pos, 0, sizeof(*pos));
 	pos->len	  = udf_rw32(nblk * context.sector_size);
 	pos->loc.lb_num   = udf_rw32(context.data_alloc_pos);
 	pos->loc.part_num = udf_rw16(context.data_part);



CVS commit: src/sbin/newfs_udf

2013-08-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Aug  5 14:28:48 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Sort.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.13 src/sbin/newfs_udf/newfs_udf.8:1.14
--- src/sbin/newfs_udf/newfs_udf.8:1.13	Mon Aug  5 14:11:30 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Mon Aug  5 14:28:48 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.13 2013/08/05 14:11:30 reinoud Exp $
+.\" $NetBSD: newfs_udf.8,v 1.14 2013/08/05 14:28:48 wiz Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -35,12 +35,12 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl cFM
+.Op Fl B Ar blockingsize
 .Op Fl L Ar loglabel
 .Op Fl P Ar discid
 .Op Fl p Ar percentage
 .Op Fl S Ar sectorsize
 .Op Fl s Ar size
-.Op Fl B Ar blockingsize
 .Op Fl t Ar gmtoff
 .Op Fl V Ar max_udf
 .Op Fl v Ar min_udf
@@ -54,6 +54,10 @@ suitable for the media currently inserte
 .Pp
 The options are as follow:
 .Bl -tag -width indent
+.It Fl B Ar blockingsize
+When creating image files, specify the blocking size or packetsize of the media
+to
+.Ar blockingsize .
 .It Fl c
 Perform a crude surface check first to weed out disc faults on rewritable
 media.
@@ -85,10 +89,6 @@ For strict conformance and interchange, 
 .It Fl s Ar size
 For image files, set the file size to the humanized size
 .Ar size .
-.It Fl B Ar blockingsize
-When creating image files, specify the blocking size or packetsize of the media
-to
-.Ar blockingsize .
 .It Fl t Ar gmtoff
 Use the specified
 .Ar gmtoff



CVS commit: src/sbin/newfs_udf

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 14:11:30 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8 newfs_udf.c udf_create.c udf_create.h
udf_write.c udf_write.h
Added Files:
src/sbin/newfs_udf: unicode.h

Log Message:
Adjust newfs_udf to be sharing code with the new `makefs -t udf' to be
comitted.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/newfs_udf/newfs_udf.8
cvs rdiff -u -r1.14 -r1.15 src/sbin/newfs_udf/newfs_udf.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/newfs_udf/udf_create.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_udf/udf_create.h
cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_udf/udf_write.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/newfs_udf/udf_write.h
cvs rdiff -u -r0 -r1.1 src/sbin/newfs_udf/unicode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.12 src/sbin/newfs_udf/newfs_udf.8:1.13
--- src/sbin/newfs_udf/newfs_udf.8:1.12	Sat Jul 20 21:39:58 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Mon Aug  5 14:11:30 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.12 2013/07/20 21:39:58 wiz Exp $
+.\" $NetBSD: newfs_udf.8,v 1.13 2013/08/05 14:11:30 reinoud Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd July 2, 2013
+.Dd August 2, 2013
 .Dt NEWFS_UDF 8
 .Os
 .Sh NAME
@@ -40,6 +40,7 @@
 .Op Fl p Ar percentage
 .Op Fl S Ar sectorsize
 .Op Fl s Ar size
+.Op Fl B Ar blockingsize
 .Op Fl t Ar gmtoff
 .Op Fl V Ar max_udf
 .Op Fl v Ar min_udf
@@ -84,6 +85,10 @@ For strict conformance and interchange, 
 .It Fl s Ar size
 For image files, set the file size to the humanized size
 .Ar size .
+.It Fl B Ar blockingsize
+When creating image files, specify the blocking size or packetsize of the media
+to
+.Ar blockingsize .
 .It Fl t Ar gmtoff
 Use the specified
 .Ar gmtoff

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.14 src/sbin/newfs_udf/newfs_udf.c:1.15
--- src/sbin/newfs_udf/newfs_udf.c:1.14	Thu Jul 18 12:44:21 2013
+++ src/sbin/newfs_udf/newfs_udf.c	Mon Aug  5 14:11:30 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.14 2013/07/18 12:44:21 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.15 2013/08/05 14:11:30 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -94,6 +94,7 @@ int	 format_flags;			/* format: attribut
 int	 media_accesstype;		/* derived from current mmc cap  */
 int	 check_surface;			/* for rewritables   */
 int	 imagefile_secsize;		/* for files			 */
+int	 emul_packetsize;		/* for discs and files		 */
 
 int	 wrtrack_skew;
 int	 meta_perc = UDF_META_PERC;
@@ -289,8 +290,9 @@ udf_update_discinfo(struct mmc_discinfo 
 		sectors = size / secsize;
 	} else {
 		/*
-		 * disc partition support; note we can't use DIOCGPART in userland so
-		 * get disc label and use the stat info to get the partition number.
+		 * disc partition support; note we can't use DIOCGPART in
+		 * userland so get disc label and use the stat info to get the
+		 * partition number.
 		 */
 		if (ioctl(fd, DIOCGDINFO, &disklab) == -1) {
 			/* failed to get disclabel! */
@@ -303,9 +305,10 @@ udf_update_discinfo(struct mmc_discinfo 
 		partnr = DISKPART(st.st_rdev);
 		dp = &disklab.d_partitions[partnr];
 
-		/* TODO problem with last_possible_lba on resizable VND; request */
+		/* TODO problem with last_possible_lba on resizable VND */
 		if (dp->p_size == 0) {
-			perror("faulty disklabel partition returned, check label\n");
+			perror("faulty disklabel partition returned, "
+"check label\n");
 			return EIO;
 		}
 
@@ -363,7 +366,7 @@ udf_update_trackinfo(struct mmc_discinfo
 	ti->flags = MMC_TRACKINFO_LRA_VALID | MMC_TRACKINFO_NWA_VALID;
 
 	ti->track_start= 0;
-	ti->packet_size= 1;
+	ti->packet_size= emul_packetsize;
 
 	/* TODO support for resizable vnd */
 	ti->track_size= di->last_possible_lba;
@@ -722,6 +725,7 @@ main(int argc, char **argv)
 	check_surface = 0;
 	setsize   = 0;
 	imagefile_secsize = 512;	/* minimum allowed sector size */
+	emul_packetsize   = 32;		/* reasonable default */
 
 	srandom((unsigned long) time(NULL));
 	udf_init_create_context();
@@ -740,7 +744,7 @@ main(int argc, char **argv)
 	context.gmtoff = tm->tm_gmtoff;
 
 	/* process options */
-	while ((ch = getopt(argc, argv, "cFL:Mp:P:s:S:t:v:V:")) != -1) {
+	while ((ch = getopt(argc, argv, "cFL:Mp:P:s:S:B:t:v:V:")) != -1) {
 		switch (ch) {
 		case 'c' :
 			check_surface = 1;
@@ -802,6 +806,12 @@ main(int argc, char **argv)
 			imagefile_secsize = a_num(optarg, "secsize");
 			imagefile_secsize = MAX(512, imagefile_secsize);
 			break;
+		case 'B' :
+			emul_packetsize = a_num(optarg,
+"blockingnr, packetsize");
+			emul_packetsize = MAX(emul_packetsize, 1);
+			emul_packetsize = MIN(emul_packetsize, 32);
+			

CVS commit: src/sbin/newfs_udf

2013-07-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul 18 12:50:51 UTC 2013

Modified Files:
src/sbin/newfs_udf: udf_write.c

Log Message:
Add comment to udf_do_rootdir(). Might eventually be moved to newfs_udf(8)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/newfs_udf/udf_write.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_write.c
diff -u src/sbin/newfs_udf/udf_write.c:1.1 src/sbin/newfs_udf/udf_write.c:1.2
--- src/sbin/newfs_udf/udf_write.c:1.1	Thu Jul 18 12:44:21 2013
+++ src/sbin/newfs_udf/udf_write.c	Thu Jul 18 12:50:51 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_write.c,v 1.1 2013/07/18 12:44:21 reinoud Exp $ */
+/* $NetBSD: udf_write.c,v 1.2 2013/07/18 12:50:51 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: udf_write.c,v 1.1 2013/07/18 12:44:21 reinoud Exp $");
+__RCSID("$NetBSD: udf_write.c,v 1.2 2013/07/18 12:50:51 reinoud Exp $");
 #endif /* not lint */
 
 #define _EXPOSE_MMC
@@ -709,6 +709,7 @@ udf_do_newfs_prefix(void)
 }
 
 
+/* specific routine for newfs to create empty rootdirectory */
 int
 udf_do_rootdir(void) {
 	union dscrptr *root_dscr;



CVS commit: src/sbin/newfs_udf

2013-07-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul 18 12:44:21 UTC 2013

Modified Files:
src/sbin/newfs_udf: Makefile newfs_udf.c
Added Files:
src/sbin/newfs_udf: newfs_udf.h udf_write.c udf_write.h

Log Message:
Initial split up for making newfs_udf(8) routines suitable for makefs_udf(8)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_udf/Makefile
cvs rdiff -u -r1.13 -r1.14 src/sbin/newfs_udf/newfs_udf.c
cvs rdiff -u -r0 -r1.1 src/sbin/newfs_udf/newfs_udf.h \
src/sbin/newfs_udf/udf_write.c src/sbin/newfs_udf/udf_write.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/Makefile
diff -u src/sbin/newfs_udf/Makefile:1.3 src/sbin/newfs_udf/Makefile:1.4
--- src/sbin/newfs_udf/Makefile:1.3	Sat Apr 11 07:58:13 2009
+++ src/sbin/newfs_udf/Makefile	Thu Jul 18 12:44:21 2013
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.3 2009/04/11 07:58:13 lukem Exp $
+# $NetBSD: Makefile,v 1.4 2013/07/18 12:44:21 reinoud Exp $
 
 .include 
 
 PROG=	newfs_udf
 MAN=	newfs_udf.8
-SRCS=	newfs_udf.c udf_create.c udf_osta.c fattr.c
+SRCS=	newfs_udf.c udf_create.c udf_write.c udf_osta.c fattr.c
 
 MOUNT=  ${NETBSDSRCDIR}/sbin/mount
 KUDF=	${NETBSDSRCDIR}/sys/fs/udf

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.13 src/sbin/newfs_udf/newfs_udf.c:1.14
--- src/sbin/newfs_udf/newfs_udf.c:1.13	Tue Jul  2 14:59:01 2013
+++ src/sbin/newfs_udf/newfs_udf.c	Thu Jul 18 12:44:21 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.13 2013/07/02 14:59:01 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.14 2013/07/18 12:44:21 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -65,25 +65,23 @@
 
 #include "mountprog.h"
 #include "udf_create.h"
-
-/* general settings */
-#define UDF_512_TRACK	0	/* NOT recommended */
-#define UDF_META_PERC  20	/* picked */
-
+#include "udf_write.h"
+#include "newfs_udf.h"
 
 /* prototypes */
 int newfs_udf(int argc, char **argv);
 static void usage(void) __attribute__((__noreturn__));
 
-int udf_derive_format(int req_en, int req_dis, int force);
-int udf_proces_names(void);
-int udf_do_newfs(void);
-
-/* Identifying myself */
-#define APP_NAME		"*NetBSD newfs"
-#define APP_VERSION_MAIN	0
-#define APP_VERSION_SUB		3
-#define IMPL_NAME		"*NetBSD userland UDF"
+
+/* queue for temporary storage of sectors to be written out */
+struct wrsect {
+	uint32_t  sectornr;
+	uint8_t	 *sector_data;
+	TAILQ_ENTRY(wrsect) next;
+};
+
+/* write queue and track blocking skew */
+TAILQ_HEAD(wrsect_list, wrsect) write_queue;
 
 
 /* global variables describing disc and format requests */
@@ -102,29 +100,13 @@ int	 meta_perc = UDF_META_PERC;
 float	 meta_fract = (float) UDF_META_PERC / 100.0;
 
 
-/* shared structure between udf_create.c users */
-struct udf_create_context context;
-struct udf_disclayout layout;
-
-
-/* queue for temporary storage of sectors to be written out */
-struct wrsect {
-	uint32_t  sectornr;
-	uint8_t	 *sector_data;
-	TAILQ_ENTRY(wrsect) next;
-};
-
-/* write queue and track blocking skew */
-TAILQ_HEAD(wrsect_list, wrsect) write_queue;
-
-
 /* - */
 
 /*
  * write queue implementation
  */
 
-static int
+int
 udf_write_sector(void *sector, uint32_t location)
 {
 	struct wrsect *pos, *seekpos;
@@ -167,7 +149,7 @@ udf_write_sector(void *sector, uint32_t 
  * XXX support for growing vnd?
  */
 
-static int
+int
 writeout_write_queue(void)
 {
 	struct wrsect *pos;
@@ -357,7 +339,7 @@ udf_update_discinfo(struct mmc_discinfo 
 }
 
 
-static int
+int
 udf_update_trackinfo(struct mmc_discinfo *di, struct mmc_trackinfo *ti)
 {
 	int error, class;
@@ -447,276 +429,6 @@ udf_synchronise_caches(void)
 /* - */
 
 static int
-udf_write_dscr_phys(union dscrptr *dscr, uint32_t location,
-	uint32_t sects)
-{
-	uint32_t phys, cnt;
-	uint8_t *bpos;
-	int error;
-
-	dscr->tag.tag_loc = udf_rw32(location);
-	(void) udf_validate_tag_and_crc_sums(dscr);
-
-	for (cnt = 0; cnt < sects; cnt++) {
-		bpos  = (uint8_t *) dscr;
-		bpos += context.sector_size * cnt;
-
-		phys = location + cnt;
-		error = udf_write_sector(bpos, phys);
-		if (error)
-			return error;
-	}
-	return 0;
-}
-
-
-static int
-udf_write_dscr_virt(union dscrptr *dscr, uint32_t location, uint32_t vpart,
-	uint32_t sects)
-{
-	struct file_entry *fe;
-	struct extfile_entry *efe;
-	struct extattrhdr_desc *extattrhdr;
-	uint32_t phys, cnt;
-	uint8_t *bpos;
-	int error;
-
-	extattrhdr = NULL;
-	if (udf_rw16(dscr->tag.id) == TAGID_FENTRY) {
-		fe = (struct file_entry *) dscr;
-		if (udf_rw32(fe->l_ea) > 0)
-			extattrhdr = (struct extattrhdr_desc *) fe->data;
-	}
-	if (udf_rw16(dscr->tag.id) == TAGID_EXTFENTRY) {
-		efe = (struct extfile_entry *) dscr;
-		if (udf_rw32(efe->l_ea) > 0)
-			extattrhdr = (struct extattrhdr_desc 

CVS commit: src/sbin/newfs_udf

2013-07-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jul  2 20:53:10 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Sort sections. New sentence, new line. Fix macro.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.10 src/sbin/newfs_udf/newfs_udf.8:1.11
--- src/sbin/newfs_udf/newfs_udf.8:1.10	Tue Jul  2 14:59:01 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Tue Jul  2 20:53:10 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.10 2013/07/02 14:59:01 reinoud Exp $
+.\" $NetBSD: newfs_udf.8,v 1.11 2013/07/02 20:53:10 wiz Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -158,15 +158,6 @@ native sectorsize of 512 :
 .Bd -literal -offset indent
 newfs_udf -L "My USB stick" /dev/rsd0d
 .Ed
-.Sh BUGS
-The
-.Ar P
-and the
-.Ar S
-arguments have changed meaning. The meaning of
-.Ar S
-has been merged into
-.Ar P since NetBSD 6.1.
 .Sh SEE ALSO
 .Xr disktab 5 ,
 .Xr disklabel 8 ,
@@ -179,3 +170,15 @@ command first appeared in
 .Nx 5.0 .
 .Sh AUTHORS
 .An Reinoud Zandijk Aq rein...@netbsd.org
+.Sh BUGS
+The
+.Ar P
+and the
+.Ar S
+arguments have changed meaning.
+The meaning of
+.Ar S
+has been merged into
+.Ar P
+since
+.Nx 6.1 .



CVS commit: src/sbin/newfs_udf

2013-07-02 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Jul  2 14:59:01 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8 newfs_udf.c

Log Message:
Update newfs_udf to allow for creating file images with -F and specifying
sector sizes with -S.

For this i had to recycle the -S parameter but its preserved as an extension
to the -P parameter. These parameters are hardly ever use though since using
either or both the origional -S and the -P parameter without specific values
would break the standard. Also the -F now has a double meaning.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/newfs_udf/newfs_udf.8
cvs rdiff -u -r1.12 -r1.13 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.9 src/sbin/newfs_udf/newfs_udf.8:1.10
--- src/sbin/newfs_udf/newfs_udf.8:1.9	Sat Jun 29 20:41:47 2013
+++ src/sbin/newfs_udf/newfs_udf.8	Tue Jul  2 14:59:01 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.9 2013/06/29 20:41:47 reinoud Exp $
+.\" $NetBSD: newfs_udf.8,v 1.10 2013/07/02 14:59:01 reinoud Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd June 29, 2013
+.Dd July 2, 2013
 .Dt NEWFS_UDF 8
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 .Op Fl L Ar loglabel
 .Op Fl P Ar discid
 .Op Fl p Ar percentage
-.Op Fl S Ar setlabel
+.Op Fl S Ar sectorsize
 .Op Fl s Ar size
 .Op Fl t Ar gmtoff
 .Op Fl V Ar max_udf
@@ -57,7 +57,8 @@ The options are as follow:
 Perform a crude surface check first to weed out disc faults on rewritable
 media.
 .It Fl F
-Force file system construction on non-empty recordable media.
+Force file system construction on non-empty recordable media or create an
+image file.
 .It Fl L Ar loglabel
 Set the disc logical label to the specified
 .Ar loglabel .
@@ -69,17 +70,20 @@ its causing problems.
 .It Fl P Ar discid
 Set the physical disc label to the specified
 .Ar discid .
+Prepend
+.Ar discid
+with volsetname separated with a ':' if wanted.
 For strict conformance and interchange, don't set this manually.
 .It Fl p Ar percentage
 Percentage of partition to be initially reserved for metadata on the Metadata
 partition.
 It defaults to 20 %.
-.It Fl S Ar setlabel
-Set the disc set label to the specified
-.Ar setlabel .
+.It Fl S Ar sectorsize
+Set the sectorsize for image files.
 For strict conformance and interchange, don't set this manually.
 .It Fl s Ar size
-Ignored for now.
+For image files, set the file size to the humanized size
+.Ar size .
 .It Fl t Ar gmtoff
 Use the specified
 .Ar gmtoff
@@ -123,7 +127,7 @@ Create a file system, using the specifie
 .Pa /dev/rcd0d
 with the default UDF version :
 .Bd -literal -offset indent
-newfs_udf -S "Encyclopedia" -L "volume 2" -P "copy-nr-1" /dev/rcd0d
+newfs_udf -P "Encyclopedia:copy-nr-1" -L "volume 2" /dev/rcd0d
 .Ed
 .Pp
 Create a 4.8 GiB sparse file and configure it using
@@ -137,12 +141,32 @@ vnconfig -c vnd0 bigdisk.2048.udf 2048/1
 newfs_udf -L bigdisk /dev/rvnd0d
 .Ed
 .Pp
+Create a 2 GiB file and create a new UDF file system on it using the default
+512 byte sector size :
+.Bd -literal -offset indent
+newfs_udf -L bigdisk2 -F -s 2G bigdisk2.iso
+.Ed
+.Pp
+Create a 200 MiB file and create a new UDF file system on it using a sector size
+of 2048 :
+.Bd -literal -offset indent
+newfs_udf -L bigdisk2 -F -s 200M -S 2048 bigdisk3.iso
+.Ed
+.Pp
 Create a new UDF file system on the inserted USB stick using its
-.Dq native
-sectorsize of 512 :
+native sectorsize of 512 :
 .Bd -literal -offset indent
 newfs_udf -L "My USB stick" /dev/rsd0d
 .Ed
+.Sh BUGS
+The
+.Ar P
+and the
+.Ar S
+arguments have changed meaning. The meaning of
+.Ar S
+has been merged into
+.Ar P since NetBSD 6.1.
 .Sh SEE ALSO
 .Xr disktab 5 ,
 .Xr disklabel 8 ,

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.12 src/sbin/newfs_udf/newfs_udf.c:1.13
--- src/sbin/newfs_udf/newfs_udf.c:1.12	Thu May 26 07:59:08 2011
+++ src/sbin/newfs_udf/newfs_udf.c	Tue Jul  2 14:59:01 2013
@@ -1,7 +1,7 @@
-/* $NetBSD: newfs_udf.c,v 1.12 2011/05/26 07:59:08 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.13 2013/07/02 14:59:01 reinoud Exp $ */
 
 /*
- * Copyright (c) 2006, 2008 Reinoud Zandijk
+ * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
  * All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
@@ -95,6 +95,7 @@ char	*format_str;			/* format: string re
 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	 wrtrack_skew;
 int	 meta_perc = UDF_META_PERC;
@@ -283,9 +284,10 @@ udf_dump_discinfo(struct mmc_discinfo *d
 static int
 udf_update_d

CVS commit: src/sbin/newfs_udf

2013-06-29 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jun 29 20:41:47 UTC 2013

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Small rewording of the examples section.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.8 src/sbin/newfs_udf/newfs_udf.8:1.9
--- src/sbin/newfs_udf/newfs_udf.8:1.8	Thu Apr 28 17:17:51 2011
+++ src/sbin/newfs_udf/newfs_udf.8	Sat Jun 29 20:41:47 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.8 2011/04/28 17:17:51 wiz Exp $
+.\" $NetBSD: newfs_udf.8,v 1.9 2013/06/29 20:41:47 reinoud Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd December 23, 2009
+.Dd June 29, 2013
 .Dt NEWFS_UDF 8
 .Os
 .Sh NAME
@@ -119,31 +119,30 @@ This can be done using
 .Pp
 The default UDF version is version 2.01.
 .Sh EXAMPLES
-.Bd -literal -offset indent
-newfs_udf -S "Encyclopedia" -L "volume 2" -P "copy-nr-1" /dev/rcd0d
-.Ed
-.Pp
 Create a file system, using the specified names on the device
 .Pa /dev/rcd0d
-with the default UDF version.
-.Pp
+with the default UDF version :
 .Bd -literal -offset indent
-dd if=/dev/zero of=bigdisk.2048.udf seek=999 count=1
-vnconfig -c vnd0 bigdisk.2048.udf 2048/1/1/1
-newfs_udf -L bigdisk /dev/rvnd0d
+newfs_udf -S "Encyclopedia" -L "volume 2" -P "copy-nr-1" /dev/rcd0d
 .Ed
 .Pp
 Create a 4.8 GiB sparse file and configure it using
 .Xr vnconfig 8
 to be a 2048 sector size disc and create a new UDF file system on
-.Pa /dev/rvnd0d .
+.Pa /dev/rvnd0d
+:
 .Bd -literal -offset indent
-newfs_udf -L "My USB stick" /dev/rsd0d
+dd if=/dev/zero of=bigdisk.2048.udf seek=999 count=1
+vnconfig -c vnd0 bigdisk.2048.udf 2048/1/1/1
+newfs_udf -L bigdisk /dev/rvnd0d
 .Ed
 .Pp
 Create a new UDF file system on the inserted USB stick using its
 .Dq native
-sectorsize of 512.
+sectorsize of 512 :
+.Bd -literal -offset indent
+newfs_udf -L "My USB stick" /dev/rsd0d
+.Ed
 .Sh SEE ALSO
 .Xr disktab 5 ,
 .Xr disklabel 8 ,



CVS commit: src/sbin/newfs_udf

2011-05-26 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu May 26 07:59:09 UTC 2011

Modified Files:
src/sbin/newfs_udf: newfs_udf.c

Log Message:
Fix accidental use of logical && instead of binary & in rare case.

Bug noticed by Joerg and clang :)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.11 src/sbin/newfs_udf/newfs_udf.c:1.12
--- src/sbin/newfs_udf/newfs_udf.c:1.11	Fri Jan 21 22:32:13 2011
+++ src/sbin/newfs_udf/newfs_udf.c	Thu May 26 07:59:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.11 2011/01/21 22:32:13 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.12 2011/05/26 07:59:08 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -581,7 +581,7 @@
 		(void)printf("\tunrecognised enable/disable req.\n");
 		return EIO;
 	}
-	if ((format_flags && FORMAT_VAT) && UDF_512_TRACK)
+	if ((format_flags & FORMAT_VAT) & UDF_512_TRACK)
 		format_flags |= FORMAT_TRACK512;
 
 	/* determine partition/media access type */



CVS commit: src/sbin/newfs_udf

2011-04-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr 28 17:17:51 UTC 2011

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Sort options and option descriptions. Fix a typo. New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.7 src/sbin/newfs_udf/newfs_udf.8:1.8
--- src/sbin/newfs_udf/newfs_udf.8:1.7	Wed Dec 23 09:18:48 2009
+++ src/sbin/newfs_udf/newfs_udf.8	Thu Apr 28 17:17:51 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.7 2009/12/23 09:18:48 mbalmer Exp $
+.\" $NetBSD: newfs_udf.8,v 1.8 2011/04/28 17:17:51 wiz Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -37,9 +37,9 @@
 .Op Fl cFM
 .Op Fl L Ar loglabel
 .Op Fl P Ar discid
+.Op Fl p Ar percentage
 .Op Fl S Ar setlabel
 .Op Fl s Ar size
-.Op Fl p Ar percentage
 .Op Fl t Ar gmtoff
 .Op Fl V Ar max_udf
 .Op Fl v Ar min_udf
@@ -61,23 +61,25 @@
 .It Fl L Ar loglabel
 Set the disc logical label to the specified
 .Ar loglabel .
+.It Fl M
+Disable metadata partition creation when selected UDF version or media dictates
+this.
+For strict conformance and interchange, don't disable this unless
+its causing problems.
 .It Fl P Ar discid
-Set the phyisical disc label to the specified
+Set the physical disc label to the specified
 .Ar discid .
 For strict conformance and interchange, don't set this manually.
+.It Fl p Ar percentage
+Percentage of partition to be initially reserved for metadata on the Metadata
+partition.
+It defaults to 20 %.
 .It Fl S Ar setlabel
 Set the disc set label to the specified
 .Ar setlabel .
 For strict conformance and interchange, don't set this manually.
-.It Fl M
-Disable metadata partition creation when selected UDF version or media dictates
-this. For strict conformance and interchange, don't disable this unless its
-causing problems.
 .It Fl s Ar size
 Ignored for now.
-.It Fl p Ar percentage
-Percentage of partition to be initially reserved for metadata on the Metadata
-partition. It defaults to 20 %.
 .It Fl t Ar gmtoff
 Use the specified
 .Ar gmtoff



CVS commit: src/sbin/newfs_udf

2011-01-21 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jan 21 22:32:13 UTC 2011

Modified Files:
src/sbin/newfs_udf: newfs_udf.c

Log Message:
When requesting to disable metadata partitions, also disable low formatting.
When no meta and not low formatting we can lower the required UDF version.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.10 src/sbin/newfs_udf/newfs_udf.c:1.11
--- src/sbin/newfs_udf/newfs_udf.c:1.10	Fri Jan 21 22:10:51 2011
+++ src/sbin/newfs_udf/newfs_udf.c	Fri Jan 21 22:32:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.10 2011/01/21 22:10:51 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.11 2011/01/21 22:32:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -573,7 +573,7 @@
 
 	/* enable/disable requests */
 	if (req_disable & FORMAT_META) {
-		format_flags &= ~FORMAT_META;
+		format_flags &= ~(FORMAT_META | FORMAT_LOW);
 		req_disable  &= ~FORMAT_META;
 	}
 	if (req_disable || req_enable) {
@@ -608,7 +608,8 @@
 		context.min_udf = MAX(context.min_udf, 0x0260);
 
 	/* adjust maximum version limits not to tease or break things */
-	if (!(format_flags & FORMAT_META) && (context.max_udf > 0x200))
+	if (!(format_flags & (FORMAT_META | FORMAT_LOW)) &&
+	(context.max_udf > 0x200))
 		context.max_udf = 0x201;
 
 	if ((format_flags & (FORMAT_VAT | FORMAT_SPARABLE)) == 0)



CVS commit: src/sbin/newfs_udf

2011-01-21 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jan 21 22:10:51 UTC 2011

Modified Files:
src/sbin/newfs_udf: newfs_udf.c

Log Message:
Fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.9 src/sbin/newfs_udf/newfs_udf.c:1.10
--- src/sbin/newfs_udf/newfs_udf.c:1.9	Tue Jan  4 23:42:48 2011
+++ src/sbin/newfs_udf/newfs_udf.c	Fri Jan 21 22:10:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.9 2011/01/04 23:42:48 wiz Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.10 2011/01/21 22:10:51 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -1549,7 +1549,7 @@
 		return EXIT_FAILURE;
 	}
 
-	/* Formatting can only be done on raw devices */
+	/* formatting can only be done on raw devices */
 	if (!S_ISCHR(st.st_mode)) {
 		printf("%s is not a raw device\n", dev);
 		close(fd);



CVS commit: src/sbin/newfs_udf

2011-01-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jan  4 23:42:48 UTC 2011

Modified Files:
src/sbin/newfs_udf: newfs_udf.c

Log Message:
Fix memory leaks. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.8 src/sbin/newfs_udf/newfs_udf.c:1.9
--- src/sbin/newfs_udf/newfs_udf.c:1.8	Thu Sep 17 10:37:28 2009
+++ src/sbin/newfs_udf/newfs_udf.c	Tue Jan  4 23:42:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.8 2009/09/17 10:37:28 reinoud Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.9 2011/01/04 23:42:48 wiz Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -848,8 +848,10 @@
 			/* block is bad */
 			printf("BAD block at %08d + %d \n",
 loc, layout.blockingnr);
-			if ((error = udf_register_bad_block(loc)))
+			if ((error = udf_register_bad_block(loc))) {
+free(buffer);
 return error;
+			}
 			num_errors ++;
 		}
 		loc += layout.blockingnr;
@@ -868,8 +870,10 @@
 			/* block is bad */
 			printf("BAD block at %08d + %d \n",
 loc, layout.blockingnr);
-			if ((error = udf_register_bad_block(loc)))
+			if ((error = udf_register_bad_block(loc))) {
+free(buffer);
 return error;
+			}
 			num_errors ++;
 		}
 		loc += layout.blockingnr;
@@ -904,8 +908,10 @@
 		/* wipe at least 6 times 2048 byte `sectors' */
 		for (cnt = 0; cnt < 6 *dpos; cnt++) {
 			pos = layout.iso9660_vrs + cnt;
-			if ((error = udf_write_sector(iso9660_vrs_desc, pos)))
+			if ((error = udf_write_sector(iso9660_vrs_desc, pos))) {
+free(iso9660_vrs_desc);
 return error;
+			}
 		}
 
 		/* common VRS fields in all written out ISO descriptors */
@@ -915,8 +921,10 @@
 
 		/* BEA01, NSR[23], TEA01 */
 		memcpy(iso9660_vrs_desc->identifier, "BEA01", 5);
-		if ((error = udf_write_sector(iso9660_vrs_desc, pos)))
+		if ((error = udf_write_sector(iso9660_vrs_desc, pos))) {
+			free(iso9660_vrs_desc);
 			return error;
+		}
 		pos += dpos;
 
 		if (context.dscrver == 2)
@@ -924,15 +932,20 @@
 		else
 			memcpy(iso9660_vrs_desc->identifier, "NSR03", 5);
 		;
-		if ((error = udf_write_sector(iso9660_vrs_desc, pos)))
+		if ((error = udf_write_sector(iso9660_vrs_desc, pos))) {
+			free(iso9660_vrs_desc);
 			return error;
+		}
 		pos += dpos;
 
 		memcpy(iso9660_vrs_desc->identifier, "TEA01", 5);
-		if ((error = udf_write_sector(iso9660_vrs_desc, pos)))
+		if ((error = udf_write_sector(iso9660_vrs_desc, pos))) {
+			free(iso9660_vrs_desc);
 			return error;
+		}
 	}
 
+	free(iso9660_vrs_desc);
 	/* return success */
 	return 0;
 }
@@ -1062,14 +1075,18 @@
 
 	loc = (format_flags & FORMAT_TRACK512) ? layout.vds1 : ti.track_start;
 	for (; loc < layout.part_start_lba; loc++) {
-		if ((error = udf_write_sector(zero_dscr, loc)))
+		if ((error = udf_write_sector(zero_dscr, loc))) {
+			free(zero_dscr);
 			return error;
+		}
 	}
+	free(zero_dscr);
 
 	/* Create anchors */
 	for (cnt = 0; cnt < 3; cnt++) {
-		if ((error = udf_create_anchor(cnt)))
+		if ((error = udf_create_anchor(cnt))) {
 			return error;
+		}
 	}
 
 	/* 



CVS commit: src/sbin/newfs_udf

2009-12-23 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Wed Dec 23 09:18:48 UTC 2009

Modified Files:
src/sbin/newfs_udf: newfs_udf.8

Log Message:
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/newfs_udf/newfs_udf.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.8
diff -u src/sbin/newfs_udf/newfs_udf.8:1.6 src/sbin/newfs_udf/newfs_udf.8:1.7
--- src/sbin/newfs_udf/newfs_udf.8:1.6	Wed Dec 23 09:13:21 2009
+++ src/sbin/newfs_udf/newfs_udf.8	Wed Dec 23 09:18:48 2009
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_udf.8,v 1.6 2009/12/23 09:13:21 mbalmer Exp $
+.\" $NetBSD: newfs_udf.8,v 1.7 2009/12/23 09:18:48 mbalmer Exp $
 .\"
 .\" Copyright (c) 2008 Reinoud Zandijk
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd January 18, 2009
+.Dd December 23, 2009
 .Dt NEWFS_UDF 8
 .Os
 .Sh NAME



CVS commit: src/sbin/newfs_udf

2009-09-17 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Sep 17 10:37:29 UTC 2009

Modified Files:
src/sbin/newfs_udf: newfs_udf.c

Log Message:
Update TODO message; we can format with meta data partitions, only not yet for
BD-R, i.e. UDF 2.60.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/newfs_udf/newfs_udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/newfs_udf.c
diff -u src/sbin/newfs_udf/newfs_udf.c:1.7 src/sbin/newfs_udf/newfs_udf.c:1.8
--- src/sbin/newfs_udf/newfs_udf.c:1.7	Sun Jan 18 00:21:09 2009
+++ src/sbin/newfs_udf/newfs_udf.c	Thu Sep 17 10:37:28 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_udf.c,v 1.7 2009/01/18 00:21:09 lukem Exp $ */
+/* $NetBSD: newfs_udf.c,v 1.8 2009/09/17 10:37:28 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 /*
  * TODO
- * - implement meta data partition formatting.
+ * - implement metadata formatting for BD-R
  * - implement support for a read-only companion partition?
  */
 



CVS commit: src/sbin/newfs_udf

2009-05-19 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue May 19 12:13:03 UTC 2009

Modified Files:
src/sbin/newfs_udf: udf_create.c

Log Message:
Fix newfs_udf to create a valid disc images on bigendian machines.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/newfs_udf/udf_create.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs_udf/udf_create.c
diff -u src/sbin/newfs_udf/udf_create.c:1.15 src/sbin/newfs_udf/udf_create.c:1.16
--- src/sbin/newfs_udf/udf_create.c:1.15	Sun Feb 15 08:23:31 2009
+++ src/sbin/newfs_udf/udf_create.c	Tue May 19 12:13:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.15 2009/02/15 08:23:31 dholland Exp $ */
+/* $NetBSD: udf_create.c,v 1.16 2009/05/19 12:13:02 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: udf_create.c,v 1.15 2009/02/15 08:23:31 dholland Exp $");
+__RCSID("$NetBSD: udf_create.c,v 1.16 2009/05/19 12:13:02 reinoud Exp $");
 #endif /* not lint */
 
 #include 
@@ -1055,7 +1055,7 @@
 	assert(lvid);
 	assert(logvol);
 
-	lvid->integrity_type = udf_rw16(type);
+	lvid->integrity_type = udf_rw32(type);
 
 	num_partmappings = udf_rw32(logvol->n_pm);
 
@@ -1298,7 +1298,7 @@
 	fid->file_char = UDF_FILE_CHAR_DIR | UDF_FILE_CHAR_PAR;
 	fid->icb = *parent;
 	fid->icb.longad_uniqueid = udf_rw32((uint32_t) unique_id);
-	fid->tag.desc_crc_len = fidsize - UDF_DESC_TAG_LENGTH;
+	fid->tag.desc_crc_len = udf_rw16(fidsize - UDF_DESC_TAG_LENGTH);
 
 	/* we have to do the fid here explicitly for simplicity */
 	udf_validate_tag_and_crc_sums((union dscrptr *) fid);