From owner-freebsd-fs@FreeBSD.ORG Tue Jan 11 11:27:18 2005 Return-Path: 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 02F5A16A4CE for ; Tue, 11 Jan 2005 11:27:18 +0000 (GMT) Received: from feith1.FEITH.COM (feith1.FEITH.COM [192.251.93.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E75D43D2F for ; Tue, 11 Jan 2005 11:27:17 +0000 (GMT) (envelope-from john@feith.com) Received: from jwlab.FEITH.COM (jwlab.FEITH.COM [192.251.93.16]) by feith1.FEITH.COM (8.12.10+Sun/8.12.9) with ESMTP id j0BBRFrt002024 for ; Tue, 11 Jan 2005 06:27:15 -0500 (EST) Received: from jwlab.FEITH.COM (localhost [127.0.0.1]) by jwlab.FEITH.COM (8.12.10+Sun/8.12.10) with ESMTP id j0BBRFLW017164 for ; Tue, 11 Jan 2005 06:27:15 -0500 (EST) Received: (from john@localhost) by jwlab.FEITH.COM (8.12.10+Sun/8.12.10/Submit) id j0BBRFY9017163 for freebsd-fs@freebsd.org; Tue, 11 Jan 2005 06:27:15 -0500 (EST) Date: Tue, 11 Jan 2005 06:27:15 -0500 (EST) From: John Wehle Message-Id: <200501111127.j0BBRFY9017163@jwlab.FEITH.COM> To: freebsd-fs@freebsd.org Content-Type: text X-Scanned-By: MIMEDefang 2.48 on 192.251.93.1 X-Archived: cashew.FEITH.COM Subject: FreeBSD 5.3 Patch to fix udf large files and reading past EOF X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2005 11:27:18 -0000 Currently reading udf files > 2 GB is busted due to truncation in the kernel. Also reading a UDF file can return more data than present in the file due to a failure to check the number of bytes being requested with the number of bytes left in the file. Both problems are addressed by the enclosed patch. -- John Wehle ------------------8<------------------------8<------------------------ *** fs/udf/udf_vnops.c.ORIGINAL Sat Oct 2 01:48:04 2004 --- fs/udf/udf_vnops.c Tue Jan 11 03:12:38 2005 *************** static int udf_strategy(struct vop_strat *** 65,72 **** static int udf_bmap(struct vop_bmap_args *); static int udf_lookup(struct vop_cachedlookup_args *); static int udf_reclaim(struct vop_reclaim_args *); ! static int udf_readatoffset(struct udf_node *, int *, int, struct buf **, uint8_t **); ! static int udf_bmap_internal(struct udf_node *, uint32_t, daddr_t *, uint32_t *); vop_t **udf_vnodeop_p; static struct vnodeopv_entry_desc udf_vnodeop_entries[] = { --- 65,72 ---- static int udf_bmap(struct vop_bmap_args *); static int udf_lookup(struct vop_cachedlookup_args *); static int udf_reclaim(struct vop_reclaim_args *); ! static int udf_readatoffset(struct udf_node *, int *, off_t, struct buf **, uint8_t **); ! static int udf_bmap_internal(struct udf_node *, off_t, daddr_t *, uint32_t *); vop_t **udf_vnodeop_p; static struct vnodeopv_entry_desc udf_vnodeop_entries[] = { *************** udf_read(struct vop_read_args *a) *** 407,414 **** struct udf_node *node = VTON(vp); struct buf *bp; uint8_t *data; int error = 0; ! int size, fsize, offset; if (uio->uio_offset < 0) return (EINVAL); --- 407,415 ---- struct udf_node *node = VTON(vp); struct buf *bp; uint8_t *data; + off_t fsize, offset; int error = 0; ! int size; if (uio->uio_offset < 0) return (EINVAL); *************** udf_read(struct vop_read_args *a) *** 417,423 **** while (uio->uio_offset < fsize && uio->uio_resid > 0) { offset = uio->uio_offset; ! size = uio->uio_resid; error = udf_readatoffset(node, &size, offset, &bp, &data); if (error == 0) error = uiomove(data, size, uio); --- 418,424 ---- while (uio->uio_offset < fsize && uio->uio_resid > 0) { offset = uio->uio_offset; ! size = min (uio->uio_resid, fsize - uio->uio_offset); error = udf_readatoffset(node, &size, offset, &bp, &data); if (error == 0) error = uiomove(data, size, uio); *************** udf_reclaim(struct vop_reclaim_args *a) *** 1060,1066 **** * */ static int ! udf_readatoffset(struct udf_node *node, int *size, int offset, struct buf **bp, uint8_t **data) { struct udf_mnt *udfmp; struct file_entry *fentry = NULL; --- 1061,1067 ---- * */ static int ! udf_readatoffset(struct udf_node *node, int *size, off_t offset, struct buf **bp, uint8_t **data) { struct udf_mnt *udfmp; struct file_entry *fentry = NULL; *************** udf_readatoffset(struct udf_node *node, *** 1107,1113 **** * block. */ static int ! udf_bmap_internal(struct udf_node *node, uint32_t offset, daddr_t *sector, uint32_t *max_size) { struct udf_mnt *udfmp; struct file_entry *fentry; --- 1108,1114 ---- * block. */ static int ! udf_bmap_internal(struct udf_node *node, off_t offset, daddr_t *sector, uint32_t *max_size) { struct udf_mnt *udfmp; struct file_entry *fentry; ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | -------------------------------------------------------------------------