Fix parsing of UDF type 1 partition maps
Pedro Martelletto
pedro at ambientworks.net
Mon Jun 26 11:46:13 UTC 2006
In udf_find_partmaps(), when we find a type 1 partition map, we have to
skip the actual type 1 length (6 bytes). With this diff, it is possible
to correctly spot the VAT partition map in a couple of discs I've.
Thanks for your attention,
-p.
Index: ecma167-udf.h
===================================================================
RCS file: /home/ncvs/src/sys/fs/udf/ecma167-udf.h,v
retrieving revision 1.6
diff -u -p -r1.6 ecma167-udf.h
--- ecma167-udf.h 3 Feb 2006 15:25:52 -0000 1.6
+++ ecma167-udf.h 26 Jun 2006 10:45:12 -0000
@@ -201,8 +201,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;
@@ -211,6 +209,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;
@@ -218,6 +218,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;
@@ -245,7 +247,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;
Index: udf_vfsops.c
===================================================================
RCS file: /home/ncvs/src/sys/fs/udf/udf_vfsops.c,v
retrieving revision 1.42
diff -u -p -r1.42 udf_vfsops.c
--- udf_vfsops.c 26 Jun 2006 03:21:19 -0000 1.42
+++ udf_vfsops.c 26 Jun 2006 10:45:12 -0000
@@ -723,30 +723,31 @@ udf_vptofh (struct vnode *vp, struct fid
static 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, k, ptype, psize, error;
+ uint8_t *pmap = (uint8_t *) &lvd->maps[0];
for (i = 0; i < le32toh(lvd->n_pm); i++) {
- pmap = (union udf_pmap *)&lvd->maps[i * UDF_PMAP_SIZE];
- ptype = pmap->data[0];
- psize = pmap->data[1];
+ ptype = pmap[0];
+ psize = pmap[1];
if (((ptype != 1) && (ptype != 2)) ||
- ((psize != UDF_PMAP_SIZE) && (psize != 6))) {
+ ((psize != UDF_PMAP_TYPE1_SIZE) &&
+ (psize != UDF_PMAP_TYPE2_SIZE))) {
printf("Invalid partition map found\n");
return (1);
}
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(®id_id[0], UDF_REGID_ID_SIZE);
bcopy(&pmap_id->id[0], ®id_id[0], UDF_REGID_ID_SIZE);
@@ -756,7 +757,8 @@ udf_find_partmaps(struct udf_mnt *udfmp,
return (1);
}
- pms = &pmap->pms;
+ pms = (struct part_map_spare *)pmap;
+ pmap += UDF_PMAP_TYPE2_SIZE;
MALLOC(udfmp->s_table, struct udf_sparing_table *,
le32toh(pms->st_size), M_UDFMOUNT, M_NOWAIT | M_ZERO);
if (udfmp->s_table == NULL)
More information about the freebsd-fs
mailing list