| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dksubr.c,v 1.80 2015/10/23 01:06:20 christos Exp $ */ | | 1 | /* $NetBSD: dksubr.c,v 1.81 2015/10/23 01:34:22 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe and Roland C. Dowdeswell. | | 8 | * by Jason R. Thorpe and Roland C. Dowdeswell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.80 2015/10/23 01:06:20 christos Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.81 2015/10/23 01:34:22 christos Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/stat.h> | | 37 | #include <sys/stat.h> |
38 | #include <sys/proc.h> | | 38 | #include <sys/proc.h> |
39 | #include <sys/ioctl.h> | | 39 | #include <sys/ioctl.h> |
40 | #include <sys/device.h> | | 40 | #include <sys/device.h> |
41 | #include <sys/disk.h> | | 41 | #include <sys/disk.h> |
42 | #include <sys/disklabel.h> | | 42 | #include <sys/disklabel.h> |
43 | #include <sys/buf.h> | | 43 | #include <sys/buf.h> |
44 | #include <sys/bufq.h> | | 44 | #include <sys/bufq.h> |
45 | #include <sys/vnode.h> | | 45 | #include <sys/vnode.h> |
46 | #include <sys/fcntl.h> | | 46 | #include <sys/fcntl.h> |
| @@ -699,27 +699,27 @@ dk_dump(struct dk_softc *dksc, dev_t dev | | | @@ -699,27 +699,27 @@ dk_dump(struct dk_softc *dksc, dev_t dev |
699 | blkno = dbtob(blkno) / lp->d_secsize; /* blkno in secsize units */ | | 699 | blkno = dbtob(blkno) / lp->d_secsize; /* blkno in secsize units */ |
700 | | | 700 | |
701 | p = &lp->d_partitions[part]; | | 701 | p = &lp->d_partitions[part]; |
702 | if (p->p_fstype != FS_SWAP) { | | 702 | if (p->p_fstype != FS_SWAP) { |
703 | DPRINTF(DKDB_DUMP, ("%s: bad fstype %d\n", __func__, | | 703 | DPRINTF(DKDB_DUMP, ("%s: bad fstype %d\n", __func__, |
704 | p->p_fstype)); | | 704 | p->p_fstype)); |
705 | return ENXIO; | | 705 | return ENXIO; |
706 | } | | 706 | } |
707 | nsects = p->p_size; | | 707 | nsects = p->p_size; |
708 | sectoff = p->p_offset; | | 708 | sectoff = p->p_offset; |
709 | | | 709 | |
710 | /* Check transfer bounds against partition size. */ | | 710 | /* Check transfer bounds against partition size. */ |
711 | if ((blkno < 0) || ((blkno + towrt) > nsects)) { | | 711 | if ((blkno < 0) || ((blkno + towrt) > nsects)) { |
712 | DPRINTF(DKDB_DUMP, ("%s: out of bounds blkno=%jd", towrt=%d, " | | 712 | DPRINTF(DKDB_DUMP, ("%s: out of bounds blkno=%jd, towrt=%d, " |
713 | "nsects=%d\n", __func__, (intmax_t)blkno, towrt, nsects)); | | 713 | "nsects=%d\n", __func__, (intmax_t)blkno, towrt, nsects)); |
714 | return EINVAL; | | 714 | return EINVAL; |
715 | } | | 715 | } |
716 | | | 716 | |
717 | /* Offset block number to start of partition. */ | | 717 | /* Offset block number to start of partition. */ |
718 | blkno += sectoff; | | 718 | blkno += sectoff; |
719 | | | 719 | |
720 | /* Start dumping and return when done. */ | | 720 | /* Start dumping and return when done. */ |
721 | maxblkcnt = howmany(maxxfer, lp->d_secsize); | | 721 | maxblkcnt = howmany(maxxfer, lp->d_secsize); |
722 | while (towrt > 0) { | | 722 | while (towrt > 0) { |
723 | nblk = min(maxblkcnt, towrt); | | 723 | nblk = min(maxblkcnt, towrt); |
724 | | | 724 | |
725 | if ((rv = (*dkd->d_dumpblocks)(dksc->sc_dev, va, blkno, nblk)) | | 725 | if ((rv = (*dkd->d_dumpblocks)(dksc->sc_dev, va, blkno, nblk)) |