Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/ntfs When the MFT record size is lower than the clust...



details:   https://anonhg.NetBSD.org/src/rev/d3b2fed01b82
branches:  trunk
changeset: 455488:d3b2fed01b82
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Oct 18 08:19:33 2019 +0000

description:
When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.

Should fix PR kern/54598: mount ntfs panic

diffstat:

 sys/fs/ntfs/ntfs_subr.c |  33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diffs (63 lines):

diff -r 95eeac7b1b02 -r d3b2fed01b82 sys/fs/ntfs/ntfs_subr.c
--- a/sys/fs/ntfs/ntfs_subr.c   Fri Oct 18 08:18:40 2019 +0000
+++ b/sys/fs/ntfs/ntfs_subr.c   Fri Oct 18 08:19:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_subr.c,v 1.61 2015/03/28 19:24:05 maxv Exp $      */
+/*     $NetBSD: ntfs_subr.c,v 1.62 2019/10/18 08:19:33 hannken Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.61 2015/03/28 19:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.62 2019/10/18 08:19:33 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -271,6 +271,8 @@
                struct buf *bp;
                daddr_t bn;
                off_t boff;
+               size_t resid, l;
+               char *data;
 
                dprintf(("%s: read system node\n", __func__));
 
@@ -281,17 +283,26 @@
                boff = ntfs_cntob(ntmp->ntm_mftcn) +
                    ntfs_bntob(ntmp->ntm_bpmftrec) * ip->i_number;
                bn = ntfs_cntobn(ntfs_btocn(boff));
-               off = ntfs_btocnoff(boff);
+               boff = ntfs_btocnoff(boff);
+               resid = ntfs_bntob(ntmp->ntm_bpmftrec);
+               data = (char *)mfrp;
+               while (resid > 0) {
+                       l = MIN(resid, ntfs_cntob(1) - boff);
 
-               error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
-                   0, &bp);
-               if (error) {
-                       printf("%s: BREAD FAILED\n", __func__);
-                       goto out;
+                       error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
+                           0, &bp);
+                       if (error) {
+                               printf("%s: BREAD FAILED\n", __func__);
+                               goto out;
+                       }
+                       memcpy(data, (char *)bp->b_data + boff, l);
+                       bqrelse(bp);
+
+                       bn += ntfs_cntobn(1);
+                       boff = 0;
+                       data += l;
+                       resid -= l;
                }
-               memcpy(mfrp, (char *)bp->b_data + off,
-                   ntfs_bntob(ntmp->ntm_bpmftrec));
-               bqrelse(bp);
        } else {
                struct vnode   *vp;
 



Home | Main Index | Thread Index | Old Index