summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2013-11-10 00:48:04 +0000
committerkrw <krw@openbsd.org>2013-11-10 00:48:04 +0000
commited8b39c238c500a22d1eef2e8cc8b0bda32a83f6 (patch)
treed951a029f5a2df87cb2068ccbe76c9928f187adc
parentAbort autoinstaller in case of an invalid answer to a yes/no question. (diff)
downloadwireguard-openbsd-ed8b39c238c500a22d1eef2e8cc8b0bda32a83f6.tar.xz
wireguard-openbsd-ed8b39c238c500a22d1eef2e8cc8b0bda32a83f6.zip
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.
-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