From owner-freebsd-fs@FreeBSD.ORG Tue Jul 25 14:25:42 2006 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E75D416A4E1 for ; Tue, 25 Jul 2006 14:25:41 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD8D243D76 for ; Tue, 25 Jul 2006 14:25:33 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k6PEPTNn069753; Tue, 25 Jul 2006 18:25:29 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k6PEPSeX069752; Tue, 25 Jul 2006 18:25:28 +0400 (MSD) (envelope-from yar) Date: Tue, 25 Jul 2006 18:25:28 +0400 From: Yar Tikhiy To: freebsd-fs@freebsd.org Message-ID: <20060725142528.GH67926@comp.chem.msu.su> References: <20060626112839.GA12741@static.protection.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060626112839.GA12741@static.protection.cx> User-Agent: Mutt/1.5.9i Cc: Subject: Re: Fix parsing of UDF type 1 partition maps X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2006 14:25:42 -0000 On Mon, Jun 26, 2006 at 08:28:39AM -0300, Pedro Martelletto wrote: > 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. All, JFYI: I went ahead and committed this patch from Pedro, who has been taking care of our UDF driver for quite a while now. Thank you, Pedro! > 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) > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org" -- Yar