History log of /openbsd-current/sbin/growfs/growfs.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.57 23-Apr-2024 jsg

correct indentation; no functional change
ok tb@


Revision tags: OPENBSD_7_5_BASE
# 1.56 03-Feb-2024 beck

Remove Softdep.

Softdep has been a no-op for some time now, this removes it to get
it out of the way.

Flensing mostly done in Talinn, with some help from krw@

ok deraadt@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.55 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.54 20-Jun-2020 otto

With filesystem having many cylinder groups and many inodes per cg the
ncg * ipg calcualtion can overflow if signed types are used. Move
to uint32_t for the relevant values. Aligned with FreeBSD changes.
Also make sure newfs refuses to create an fs with more that 2^32-1
inodes. ok millert@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.53 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c


# 1.56 03-Feb-2024 beck

Remove Softdep.

Softdep has been a no-op for some time now, this removes it to get
it out of the way.

Flensing mostly done in Talinn, with some help from krw@

ok deraadt@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.55 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.54 20-Jun-2020 otto

With filesystem having many cylinder groups and many inodes per cg the
ncg * ipg calcualtion can overflow if signed types are used. Move
to uint32_t for the relevant values. Aligned with FreeBSD changes.
Also make sure newfs refuses to create an fs with more that 2^32-1
inodes. ok millert@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.53 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c


# 1.55 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.54 20-Jun-2020 otto

With filesystem having many cylinder groups and many inodes per cg the
ncg * ipg calcualtion can overflow if signed types are used. Move
to uint32_t for the relevant values. Aligned with FreeBSD changes.
Also make sure newfs refuses to create an fs with more that 2^32-1
inodes. ok millert@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.53 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c


# 1.54 20-Jun-2020 otto

With filesystem having many cylinder groups and many inodes per cg the
ncg * ipg calcualtion can overflow if signed types are used. Move
to uint32_t for the relevant values. Aligned with FreeBSD changes.
Also make sure newfs refuses to create an fs with more that 2^32-1
inodes. ok millert@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.53 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c


# 1.53 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.51 28-May-2016 tb

Give growfs a chance to error out with ENOTTY before pledging disklabel.
Fixes pledge crash due to ioctl DIOCGDINFO with an inappropriate file.

looks good to deraadt


# 1.50 17-Mar-2016 bentley

Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.

Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@


Revision tags: OPENBSD_5_9_BASE
# 1.49 29-Jan-2016 tb

Therefor -> Therefore (where appropriate)

from ray@, ok jmc@


# 1.48 28-Nov-2015 deraadt

hoist TIOCGWINSZ code upwards, and pledge "stdio disklabel" at the
right place.
tested by mmcc


# 1.47 27-Nov-2015 deraadt

spaces


# 1.46 23-Nov-2015 mmcc

Remove the debugging infrastructure, which was ~1/3 of the code. Makes
pledging easier, and it was excessive complicated stuff.

"Good." deraadt@


# 1.45 20-Nov-2015 mmcc

De-justify more comments. From FreeBSD.


# 1.44 20-Nov-2015 mmcc

Monospace comments are not meant to be justified. From FreeBSD.


# 1.43 19-Nov-2015 mmcc

Remove some weird comments containing only the name of the next function.


# 1.42 19-Nov-2015 mmcc

Don't bother casting memset() argument to void*. No binary change.


# 1.41 19-Nov-2015 mmcc

calloc((size_t)1, ...) -> calloc(1, ...)
No binary change (for real this time).


# 1.40 20-Aug-2015 deraadt

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.39 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.38 20-Jan-2015 deraadt

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther


# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.36 15-May-2014 chl

- typo in comment
- memset() is not needed after a calloc()
- add missing DBG_ENTER;
- use SEEK_SET instead of 0 in an lseek() call

ok krw@


# 1.35 05-May-2014 krw

"new file systemsize is" -> "new filesystem size is".

From David Vasek.


# 1.34 30-Apr-2014 krw

Write last disk sector, not last 512-byte block, when testing validity
of new partition limit.

Fixes growfs on 4K-sector disks.

Reported by and fix tested by David Vasek via misc@.


Revision tags: OPENBSD_5_5_BASE
# 1.33 10-Nov-2013 krw

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.


# 1.32 09-Nov-2013 krw

Replace (int) = (size_t)(long) with (long long) = (long long) by replacing
atol() with strtonum() and storing value of 's' parameter in long long
variable instead of an int.


Revision tags: OPENBSD_5_4_BASE
# 1.31 11-Jun-2013 deraadt

final removal of daddr64_t. daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others


# 1.30 23-Apr-2013 deraadt

handle large ino_t; ok tedu


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.29 18-May-2010 dlg

dont let sys/ioctl.h imply that you get the ioctls in dkio.h. this
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include
<sys/dkio.h> to the places that actually want and use the disk
ioctls.

this became an issue when krw@'s X build failed when he was testing
a change to dkio.h.
tested by krw@
help from and ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.28 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.27 01-Apr-2009 jsg

Don't be picky about character case when checking response.
ok deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.26 24-Dec-2008 otto

fox format string; ok tedu@


# 1.25 28-Nov-2008 ckuethe

Make growfs refuse to run on a dirty filesystem, and set the filesystem to
dirty on the way out so that users are forced to run fsck afterwards. The
manpage politely suggested that the filesystem be checked after growing it;
change it to say that fsck is required.


Revision tags: OPENBSD_4_4_BASE
# 1.24 24-Jun-2008 sobrado

Index: src/sbin/growfs/growfs.c