CVS commit: [netbsd-5] src/usr.sbin/makefs

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jul 15 22:39:02 UTC 2011

Modified Files:
src/usr.sbin/makefs [netbsd-5]: cd9660.c
src/usr.sbin/makefs/cd9660 [netbsd-5]: iso9660_rrip.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1638):
usr.sbin/makefs/cd9660/iso9660_rrip.c: revision 1.9
usr.sbin/makefs/cd9660/iso9660_rrip.c: revision 1.10
usr.sbin/makefs/cd9660.c: revision 1.30
- remove unnecessary (pasto?) line on RRIP PL handling for moved dir
- RRIP RE length should be 4, not 0
Apply fixes for PR bin/44114 (makefs(8) -t cd9660 -o rockridge creates
corrupted cd9660fs):
 - makefs/cd9660.c:
  - cd9660_rrip_move_directory() should also update lenght[0] and
name_len[0] in dir-isoDirRecord
 - makefs/cd9660/iso9660_rrip.c:
  - cd9660_rrip_finalize_node() should check rr_real_parent in node-parent,
not in node itself in RRIP_PL case
  - cd9660_rrip_initialize_node() should update only node passed as arg
so handle RRIP_PL in DOTDOT case
Fixes malformed dotdot entries in deep (more than 8 level) directories
moved into .rr_moved dir.
Should be pulled up to netbsd-5.
(no official ISO has such deep dirs, but cobalt restorecd is affected)


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.2 -r1.22.2.3 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.4.18.4 -r1.4.18.5 src/usr.sbin/makefs/cd9660/iso9660_rrip.c

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

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.22.2.2 src/usr.sbin/makefs/cd9660.c:1.22.2.3
--- src/usr.sbin/makefs/cd9660.c:1.22.2.2	Sat Jan  2 06:45:03 2010
+++ src/usr.sbin/makefs/cd9660.c	Fri Jul 15 22:39:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.22.2.2 2010/01/02 06:45:03 snj Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.22.2.3 2011/07/15 22:39:02 riz Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.22.2.2 2010/01/02 06:45:03 snj Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.22.2.3 2011/07/15 22:39:02 riz Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -1299,6 +1299,8 @@
 	/* Set the new name */
 	memset(dir-isoDirRecord-name, 0, ISO_FILENAME_MAXLENGTH_WITH_PADDING);
 	strncpy(dir-isoDirRecord-name, newname, 8);
+	dir-isoDirRecord-length[0] = 34 + 8;
+	dir-isoDirRecord-name_len[0] = 8;
 
 	return dir;
 }

Index: src/usr.sbin/makefs/cd9660/iso9660_rrip.c
diff -u src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.4 src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.5
--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.4	Sat Jan  2 06:45:03 2010
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c	Fri Jul 15 22:39:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso9660_rrip.c,v 1.4.18.4 2010/01/02 06:45:03 snj Exp $	*/
+/*	$NetBSD: iso9660_rrip.c,v 1.4.18.5 2011/07/15 22:39:02 riz Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -43,7 +43,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.4 2010/01/02 06:45:03 snj Exp $);
+__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.5 2011/07/15 22:39:02 riz Exp $);
 #endif  /* !__lint */
 
 static void cd9660_rrip_initialize_inode(cd9660node *);
@@ -185,10 +185,11 @@
 			break;
 		case SUSP_ENTRY_RRIP_PL:
 			/* Look at rr_real_parent */
-			if (node-rr_real_parent == NULL)
+			if (node-parent == NULL ||
+			node-parent-rr_real_parent == NULL)
 return -1;
 			cd9660_bothendian_dword(
-node-rr_real_parent-fileDataSector,
+node-parent-rr_real_parent-fileDataSector,
 (unsigned char *)
 t-attr.rr_entry.PL.dir_loc);
 			break;
@@ -398,6 +399,13 @@
 			cd9660node_rrip_px(current, grandparent-node);
 			TAILQ_INSERT_TAIL(node-head, current, rr_ll);
 		}
+		/* Handle PL */
+		if (parent != NULL  parent-rr_real_parent != NULL) {
+			current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
+			SUSP_ENTRY_RRIP_PL, PL, SUSP_LOC_DOTDOT);
+			cd9660_rrip_PL(current,node);
+			TAILQ_INSERT_TAIL(node-head, current, rr_ll);
+		}
 	} else {
 		cd9660_rrip_initialize_inode(node);
 
@@ -437,14 +445,6 @@
 SUSP_ENTRY_RRIP_RE, RE, SUSP_LOC_ENTRY);
 			cd9660_rrip_RE(current,node);
 			TAILQ_INSERT_TAIL(node-head, current, rr_ll);
