| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: setup.c,v 1.31 2013/06/23 02:06:04 dholland Exp $ */ | | 1 | /* $NetBSD: setup.c,v 1.31.6.1 2015/04/14 05:15:57 snj Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1980, 1986, 1993 | | 4 | * Copyright (c) 1980, 1986, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -48,27 +48,27 @@ | | | @@ -48,27 +48,27 @@ |
48 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 48 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
49 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 49 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
53 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 53 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
54 | */ | | 54 | */ |
55 | | | 55 | |
56 | #include <sys/cdefs.h> | | 56 | #include <sys/cdefs.h> |
57 | #ifndef lint | | 57 | #ifndef lint |
58 | #if 0 | | 58 | #if 0 |
59 | static char sccsid[] = "@(#)setup.c 8.5 (Berkeley) 11/23/94"; | | 59 | static char sccsid[] = "@(#)setup.c 8.5 (Berkeley) 11/23/94"; |
60 | #else | | 60 | #else |
61 | __RCSID("$NetBSD: setup.c,v 1.31 2013/06/23 02:06:04 dholland Exp $"); | | 61 | __RCSID("$NetBSD: setup.c,v 1.31.6.1 2015/04/14 05:15:57 snj Exp $"); |
62 | #endif | | 62 | #endif |
63 | #endif /* not lint */ | | 63 | #endif /* not lint */ |
64 | | | 64 | |
65 | #define FSTYPENAMES | | 65 | #define FSTYPENAMES |
66 | #include <sys/param.h> | | 66 | #include <sys/param.h> |
67 | #include <sys/time.h> | | 67 | #include <sys/time.h> |
68 | #include <ufs/ext2fs/ext2fs_dinode.h> | | 68 | #include <ufs/ext2fs/ext2fs_dinode.h> |
69 | #include <ufs/ext2fs/ext2fs.h> | | 69 | #include <ufs/ext2fs/ext2fs.h> |
70 | #include <sys/stat.h> | | 70 | #include <sys/stat.h> |
71 | #include <sys/ioctl.h> | | 71 | #include <sys/ioctl.h> |
72 | #include <sys/disklabel.h> | | 72 | #include <sys/disklabel.h> |
73 | #include <sys/file.h> | | 73 | #include <sys/file.h> |
74 | | | 74 | |
| @@ -480,26 +480,30 @@ calcsb(const char *dev, int devfd, struc | | | @@ -480,26 +480,30 @@ calcsb(const char *dev, int devfd, struc |
480 | return 0; | | 480 | return 0; |
481 | } | | 481 | } |
482 | lp = getdisklabel(dev, devfd); | | 482 | lp = getdisklabel(dev, devfd); |
483 | if (isdigit((unsigned char)*cp)) | | 483 | if (isdigit((unsigned char)*cp)) |
484 | pp = &lp->d_partitions[0]; | | 484 | pp = &lp->d_partitions[0]; |
485 | else | | 485 | else |
486 | pp = &lp->d_partitions[*cp - 'a']; | | 486 | pp = &lp->d_partitions[*cp - 'a']; |
487 | if (pp->p_fstype != FS_EX2FS) { | | 487 | if (pp->p_fstype != FS_EX2FS) { |
488 | pfatal("%s: NOT LABELED AS A EXT2 FILE SYSTEM (%s)\n", | | 488 | pfatal("%s: NOT LABELED AS A EXT2 FILE SYSTEM (%s)\n", |
489 | dev, pp->p_fstype < FSMAXTYPES ? | | 489 | dev, pp->p_fstype < FSMAXTYPES ? |
490 | fstypenames[pp->p_fstype] : "unknown"); | | 490 | fstypenames[pp->p_fstype] : "unknown"); |
491 | return 0; | | 491 | return 0; |
492 | } | | 492 | } |
| | | 493 | if (pp->p_fsize == 0) { |
| | | 494 | pfatal("%s: PARTITION SIZE IS 0\n", dev); |
| | | 495 | return 0; |
| | | 496 | } |
493 | memset(fs, 0, sizeof(struct m_ext2fs)); | | 497 | memset(fs, 0, sizeof(struct m_ext2fs)); |
494 | fs->e2fs_bsize = pp->p_fsize; | | 498 | fs->e2fs_bsize = pp->p_fsize; |
495 | fs->e2fs.e2fs_log_bsize = pp->p_fsize / 1024; | | 499 | fs->e2fs.e2fs_log_bsize = pp->p_fsize / 1024; |
496 | fs->e2fs.e2fs_bcount = (pp->p_size * DEV_BSIZE) / fs->e2fs_bsize; | | 500 | fs->e2fs.e2fs_bcount = (pp->p_size * DEV_BSIZE) / fs->e2fs_bsize; |
497 | fs->e2fs.e2fs_first_dblock = (fs->e2fs.e2fs_log_bsize == 0) ? 1 : 0; | | 501 | fs->e2fs.e2fs_first_dblock = (fs->e2fs.e2fs_log_bsize == 0) ? 1 : 0; |
498 | fs->e2fs.e2fs_bpg = fs->e2fs_bsize * NBBY; | | 502 | fs->e2fs.e2fs_bpg = fs->e2fs_bsize * NBBY; |
499 | fs->e2fs_bshift = LOG_MINBSIZE + fs->e2fs.e2fs_log_bsize; | | 503 | fs->e2fs_bshift = LOG_MINBSIZE + fs->e2fs.e2fs_log_bsize; |
500 | fs->e2fs_qbmask = fs->e2fs_bsize - 1; | | 504 | fs->e2fs_qbmask = fs->e2fs_bsize - 1; |
501 | fs->e2fs_bmask = ~fs->e2fs_qbmask; | | 505 | fs->e2fs_bmask = ~fs->e2fs_qbmask; |
502 | fs->e2fs_ncg = | | 506 | fs->e2fs_ncg = |
503 | howmany(fs->e2fs.e2fs_bcount - fs->e2fs.e2fs_first_dblock, | | 507 | howmany(fs->e2fs.e2fs_bcount - fs->e2fs.e2fs_first_dblock, |
504 | fs->e2fs.e2fs_bpg); | | 508 | fs->e2fs.e2fs_bpg); |
505 | fs->e2fs_fsbtodb = fs->e2fs.e2fs_log_bsize + 1; | | 509 | fs->e2fs_fsbtodb = fs->e2fs.e2fs_log_bsize + 1; |