summaryrefslogtreecommitdiff
path: root/sbin/growfs
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-11-10 00:48:05 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-11-10 00:48:05 +0000
commitf1a1e0eb1bcd91f06f605d3b919280bcfd3423b0 (patch)
tree93a32aa0c9336251a5436ef765c5621a625d974b /sbin/growfs
parent2f9dd6b465d689c2b927b3a78fd5b8d04bdc245a (diff)
Don't use p_size as if it was the full partition size, and don't
assume the disk sector size is 512-bytes. Use DL_GETPSIZE() to get correct partition sizes and DL_SECTOBLK() to turn disk sector values into 512-byte-block values.
Diffstat (limited to 'sbin/growfs')
-rw-r--r--sbin/growfs/growfs.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c
index d3475114a7b..df836fc6927 100644
--- a/sbin/growfs/growfs.c
+++ b/sbin/growfs/growfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: growfs.c,v 1.32 2013/11/09 15:53:20 krw Exp $ */
+/* $OpenBSD: growfs.c,v 1.33 2013/11/10 00:48:04 krw Exp $ */
/*
* Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
* Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
@@ -1986,7 +1986,7 @@ main(int argc, char **argv)
/*
* Check if that partition is suitable for growing a file system.
*/
- if (pp->p_size < 1)
+ if (DL_GETPSIZE(pp) < 1)
errx(1, "partition is unavailable");
if (pp->p_fstype != FS_BSDFFS)
errx(1, "can only grow ffs partitions");
@@ -2021,13 +2021,13 @@ main(int argc, char **argv)
* Determine size to grow to. Default to the full size specified in
* the disk label.
*/
- sblock.fs_size = dbtofsb(&osblock, pp->p_size);
+ sblock.fs_size = dbtofsb(&osblock, DL_SECTOBLK(lp, DL_GETPSIZE(pp)));
if (size != 0) {
- if (size > pp->p_size) {
- errx(1, "there is not enough space (%d < %lld)",
- pp->p_size, size);
+ if (size > DL_GETPSIZE(pp)) {
+ errx(1, "there is not enough space (%llu < %lld)",
+ DL_GETPSIZE(pp), size);
}
- sblock.fs_size = dbtofsb(&osblock, size);
+ sblock.fs_size = dbtofsb(&osblock, DL_SECTOBLK(lp, size));
}
/*
@@ -2076,8 +2076,8 @@ main(int argc, char **argv)
* later on realize we have to abort our operation, on that block
* there should be no data, so we can't destroy something yet.
*/
- wtfs((daddr_t)pp->p_size-1, (size_t)DEV_BSIZE, (void *)&sblock,
- fso, Nflag);
+ wtfs(DL_SECTOBLK(lp, DL_GETPSIZE(pp)) - 1, (size_t)DEV_BSIZE,
+ (void *)&sblock, fso, Nflag);
/*
* Now calculate new superblock values and check for reasonable