-
-			/* Handle PL */
-			current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
-SUSP_ENTRY_RRIP_PL, PL, SUSP_LOC_DOTDOT);
-			cd9660_rrip_PL(current,node-dot_dot_record);
-			TAILQ_INSERT_TAIL(node-dot_dot_record-head, current,
-			rr_ll);
-			TAILQ_INSERT_TAIL(node-head, current, rr_ll);
 		}
 	}
 	return 1;
@@ -498,7 +498,7 @@
 int
 cd9660_rrip_RE(struct ISO_SUSP_ATTRIBUTES *p, cd9660node *node __unused)
 {
-	p-attr.rr_entry.RE.h.length[0] = 0;
+	p-attr.rr_entry.RE.h.length[0] = 4;
 	p-attr.rr_entry.RE.h.version[0] = 1;
 	return 1;
 }



CVS commit: [netbsd-5] src/usr.sbin/makefs/cd9660

2010-01-01 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Jan  2 06:41:03 UTC 2010

Modified Files:
src/usr.sbin/makefs/cd9660 [netbsd-5]: iso9660_rrip.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1198):
usr.sbin/makefs/cd9660/iso9660_rrip.c: revision 1.5
When splitting a System Use Area between a System Use field and a
Continuation Area, be sure to insert the CE record at the correct
point in the chain of SUSP records.  Without this, makefs emits
an invalid image if any file needs a Continuation Area.  The bug
seems to have been introduced with the conversion to TAILQs.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.18.1 src/usr.sbin/makefs/cd9660/iso9660_rrip.c

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

Modified files:

Index: src/usr.sbin/makefs/cd9660/iso9660_rrip.c
diff -u src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4 src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.1
--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4	Mon Dec 18 21:03:29 2006
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c	Sat Jan  2 06:41:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso9660_rrip.c,v 1.4 2006/12/18 21:03:29 christos Exp $	*/
+/*	$NetBSD: iso9660_rrip.c,v 1.4.18.1 2010/01/02 06:41:03 snj Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -43,7 +43,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: iso9660_rrip.c,v 1.4 2006/12/18 21:03:29 christos Exp $);
+__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.1 2010/01/02 06:41:03 snj Exp $);
 #endif  /* !__lint */
 
 static void cd9660_rrip_initialize_inode(cd9660node *);
@@ -228,7 +228,7 @@
 			SUSP_ENTRY_SUSP_CE, CE, SUSP_LOC_ENTRY);
 		cd9660_susp_ce(CE, node);
 		/* This will automatically insert at the appropriate location */
-		TAILQ_INSERT_TAIL(node-head, CE, rr_ll);
+		TAILQ_INSERT_AFTER(node-head, last, CE, rr_ll);
 		susp_used += 28;
 
 		/* Count how much CA data is necessary */



CVS commit: [netbsd-5] src/usr.sbin/makefs/cd9660

2010-01-01 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Jan  2 06:41:48 UTC 2010

Modified Files:
src/usr.sbin/makefs/cd9660 [netbsd-5]: iso9660_rrip.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1198):
usr.sbin/makefs/cd9660/iso9660_rrip.c: revision 1.6
Fix another bug in SUSP CE handling: when the SUSP records fit into
the System Use field with fewer then 28 bytes to spare, we were
remembering the wrong length for the System Use field and hence
emitting a corrupt directory entry.  This could be triggered by trying
to build a filesystem containing a regular file with a 120-byte name.
Now we're a little more careful.


To generate a diff of this commit:
cvs rdiff -u -r1.4.18.1 -r1.4.18.2 src/usr.sbin/makefs/cd9660/iso9660_rrip.c

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

Modified files:

Index: src/usr.sbin/makefs/cd9660/iso9660_rrip.c
diff -u src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.1 src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.2
--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.1	Sat Jan  2 06:41:03 2010
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c	Sat Jan  2 06:41:47 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso9660_rrip.c,v 1.4.18.1 2010/01/02 06:41:03 snj Exp $	*/
+/*	$NetBSD: iso9660_rrip.c,v 1.4.18.2 2010/01/02 06:41:47 snj Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -43,7 +43,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.1 2010/01/02 06:41:03 snj Exp $);
+__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.2 2010/01/02 06:41:47 snj Exp $);
 #endif  /* !__lint */
 
 static void cd9660_rrip_initialize_inode(cd9660node *);
