NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/42410 (Bug in makefs gives unhandled exception on MIPS MagnumR4000)



> > cd9660.c:cd9660_compute_record_size() should round size variable.
> > -current was already fixed on changes for RISC OS metadata support
> > and netbsd-5 and netbsd-5-0 branches need a patch for this PR.
> 
> The following patch (from rev 1.25) should fix this PR. 

Umm, no, more fixes put with RISC OS support are required.
I've confirmed the following ones fix the problem.

Could you try this ISO created with these fixes?
ftp://ftp.NetBSD.org/pub/NetBSD/misc/tsutsui/iso/arccd-5.0.1_PATCH-20091217.iso.gz

src/usr.sbin/makefs/cd9660.c                    1.25 (partial)
src/usr.sbin/makefs/cd9669.h                    1.13
src/usr.sbin/makefs/cd9660/cd9660_write.c       1.10
src/usr.sbin/makefs/cd9660/iso9660_rrip.c       1.5, 1.6, 1.7, 1.8
src/usr.sbin/makefs/cd9660/iso9660_rrip.h       1.5

http://mail-index.NetBSD.org/source-changes/2009/01/08/msg215047.html
http://mail-index.NetBSD.org/source-changes/2009/01/09/msg215048.html
http://mail-index.NetBSD.org/source-changes/2009/01/10/msg215105.html
http://mail-index.NetBSD.org/source-changes/2009/01/10/msg215126.html (partial)

---
Index: cd9660.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660.c,v
retrieving revision 1.22.2.1
diff -u -r1.22.2.1 cd9660.c
--- cd9660.c    2 Feb 2009 03:32:34 -0000       1.22.2.1
+++ cd9660.c    17 Dec 2009 19:50:04 -0000
@@ -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: cd9660.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660.h,v
retrieving revision 1.12
diff -u -r1.12 cd9660.h
--- cd9660.h    27 Jul 2008 10:29:32 -0000      1.12
+++ cd9660.h    17 Dec 2009 19:50:05 -0000
@@ -199,6 +199,10 @@
        int susp_dot_entry_size;
        int susp_dot_dot_entry_size;
 
+       /* Data to put at the end of the System Use field */
+       int su_tail_size;
+       char *su_tail_data;
+
        /* Continuation area stuff */
        int susp_entry_ce_start;
        int susp_dot_ce_start;
Index: cd9660/cd9660_write.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660/cd9660_write.c,v
retrieving revision 1.9
diff -u -r1.9 cd9660_write.c
--- cd9660/cd9660_write.c       10 May 2008 19:00:07 -0000      1.9
+++ cd9660/cd9660_write.c       17 Dec 2009 19:50:05 -0000
@@ -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 */
 
@@ -344,30 +344,27 @@
                                    SEEK_SET);
                        }
 
