summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/isofs/udf/ecma167-udf.h9
-rw-r--r--sys/isofs/udf/udf_vfsops.c29
2 files changed, 21 insertions, 17 deletions
diff --git a/sys/isofs/udf/ecma167-udf.h b/sys/isofs/udf/ecma167-udf.h
index 720e69ec540..f4538261173 100644
--- a/sys/isofs/udf/ecma167-udf.h
+++ b/sys/isofs/udf/ecma167-udf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ecma167-udf.h,v 1.3 2006/01/19 01:05:32 pedro Exp $ */
+/* $OpenBSD: ecma167-udf.h,v 1.4 2006/06/22 00:10:01 pedro Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -203,8 +203,6 @@ struct logvol_desc {
uint8_t maps[1];
} __packed;
-#define UDF_PMAP_SIZE 64
-
/* Type 1 Partition Map [3/10.7.2] */
struct part_map_1 {
uint8_t type;
@@ -213,6 +211,8 @@ struct part_map_1 {
uint16_t part_num;
} __packed;
+#define UDF_PMAP_TYPE1_SIZE 6
+
/* Type 2 Partition Map [3/10.7.3] */
struct part_map_2 {
uint8_t type;
@@ -220,6 +220,8 @@ struct part_map_2 {
uint8_t part_id[62];
} __packed;
+#define UDF_PMAP_TYPE2_SIZE 64
+
/* Virtual Partition Map [UDF 2.01/2.2.8] */
struct part_map_virt {
uint8_t type;
@@ -247,7 +249,6 @@ struct part_map_spare {
} __packed;
union udf_pmap {
- uint8_t data[UDF_PMAP_SIZE];
struct part_map_1 pm1;
struct part_map_2 pm2;
struct part_map_virt pmv;
diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c
index 69353c107c8..94128de29a3 100644
--- a/sys/isofs/udf/udf_vfsops.c
+++ b/sys/isofs/udf/udf_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udf_vfsops.c,v 1.7 2006/06/14 16:40:15 pat Exp $ */
+/* $OpenBSD: udf_vfsops.c,v 1.8 2006/06/22 00:10:01 pedro Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -692,30 +692,31 @@ udf_checkexp(struct mount *mp, struct mbuf *nam, int *exflagsp,
int
udf_find_partmaps(struct udf_mnt *udfmp, struct logvol_desc *lvd)
{
- union udf_pmap *pmap;
struct part_map_spare *pms;
struct regid *pmap_id;
struct buf *bp;
unsigned char regid_id[UDF_REGID_ID_SIZE + 1];
int i, ptype, psize, error;
+ uint8_t *pmap = (uint8_t *) &lvd->maps[0];
for (i = 0; i < letoh32(lvd->n_pm); i++) {
- pmap = (union udf_pmap *)&lvd->maps[i * UDF_PMAP_SIZE];
- ptype = pmap->data[0];
- psize = pmap->data[1];
- if (((ptype != 1) && (ptype != 2)) ||
- ((psize != UDF_PMAP_SIZE) && (psize != 6))) {
- printf("Invalid partition map found\n");
- return (1);
- }
+ ptype = pmap[0];
+ psize = pmap[1];
+
+ if (ptype != 1 && ptype != 2)
+ return (1); /* Invalid partition map type */
+
+ if (psize != UDF_PMAP_TYPE1_SIZE &&
+ psize != UDF_PMAP_TYPE2_SIZE)
+ return (1); /* Invalid partition map size */
if (ptype == 1) {
- /* Type 1 map. We don't care */
+ pmap += UDF_PMAP_TYPE1_SIZE;
continue;
}
/* Type 2 map. Gotta find out the details */
- pmap_id = (struct regid *)&pmap->data[4];
+ pmap_id = (struct regid *) &pmap[4];
bzero(&regid_id[0], UDF_REGID_ID_SIZE);
bcopy(&pmap_id->id[0], &regid_id[0], UDF_REGID_ID_SIZE);
@@ -725,7 +726,9 @@ udf_find_partmaps(struct udf_mnt *udfmp, struct logvol_desc *lvd)
return (1);
}
- pms = &pmap->pms;
+ pms = (struct part_map_spare *) pmap;
+ pmap += UDF_PMAP_TYPE2_SIZE;
+
MALLOC(udfmp->s_table, struct udf_sparing_table *,
letoh32(pms->st_size), M_UDFMOUNT, M_NOWAIT);
if (udfmp->s_table == NULL)