@@ -200,7 +200,7 @@
 static int
 cd9660_susp_handle_continuation_common(cd9660node *node, int space)
 {
-	int ca_used, susp_used, working;
+	int ca_used, susp_used, susp_used_last, working;
 	struct ISO_SUSP_ATTRIBUTES *temp, *last = NULL, *CE;
 
 	working = 254 - space;
@@ -216,9 +216,15 @@
 		 * CD9660_SUSP_ENTRY_SIZE(temp));
 		 */
 		working -= CD9660_SUSP_ENTRY_SIZE(temp);
+		if (working = 0)
+			susp_used += CD9660_SUSP_ENTRY_SIZE(temp);
 		if (working = 28) {
+			/*
+			 * Remember the last entry after which we
+			 * could insert a CE entry.
+			 */
 			last = temp;
-			susp_used += CD9660_SUSP_ENTRY_SIZE(temp);
+			susp_used_last = susp_used;
 		}
 	}
 
@@ -229,7 +235,7 @@
 		cd9660_susp_ce(CE, node);
 		/* This will automatically insert at the appropriate location */
 		TAILQ_INSERT_AFTER(node-head, last, CE, rr_ll);
-		susp_used += 28;
+		susp_used = susp_used_last + 28;
 
 		/* Count how much CA data is necessary */
 		for (temp = TAILQ_NEXT(CE, rr_ll); temp != NULL;



CVS commit: [netbsd-5] src/usr.sbin/makefs/cd9660

2010-01-01 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Jan  2 06:42:45 UTC 2010

Modified Files:
src/usr.sbin/makefs/cd9660 [netbsd-5]: iso9660_rrip.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1198):
usr.sbin/makefs/cd9660/iso9660_rrip.c: revision 1.7
Initialize a local variable to get rid of a may be used uninitialized
warning (turned into error by -Werror).


To generate a diff of this commit:
cvs rdiff -u -r1.4.18.2 -r1.4.18.3 src/usr.sbin/makefs/cd9660/iso9660_rrip.c

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

Modified files:

Index: src/usr.sbin/makefs/cd9660/iso9660_rrip.c
diff -u src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.2 src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.3
--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.4.18.2	Sat Jan  2 06:41:47 2010
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c	Sat Jan  2 06:42:45 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso9660_rrip.c,v 1.4.18.2 2010/01/02 06:41:47 snj Exp $	*/
+/*	$NetBSD: iso9660_rrip.c,v 1.4.18.3 2010/01/02 06:42:45 snj Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -43,7 +43,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.2 2010/01/02 06:41:47 snj Exp $);
+__RCSID($NetBSD: iso9660_rrip.c,v 1.4.18.3 2010/01/02 06:42:45 snj Exp $);
 #endif  /* !__lint */
 
 static void cd9660_rrip_initialize_inode(cd9660node *);
@@ -200,7 +200,7 @@
 static int
 cd9660_susp_handle_continuation_common(cd9660node *node, int space)
 {
-	int ca_used, susp_used, susp_used_last, working;
+	int ca_used, susp_used, susp_used_last = 0, working;
 	struct ISO_SUSP_ATTRIBUTES *temp, *last = NULL, *CE;
 
 	working = 254 - space;



CVS commit: [netbsd-5] src/usr.sbin/makefs

2010-01-01 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Jan  2 06:45:03 UTC 2010

Modified Files:
src/usr.sbin/makefs [netbsd-5]: cd9660.c cd9660.h
src/usr.sbin/makefs/cd9660 [netbsd-5]: cd9660_write.c iso9660_rrip.c
iso9660_rrip.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1198):
usr.sbin/makefs/cd9660.c: revision 1.25 via patch
usr.sbin/makefs/cd9660.h: revision 1.13 via patch
usr.sbin/makefs/cd9660/cd9660_write.c: revision 1.10
usr.sbin/makefs/cd9660/iso9660_rrip.c: revision 1.8
usr.sbin/makefs/cd9660/iso9660_rrip.h: revision 1.5
Add support for encoding RISC OS metadata into ISO 9660 filesystems.
This is done by adding the general ability to stuff non-SUSP data into
the end of the System Use field of a Directory Record, which required
some amount of rewriting of the SUSP support.  I think the result is
at least as good as what came before, and I've fixed at least one bug
along the way.  Tested against RISC OS 3.70 on my Risc PC.
Oh, why do we want it?  It should allow us to make acorn{26,32} CDs that
can be booted directly from RISC OS without mucking around copying the
bootloader to a native filing system.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.1 -r1.22.2.2 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.12 -r1.12.4.1 src/usr.sbin/makefs/cd9660.h
cvs rdiff -u -r1.9 -r1.9.4.1 src/usr.sbin/makefs/cd9660/cd9660_write.c
cvs rdiff -u -r1.4.18.3 -r1.4.18.4 src/usr.sbin/makefs/cd9660/iso9660_rrip.c
cvs rdiff -u -r1.4 -r1.4.26.1 src/usr.sbin/makefs/cd9660/iso9660_rrip.h

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

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.22.2.1 src/usr.sbin/makefs/cd9660.c:1.22.2.2
--- src/usr.sbin/makefs/cd9660.c:1.22.2.1	Mon Feb  2 03:32:34 2009
+++ src/usr.sbin/makefs/cd9660.c	Sat Jan  2 06:45:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.22.2.1 2009/02/02 03:32:34 snj Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.22.2.2 2010/01/02 06:45:03 snj Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.22.2.1 2009/02/02 03:32:34 snj Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.22.2.2 2010/01/02 06:45:03 snj Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -187,6 +187,7 @@
 	temp-isoDirRecord = NULL;
 	temp-isoExtAttributes = NULL;
 	temp-rr_real_parent = temp-rr_relocated = NULL;
