summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2011-08-10 19:12:21 +0000
committermarius <marius@FreeBSD.org>2011-08-10 19:12:21 +0000
commit0043c1697f383547da5956eaac65f169969f0b32 (patch)
tree6523aec50aaa1496802d456fb2481464a0719587 /usr.sbin
parentce69106ff2202bf9f5cfbd3d9a55c17af5cf7e0a (diff)
downloadFreeBSD-src-0043c1697f383547da5956eaac65f169969f0b32.zip
FreeBSD-src-0043c1697f383547da5956eaac65f169969f0b32.tar.gz
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 Approved by: re (kib) Obtained from: NetBSD MFC after: 3 days
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/makefs/cd9660.c14
-rw-r--r--usr.sbin/makefs/cd9660.h3
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_conversion.c2
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.c16
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_write.c4
-rw-r--r--usr.sbin/makefs/cd9660/iso9660_rrip.c24
6 files changed, 32 insertions, 31 deletions
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 281a203..44af984 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -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_descriptors(void);
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(cd9660node *node)
#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 *newnode)
}
/*
- * 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, cd9660node *newnode)
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, cd9660node *parent, cd9660node *me)
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, cd9660node *parent, cd9660node *me)
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;
}
diff --git a/usr.sbin/makefs/cd9660.h b/usr.sbin/makefs/cd9660.h
index 79f0a9d..108dd48 100644
--- a/usr.sbin/makefs/cd9660.h
+++ b/usr.sbin/makefs/cd9660.h
@@ -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"
diff --git a/usr.sbin/makefs/cd9660/cd9660_conversion.c b/usr.sbin/makefs/cd9660/cd9660_conversion.c
index e815028..43fc7c5 100644
--- a/usr.sbin/makefs/cd9660/cd9660_conversion.c
+++ b/usr.sbin/makefs/cd9660/cd9660_conversion.c
@@ -36,8 +36,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/endian.h>
-
static char cd9660_compute_gm_offset(time_t);
#if 0
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index 2f45e9d..ca3dfd9 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -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(volume_descriptor *bvd)
}
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 *fd, int index, off_t sector_start,
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);
diff --git a/usr.sbin/makefs/cd9660/cd9660_write.c b/usr.sbin/makefs/cd9660/cd9660_write.c
index 4622701..4c2a24a 100644
--- a/usr.sbin/makefs/cd9660/cd9660_write.c
+++ b/usr.sbin/makefs/cd9660/cd9660_write.c
@@ -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
@@ -460,6 +460,7 @@ cd9660_copy_file(FILE *fd, off_t start_sector, const char *filename)
if (ferror(rf)) {
warn("%s: fread", __func__);
free(buf);
+ (void)fclose(rf);
return 0;
}
@@ -467,6 +468,7 @@ cd9660_copy_file(FILE *fd, off_t start_sector, const char *filename)
if (ferror(fd)) {
warn("%s: fwrite", __func__);
free(buf);
+ (void)fclose(rf);
return 0;
}
sector++;
diff --git a/usr.sbin/makefs/cd9660/iso9660_rrip.c b/usr.sbin/makefs/cd9660/iso9660_rrip.c
index 71f77aa..68de7cc 100644
--- a/usr.sbin/makefs/cd9660/iso9660_rrip.c
+++ b/usr.sbin/makefs/cd9660/iso9660_rrip.c
@@ -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 *node)
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 *node, cd9660node *parent,
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 *node, cd9660node *parent,
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_ATTRIBUTES *p, cd9660node *node __unused)
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;
}
OpenPOWER on IntegriCloud