Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dkwedge Fix fallout of migration from malloc to gete...



details:   https://anonhg.NetBSD.org/src/rev/dfd0fa782e5b
branches:  trunk
changeset: 932249:dfd0fa782e5b
user:      rin <rin%NetBSD.org@localhost>
date:      Sun May 03 06:30:45 2020 +0000

description:
Fix fallout of migration from malloc to geteblk.

- Use bp->b_data instead of bp itself.
- When buffer is not large enough, start all over; brelse + geteblk does not
  apparently behave like realloc.

diffstat:

 sys/dev/dkwedge/dkwedge_rdb.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (68 lines):

diff -r 588a512e1274 -r dfd0fa782e5b sys/dev/dkwedge/dkwedge_rdb.c
--- a/sys/dev/dkwedge/dkwedge_rdb.c     Sun May 03 04:06:15 2020 +0000
+++ b/sys/dev/dkwedge/dkwedge_rdb.c     Sun May 03 06:30:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dkwedge_rdb.c,v 1.6 2020/04/11 16:00:34 jdolecek Exp $ */
+/*     $NetBSD: dkwedge_rdb.c,v 1.7 2020/05/03 06:30:45 rin Exp $      */
 
 /*
  * Adapted from arch/amiga/amiga/disksubr.c:
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.6 2020/04/11 16:00:34 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.7 2020/05/03 06:30:45 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/disklabel_rdb.h>
@@ -116,19 +116,21 @@
            secsize);
        bp = geteblk(bufsize);
 
+retry:
        /*
         * find the RDB block
         * XXX bsdlabel should be detected by the other method
         */
        for (nextb = 0; nextb < RDB_MAXBLOCKS; nextb++) {
-               error = dkwedge_read(pdk, vp, ADJUST_NR(nextb), bp, bufsize);
+               error = dkwedge_read(pdk, vp, ADJUST_NR(nextb), bp->b_data,
+                   bufsize);
                if (error) {
                        aprint_error("%s: unable to read RDB @ %u, "
                            "error = %d\n", pdk->dk_name, nextb, error);
                        error = ESRCH;
                        goto done;
                }
-               rbp = (struct rdblock *)bp;
+               rbp = (struct rdblock *)bp->b_data;
                if (be32toh(rbp->id) == RDBLOCK_ID) {
                        if (rdbchksum(rbp) == 0)
                                break;
@@ -152,6 +154,7 @@
                    sizeof(struct rdblock)), secsize);
                brelse(bp, 0);
                bp = geteblk(bufsize);
+               goto retry;
        }
 
        memset(&dkw, 0, sizeof(dkw));
@@ -164,14 +167,15 @@
         */
        for (nextb = be32toh(rbp->partbhead); nextb != RDBNULL;
             nextb = be32toh(pbp->next)) {
-               error = dkwedge_read(pdk, vp, ADJUST_NR(nextb), bp, bufsize);
+               error = dkwedge_read(pdk, vp, ADJUST_NR(nextb), bp->b_data,
+                   bufsize);
                if (error) {
                        aprint_error("%s: unable to read RDB partition block @ "
                            "%u, error = %d\n", pdk->dk_name, nextb, error);
                        error = ESRCH;
                        goto done;
                }
-               pbp = (struct partblock *)bp;
+               pbp = (struct partblock *)bp->b_data;
                
                if (be32toh(pbp->id) != PARTBLOCK_ID) {
                        aprint_error(



Home | Main Index | Thread Index | Old Index