Module Name:    src
Committed By:   tsutsui
Date:           Sun May 29 17:07:58 UTC 2011

Modified Files:
        src/usr.sbin/makefs: cd9660.c
        src/usr.sbin/makefs/cd9660: iso9660_rrip.c

Log Message:
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.29 -r1.30 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.9 -r1.10 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.29 src/usr.sbin/makefs/cd9660.c:1.30
--- src/usr.sbin/makefs/cd9660.c:1.29	Sun May 22 21:51:39 2011
+++ src/usr.sbin/makefs/cd9660.c	Sun May 29 17:07:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.29 2011/05/22 21:51:39 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.30 2011/05/29 17:07:57 tsutsui 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.29 2011/05/22 21:51:39 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.30 2011/05/29 17:07:57 tsutsui Exp $");
 #endif  /* !__lint */
 
 #include <string.h>
@@ -1315,6 +1315,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.9 src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.10
--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.9	Sat May 28 11:59:29 2011
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c	Sun May 29 17:07:58 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso9660_rrip.c,v 1.9 2011/05/28 11:59:29 tsutsui Exp $	*/
+/*	$NetBSD: iso9660_rrip.c,v 1.10 2011/05/29 17:07:58 tsutsui 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.9 2011/05/28 11:59:29 tsutsui Exp $");
+__RCSID("$NetBSD: iso9660_rrip.c,v 1.10 2011/05/29 17:07:58 tsutsui 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,13 +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);
 		}
 	}
 	return 1;

Reply via email to