Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Support dump on wedges.



details:   https://anonhg.NetBSD.org/src/rev/c38c165c3fe5
branches:  trunk
changeset: 832458:c38c165c3fe5
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat May 12 10:33:06 2018 +0000

description:
Support dump on wedges.

diffstat:

 sys/dev/dksubr.c     |  58 +++++++++++++++++++++++++++++++++++----------------
 sys/dev/dkwedge/dk.c |   6 ++--
 2 files changed, 43 insertions(+), 21 deletions(-)

diffs (119 lines):

diff -r 411a2b7e25ae -r c38c165c3fe5 sys/dev/dksubr.c
--- a/sys/dev/dksubr.c  Sat May 12 01:31:07 2018 +0000
+++ b/sys/dev/dksubr.c  Sat May 12 10:33:06 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.101 2017/12/04 22:15:52 jdolecek Exp $ */
+/* $NetBSD: dksubr.c,v 1.102 2018/05/12 10:33:06 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.101 2017/12/04 22:15:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.102 2018/05/12 10:33:06 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -762,10 +762,11 @@
     daddr_t blkno, void *vav, size_t size)
 {
        const struct dkdriver *dkd = dksc->sc_dkdev.dk_driver;
+       struct disk_geom *dg = &dksc->sc_dkdev.dk_geom;
        char *va = vav;
        struct disklabel *lp;
        struct partition *p;
-       int part, towrt, nsects, sectoff, maxblkcnt, nblk;
+       int part, towrt, maxblkcnt, nblk;
        int maxxfer, rv = 0;
 
        /*
@@ -804,24 +805,45 @@
        blkno = dbtob(blkno) / lp->d_secsize;   /* blkno in secsize units */
 
        p = &lp->d_partitions[part];
-       if (p->p_fstype != FS_SWAP) {
-               DPRINTF(DKDB_DUMP, ("%s: bad fstype %d\n", __func__,
-                   p->p_fstype));
-               return ENXIO;
-       }
-       nsects = p->p_size;
-       sectoff = p->p_offset;
+       if (part == RAW_PART) {
+               if (p->p_fstype != FS_UNUSED) {
+                       DPRINTF(DKDB_DUMP, ("%s: bad fstype %d\n", __func__,
+                           p->p_fstype));
+                       return ENXIO;
+               }
+               /* Check wether dump goes to a wedge */
+               if (dksc->sc_dkdev.dk_nwedges == 0) {
+                       DPRINTF(DKDB_DUMP, ("%s: dump to raw\n", __func__));
+                       return ENXIO;
+               }
+               /* Check transfer bounds against media size */
+               if (blkno < 0 || (blkno + towrt) > dg->dg_secperunit) {
+                       DPRINTF(DKDB_DUMP, ("%s: out of bounds blkno=%jd, towrt=%d, "
+                           "nsects=%jd\n", __func__, (intmax_t)blkno, towrt, dg->dg_secperunit));
+                       return EINVAL;
+               }
+       } else {
+               int nsects, sectoff;
 
-       /* Check transfer bounds against partition size. */
-       if ((blkno < 0) || ((blkno + towrt) > nsects)) {
-               DPRINTF(DKDB_DUMP, ("%s: out of bounds blkno=%jd, towrt=%d, "
-                   "nsects=%d\n", __func__, (intmax_t)blkno, towrt, nsects));
-               return EINVAL;
+               if (p->p_fstype != FS_SWAP) {
+                       DPRINTF(DKDB_DUMP, ("%s: bad fstype %d\n", __func__,
+                           p->p_fstype));
+                       return ENXIO;
+               }
+               nsects = p->p_size;
+               sectoff = p->p_offset;
+
+               /* Check transfer bounds against partition size. */
+               if ((blkno < 0) || ((blkno + towrt) > nsects)) {
+                       DPRINTF(DKDB_DUMP, ("%s: out of bounds blkno=%jd, towrt=%d, "
+                           "nsects=%d\n", __func__, (intmax_t)blkno, towrt, nsects));
+                       return EINVAL;
+               }
+
+               /* Offset block number to start of partition. */
+               blkno += sectoff;
        }
 
-       /* Offset block number to start of partition. */
-       blkno += sectoff;
-
        /* Start dumping and return when done. */
        maxblkcnt = howmany(maxxfer, lp->d_secsize);
        while (towrt > 0) {
diff -r 411a2b7e25ae -r c38c165c3fe5 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Sat May 12 01:31:07 2018 +0000
+++ b/sys/dev/dkwedge/dk.c      Sat May 12 10:33:06 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $  */
+/*     $NetBSD: dk.c,v 1.97 2018/05/12 10:33:06 mlelstv Exp $  */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.97 2018/05/12 10:33:06 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1613,7 +1613,7 @@
                rv = EINVAL;
                goto out;
        }
-       if (blkno + size / DEV_BSIZE > sc->sc_size) {
+       if (blkno < 0 || blkno + size / DEV_BSIZE > sc->sc_size) {
                printf("%s: blkno (%" PRIu64 ") + size / DEV_BSIZE (%zu) > "
                    "sc->sc_size (%" PRIu64 ")\n", __func__, blkno,
                    size / DEV_BSIZE, sc->sc_size);



Home | Main Index | Thread Index | Old Index