svn commit: r224836 - in stable/7/usr.sbin/makefs: . cd9660
Marius Strobl
marius at FreeBSD.org
Sat Aug 13 13:15:39 UTC 2011
Author: marius
Date: Sat Aug 13 13:15:38 2011
New Revision: 224836
URL: http://svn.freebsd.org/changeset/base/224836
Log:
MFC: r224762
Sync makefs(8) ISO 9660 support with NetBSD:
o cd9960 -> cd9660
o Move inclusion of sys/endian.h from cd9660_eltorito.c to cd9660.h
since actual user is not cd9660_eltorito.c but iso.h and
cd9660_eltorito.h.
Actually, include order/place of sys/endian.h doesn't matter on
netbsd since it is always included by sys/types.h but it's not
true on other system. This should fix cross build breakage on
freebsd introduced by rev. 1.16 of cd9660_eltorito.c.
Problem reported and fix suggested on twitter.
o Fix fd leaks in error cases. Found by cppcheck.
o RRIP RE length should be 4, not 0
o Apply fixes for PR bin/44114 (makefs(8) -t cd9660 -o rockridge creates
corrupted cd9660fs), iso9660_rrip.c part:
- 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)
Reviewed by: mm
Obtained from: NetBSD
Modified:
stable/7/usr.sbin/makefs/cd9660.c
stable/7/usr.sbin/makefs/cd9660.h
stable/7/usr.sbin/makefs/cd9660/cd9660_conversion.c
stable/7/usr.sbin/makefs/cd9660/cd9660_eltorito.c
stable/7/usr.sbin/makefs/cd9660/cd9660_write.c
stable/7/usr.sbin/makefs/cd9660/iso9660_rrip.c
Directory Properties:
stable/7/usr.sbin/makefs/ (props changed)
Modified: stable/7/usr.sbin/makefs/cd9660.c
==============================================================================
--- stable/7/usr.sbin/makefs/cd9660.c Sat Aug 13 13:15:27 2011 (r224835)
+++ stable/7/usr.sbin/makefs/cd9660.c Sat Aug 13 13:15:38 2011 (r224836)
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660.c,v 1.27 2010/10/27 18:51:34 christos Exp $ */
+/* $NetBSD: cd9660.c,v 1.31 2011/08/06 23:25:19 christos Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -127,7 +127,7 @@ static int cd9660_setup_volume_descripto
static int cd9660_fill_extended_attribute_record(cd9660node *);
#endif
static void cd9660_sort_nodes(cd9660node *);
-static int cd9960_translate_node_common(cd9660node *);
+static int cd9660_translate_node_common(cd9660node *);
static int cd9660_translate_node(fsnode *, cd9660node *);
static int cd9660_compare_filename(const char *, const char *);
static void cd9660_sorted_child_insert(cd9660node *, cd9660node *);
@@ -809,7 +809,7 @@ cd9660_fill_extended_attribute_record(cd
#endif
static int
-cd9960_translate_node_common(cd9660node *newnode)
+cd9660_translate_node_common(cd9660node *newnode)
{
time_t tim;
int test;
@@ -846,7 +846,7 @@ cd9960_translate_node_common(cd9660node
}
/*
- * Translate fsnode to cd9960node
+ * Translate fsnode to cd9660node
* Translate filenames and other metadata, including dates, sizes,
* permissions, etc
* @param struct fsnode * The node generated by makefs
@@ -875,7 +875,7 @@ cd9660_translate_node(fsnode *node, cd96
if (!(S_ISDIR(node->type)))
newnode->fileDataLength = node->inode->st.st_size;
- if (cd9960_translate_node_common(newnode) == 0)
+ if (cd9660_translate_node_common(newnode) == 0)
return 0;
/* Finally, overwrite some of the values that are set by default */
@@ -2042,7 +2042,7 @@ cd9660_create_file(const char * name, cd
return NULL;
*temp->node->inode = *me->node->inode;
- if (cd9960_translate_node_common(temp) == 0)
+ if (cd9660_translate_node_common(temp) == 0)
return NULL;
return temp;
}
@@ -2069,7 +2069,7 @@ cd9660_create_directory(const char *name
return NULL;
*temp->node->inode = *me->node->inode;
- if (cd9960_translate_node_common(temp) == 0)
+ if (cd9660_translate_node_common(temp) == 0)
return NULL;
return temp;
}
Modified: stable/7/usr.sbin/makefs/cd9660.h
==============================================================================
--- stable/7/usr.sbin/makefs/cd9660.h Sat Aug 13 13:15:27 2011 (r224835)
+++ stable/7/usr.sbin/makefs/cd9660.h Sat Aug 13 13:15:38 2011 (r224836)
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660.h,v 1.15 2010/10/27 18:51:34 christos Exp $ */
+/* $NetBSD: cd9660.h,v 1.17 2011/06/23 02:35:56 enami Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -50,6 +50,7 @@
#include <limits.h>
#include <sys/queue.h>
#include <sys/param.h>
+#include <sys/endian.h>
#include "makefs.h"
#include "iso.h"
Modified: stable/7/usr.sbin/makefs/cd9660/cd9660_conversion.c
==============================================================================
--- stable/7/usr.sbin/makefs/cd9660/cd9660_conversion.c Sat Aug 13 13:15:27 2011 (r224835)
+++ stable/7/usr.sbin/makefs/cd9660/cd9660_conversion.c Sat Aug 13 13:15:38 2011 (r224836)
@@ -36,8 +36,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/endian.h>
-
static char cd9660_compute_gm_offset(time_t);
#if 0
Modified: stable/7/usr.sbin/makefs/cd9660/cd9660_eltorito.c
==============================================================================
--- stable/7/usr.sbin/makefs/cd9660/cd9660_eltorito.c Sat Aug 13 13:15:27 2011 (r224835)
+++ stable/7/usr.sbin/makefs/cd9660/cd9660_eltorito.c Sat Aug 13 13:15:38 2011 (r224836)
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_eltorito.c,v 1.14 2010/10/27 18:51:35 christos Exp $ */
+/* $NetBSD: cd9660_eltorito.c,v 1.17 2011/06/23 02:35:56 enami Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -32,8 +32,6 @@
* OF SUCH DAMAGE.
*/
-#include <sys/endian.h>
-
#include "cd9660.h"
#include "cd9660_eltorito.h"
@@ -501,13 +499,14 @@ cd9660_setup_boot_volume_descriptor(volu
}
static int
-cd9660_write_mbr_partition_entry(FILE *fd, int index, off_t sector_start,
+cd9660_write_mbr_partition_entry(FILE *fd, int idx, off_t sector_start,
off_t nsectors, int type)
{
uint8_t val;
uint32_t lba;
- fseeko(fd, (off_t)(index) * 16 + 0x1be, SEEK_SET);
+ if (fseeko(fd, (off_t)(idx) * 16 + 0x1be, SEEK_SET) == -1)
+ err(1, "fseeko");
val = 0x80; /* Bootable */
fwrite(&val, sizeof(val), 1, fd);
@@ -531,18 +530,19 @@ cd9660_write_mbr_partition_entry(FILE *f
lba = htole32(nsectors);
fwrite(&lba, sizeof(lba), 1, fd);
- return (0);
+ return 0;
}
static int
-cd9660_write_apm_partition_entry(FILE *fd, int index, int total_partitions,
+cd9660_write_apm_partition_entry(FILE *fd, int idx, int total_partitions,
off_t sector_start, off_t nsectors, off_t sector_size,
const char *part_name, const char *part_type)
{
uint32_t apm32;
uint16_t apm16;
- fseeko(fd, (off_t)(index + 1) * sector_size, SEEK_SET);
+ if (fseeko(fd, (off_t)(idx + 1) * sector_size, SEEK_SET) == -1)
+ err(1, "fseeko");
/* Signature */
apm16 = htobe16(0x504d);
Modified: stable/7/usr.sbin/makefs/cd9660/cd9660_write.c
==============================================================================
--- stable/7/usr.sbin/makefs/cd9660/cd9660_write.c Sat Aug 13 13:15:27 2011 (r224835)
+++ stable/7/usr.sbin/makefs/cd9660/cd9660_write.c Sat Aug 13 13:15:38 2011 (r224836)
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_write.c,v 1.13 2010/10/22 00:49:15 christos Exp $ */
+/* $NetBSD: cd9660_write.c,v 1.14 2011/01/04 09:48:21 wiz Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -458,6 +458,7 @@ cd9660_copy_file(FILE *fd, off_t start_s
if (ferror(rf)) {
warn("%s: fread", __func__);
free(buf);
+ (void)fclose(rf);
return 0;
}
@@ -465,6 +466,7 @@ cd9660_copy_file(FILE *fd, off_t start_s
if (ferror(fd)) {
warn("%s: fwrite", __func__);
free(buf);
+ (void)fclose(rf);
return 0;
}
sector++;
Modified: stable/7/usr.sbin/makefs/cd9660/iso9660_rrip.c
==============================================================================
--- stable/7/usr.sbin/makefs/cd9660/iso9660_rrip.c Sat Aug 13 13:15:27 2011 (r224835)
+++ stable/7/usr.sbin/makefs/cd9660/iso9660_rrip.c Sat Aug 13 13:15:38 2011 (r224836)
@@ -1,4 +1,4 @@
-/* $NetBSD: iso9660_rrip.c,v 1.8 2009/01/10 22:06:29 bjh21 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
@@ -183,10 +183,11 @@ cd9660_rrip_finalize_node(cd9660node *no
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;
@@ -396,6 +397,13 @@ cd9660_rrip_initialize_node(cd9660node *
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);
@@ -435,14 +443,6 @@ cd9660_rrip_initialize_node(cd9660node *
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;
@@ -496,7 +496,7 @@ cd9660_rrip_CL(struct ISO_SUSP_ATTRIBUTE
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;
}
More information about the svn-src-stable-7
mailing list