+	temp-su_tail_data = NULL;
 	return temp;
 }
 
@@ -1759,6 +1760,9 @@
 
 	if (diskStructure.rock_ridge_enabled)
 		size += node-susp_entry_size;
+	size += node-su_tail_size;
+	size += size  1; /* Ensure length of record is even. */
+	assert(size = 254);
 	return size;
 }
 

Index: src/usr.sbin/makefs/cd9660.h
diff -u src/usr.sbin/makefs/cd9660.h:1.12 src/usr.sbin/makefs/cd9660.h:1.12.4.1
--- src/usr.sbin/makefs/cd9660.h:1.12	Sun Jul 27 10:29:32 2008
+++ src/usr.sbin/makefs/cd9660.h	Sat Jan  2 06:45:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.h,v 1.12 2008/07/27 10:29:32 reinoud Exp $	*/
+/*	$NetBSD: cd9660.h,v 1.12.4.1 2010/01/02 06:45:03 snj Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -208,6 +208,10 @@
 	int susp_dot_ce_length;
 	int susp_dot_dot_ce_length;
 
+	/* Data to put at the end of the System Use field */
+	int su_tail_size;
+	char *su_tail_data;
+
 	/*** PATH TABLE STUFF ***/
 	int level;			/*depth*/
 	int ptnumber;

Index: src/usr.sbin/makefs/cd9660/cd9660_write.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_write.c:1.9 src/usr.sbin/makefs/cd9660/cd9660_write.c:1.9.4.1
--- src/usr.sbin/makefs/cd9660/cd9660_write.c:1.9	Sat May 10 19:00:07 2008
+++ src/usr.sbin/makefs/cd9660/cd9660_write.c	Sat Jan  2 06:45:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_write.c,v 1.9 2008/05/10 19:00:07 skrll Exp $	*/
+/*	$NetBSD: cd9660_write.c,v 1.9.4.1 2010/01/02 06:45:03 snj Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660_write.c,v 1.9 2008/05/10 19:00:07 skrll Exp $);
+__RCSID($NetBSD: cd9660_write.c,v 1.9.4.1 2010/01/02 06:45:03 snj Exp $);
 #endif  /* !__lint */
 
 static int cd9660_write_volume_descriptors(FILE *);
@@ -48,7 +48,7 @@
 #if 0
 static int cd9660_write_buffered(FILE *, int, int, const unsigned char*);
 #endif
-static int cd9660_write_rr(FILE *, cd9660node *, int, int);
+static void cd9660_write_rr(FILE *, cd9660node *, int, int);
 
 /*
  * Write the image
@@ -271,7 +271,7 @@
 	int written;
 	iso_directory_record_cd9660 temp_record;
 	cd9660node *temp;
-	int ca = 0, rv = 0;
+	int rv = 0;
 
 	/* Todo : clean up variables */
 
@@ -343,31 +343,27 @@
 working_sector * diskStructure.sectorSize,
 SEEK_SET);
 			}
-
-			written =