-                       written = fwrite(&temp_record, 1, temp_record.length[0],
-                           fd);
-                       ca = 0;
+                       /* Write out the basic ISO directory record */
+                       written = fwrite(&temp_record, 1,
+                           temp->isoDirRecord->length[0], fd);
                        if (diskStructure.rock_ridge_enabled) {
-                               ca = cd9660_write_rr(fd, temp,
+                               cd9660_write_rr(fd, temp,
                                    cur_sector_offset, working_sector);
                        }
-
-                       if (ferror(fd)) {
+                       fseek(fd,
+                           working_sector * diskStructure.sectorSize +
+                           cur_sector_offset + temp_record.length[0] -
+                           temp->su_tail_size,
+                           SEEK_SET);
+                       if (temp->su_tail_size > 0)
+                               fwrite(temp->su_tail_data, 1,
+                                   temp->su_tail_size, fd);
+                       if (ferror(fd)) {
                                warnx("%s: write error", __func__);
                                goto out;
                        }
                        cur_sector_offset += temp_record.length[0];
 
-                       /*
-                        * If we had to go the the continuation area,
-                        * head back to where we should be.
-                        */
-                       if (ca) {
-                               fseek(fd,
-                                   working_sector * diskStructure.sectorSize +
-                                       cur_sector_offset,
-                                   SEEK_SET);
-                       }
                }
 
                /*
@@ -476,37 +473,39 @@
        return 1;
 }
 
-static int
+static void
 cd9660_write_rr(FILE *fd, cd9660node *writenode, int offset, int sector)
 {
        int in_ca = 0;
        struct ISO_SUSP_ATTRIBUTES *myattr;
 
        offset += writenode->isoDirRecord->length[0];
-
+       fseek(fd, sector * diskStructure.sectorSize + offset, SEEK_SET);
        /* Offset now points at the end of the record */
        TAILQ_FOREACH(myattr, &writenode->head, rr_ll) {
-               fseek(fd,
-                   in_ca ? offset : sector*diskStructure.sectorSize + offset,
-                   SEEK_SET);
                fwrite(&(myattr->attr), CD9660_SUSP_ENTRY_SIZE(myattr), 1, fd);
 
-               offset += CD9660_SUSP_ENTRY_SIZE(myattr);
                if (!in_ca) {
-                       if ((myattr->susp_type == SUSP_TYPE_SUSP) &&
-                           (myattr->entry_type == SUSP_ENTRY_SUSP_CE)) {
+                       offset += CD9660_SUSP_ENTRY_SIZE(myattr);
+                       if (myattr->last_in_suf) {
                                /*
                                 * Point the offset to the start of this
                                 * record's CE area
                                 */
-                               offset = (diskStructure.
-                                         susp_continuation_area_start_sector *
-                                           diskStructure.sectorSize)
-                                       + writenode->susp_entry_ce_start;
+                               fseek(fd, (diskStructure.
+                                       susp_continuation_area_start_sector *
+                                       diskStructure.sectorSize)
+                                   + writenode->susp_entry_ce_start,
+                                   SEEK_SET);
                                in_ca = 1;
                        }
                }
        }
 
-       return in_ca;
+       /*
+        * If we had to go the the continuation area, head back to
+        * where we should be.
+        */
+       if (in_ca)
+               fseek(fd, sector * diskStructure.sectorSize + offset, SEEK_SET);
 }
Index: cd9660/iso9660_rrip.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660/iso9660_rrip.c,v
retrieving revision 1.4
diff -u -r1.4 iso9660_rrip.c
--- cd9660/iso9660_rrip.c       18 Dec 2006 21:03:29 -0000      1.4
+++ cd9660/iso9660_rrip.c       17 Dec 2009 19:50:05 -0000
@@ -200,13 +200,14 @@
 static int
 cd9660_susp_handle_continuation_common(cd9660node *node, int space)
 {
-       int ca_used, susp_used, working;
-       struct ISO_SUSP_ATTRIBUTES *temp, *last = NULL, *CE;
-
+       int ca_used, susp_used, susp_used_pre_ce, working;
+       struct ISO_SUSP_ATTRIBUTES *temp, *pre_ce, *last, *CE, *ST;
+ 
+       pre_ce = last = NULL;
        working = 254 - space;
        /* printf("There are %i bytes to work with\n",working); */
 
-       susp_used = 0;
+       susp_used_pre_ce = susp_used = 0;
        ca_used = 0;
        TAILQ_FOREACH(temp, &node->head, rr_ll) {
                if (working < 0)
@@ -216,10 +217,18 @@
                 * CD9660_SUSP_ENTRY_SIZE(temp));
                 */
                working -= CD9660_SUSP_ENTRY_SIZE(temp);
-               if (working >= 28) {
+               if (working >= 0) {
                        last = temp;
                        susp_used += CD9660_SUSP_ENTRY_SIZE(temp);
                }
+               if (working >= 28) {
+                       /*
+                        * Remember the last entry after which we
+                        * could insert a "CE" entry.
+                        */
+                       pre_ce = last;
+                       susp_used_pre_ce = susp_used;
+               }
        }
 
        /* A CE entry is needed */
@@ -228,16 +237,34 @@
                        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);
-               susp_used += 28;
-
+               if (pre_ce != NULL)
+                       TAILQ_INSERT_AFTER(&node->head, pre_ce, CE, rr_ll);
+               else
+                       TAILQ_INSERT_HEAD(&node->head, CE, rr_ll);
+               last = CE;
+               susp_used = susp_used_pre_ce + 28;
                /* Count how much CA data is necessary */
-               for (temp = TAILQ_NEXT(CE, rr_ll); temp != NULL;
+               for (temp = TAILQ_NEXT(last, rr_ll); temp != NULL;
                     temp = TAILQ_NEXT(temp, rr_ll)) {
                        ca_used += CD9660_SUSP_ENTRY_SIZE(temp);
                }
        }
 
+       /* An ST entry is needed */
+       if (node->su_tail_size > 0) {
+               ST = cd9660node_susp_create_node(SUSP_TYPE_SUSP,
+                   SUSP_ENTRY_SUSP_ST, "ST", SUSP_LOC_ENTRY);
+               cd9660_susp_st(ST, node);
+               if (last != NULL)
+                       TAILQ_INSERT_AFTER(&node->head, last, ST, rr_ll);
+               else
+                       TAILQ_INSERT_HEAD(&node->head, ST, rr_ll);
+               last = ST;
+               susp_used += 4;
+       }
+       if (last != NULL)
+               last->last_in_suf = 1;
+
        node->susp_entry_size = susp_used;
        node->susp_entry_ce_length = ca_used;
 
@@ -433,6 +460,7 @@
 
        temp->susp_type = susp_type;
        temp->entry_type = entry_type;
+       temp->last_in_suf = 0;
        /* Phase this out */
        temp->type_of[0] = type_id[0];
        temp->type_of[1] = type_id[1];
Index: cd9660/iso9660_rrip.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/makefs/cd9660/iso9660_rrip.h,v
retrieving revision 1.4
diff -u -r1.4 iso9660_rrip.h
--- cd9660/iso9660_rrip.h       1 Feb 2006 22:19:35 -0000       1.4
+++ cd9660/iso9660_rrip.h       17 Dec 2009 19:50:05 -0000
@@ -203,6 +203,7 @@
        SUSP_ENTRIES attr;
        int type;
        char type_of[2];
+       char last_in_suf;       /* last entry in the System Use Field? */
        /* Dan's addons - will merge later. This allows use of a switch */
        char susp_type;         /* SUSP or RRIP */
        char entry_type;        /* Record type */

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index