History log of /openbsd-current/sbin/swapctl/swapctl.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.26 11-Feb-2020 jca

Initialize rejecttype to appease static analyzers

-t has already been checked in main() and can only be "blk" or "noblk",
but static analyzers like scan-build fail to spot this. From miod@


# 1.25 05-Dec-2019 mpi

Remove clause #3 from mrg@NetBSD license.

In May 29 2008, Matthew R. Green removed it in NetBSD:
github.com/IIJ-NetBSD/netbsd-src/commit/7ea20401d535da9996394136ef

ok deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.24 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.23 17-Mar-2016 krw

Last parameter to execl[e]() functions *must* be cast to a pointer.
Just NULL is not good practise as NULL is theoretically allowed to
be an integer rather than a pointer.

Use (char *)NULL consistently instead of scattering a few (char *)0
and (void *)NULL into the mix.

Prompted by and probably ok deraadt@ millert@ kettenis@

Definitely ok mestre@ ratchov@


Revision tags: OPENBSD_5_9_BASE
# 1.22 15-Sep-2015 schwarze

update spacing in usage(); reminded by jmc@


# 1.21 14-Aug-2015 semarie

switch from system(3) to vfork(2)+execl(2) for invoking mount_nfs(8) when fstab
contains option for swapping to NFS files.

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.20 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.19 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_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 29-Dec-2010 stsp

Fix swapctl -A with DUIDs in /etc/fstab, and plug a small memory leak.
ok jsing@ (who also pointed out a DPADD tweak missing from my diff)


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.17 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


Revision tags: OPENBSD_4_2_BASE
# 1.16 17-Jul-2007 jmc

sync swapon usage(); from Igor Zinovik


# 1.15 16-Jul-2007 millert

Remove dead code and fix incorrect comment. From Igor Zinovik.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 12-Apr-2005 deraadt

handle snprintf potential -1 case


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.13 12-Jan-2004 avsm

- avoid variable sized static array (from millert@)
- check for snprintf overflow
- errx -> err for strdup

commit #1000!


# 1.12 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.11 03-Mar-2003 miod

Fix inaccuracies in comments.


Revision tags: OPENBSD_3_2_BASE
# 1.10 03-Jul-2002 deraadt

ansi


# 1.9 15-May-2002 art

typo in comment.
From Sam Smith S at mSmith.net


# 1.8 15-May-2002 art

Kill commented out stubs for swapoff.


Revision tags: OPENBSD_3_1_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.6 04-Jun-2001 mickey

return from main() don't exit


# 1.5 02-Jun-2001 miod

Various swapctl(8) improvements:
- don't print an error message when trying to enable swap on an
already active swap point.
- better handling of -t option.
- silently ignores swap points which are neither block devices nor
regular files, and don't consider swap points not starting with /dev/
as valid block devices, when invoked with -A.

Work by deraadt@ and myself, ok millert@


Revision tags: OPENBSD_2_9_BASE
# 1.4 09-Mar-2001 deraadt

PATH_MAX+1 is wrong. Not cranking libc/libc_r majors over this, since they just got cranked a little while ago. discussion with millert


Revision tags: OPENBSD_2_8_BASE
# 1.3 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


Revision tags: OPENBSD_2_7_BASE
# 1.2 26-Feb-2000 hugh

branches: 1.2.2;
add rcs idents


# 1.1 22-May-1999 weingart

branches: 1.1.1;
Initial revision


# 1.25 05-Dec-2019 mpi

Remove clause #3 from mrg@NetBSD license.

In May 29 2008, Matthew R. Green removed it in NetBSD:
github.com/IIJ-NetBSD/netbsd-src/commit/7ea20401d535da9996394136ef

ok deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.24 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.23 17-Mar-2016 krw

Last parameter to execl[e]() functions *must* be cast to a pointer.
Just NULL is not good practise as NULL is theoretically allowed to
be an integer rather than a pointer.

Use (char *)NULL consistently instead of scattering a few (char *)0
and (void *)NULL into the mix.

Prompted by and probably ok deraadt@ millert@ kettenis@

Definitely ok mestre@ ratchov@


Revision tags: OPENBSD_5_9_BASE
# 1.22 15-Sep-2015 schwarze

update spacing in usage(); reminded by jmc@


# 1.21 14-Aug-2015 semarie

switch from system(3) to vfork(2)+execl(2) for invoking mount_nfs(8) when fstab
contains option for swapping to NFS files.

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.20 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.19 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_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 29-Dec-2010 stsp

Fix swapctl -A with DUIDs in /etc/fstab, and plug a small memory leak.
ok jsing@ (who also pointed out a DPADD tweak missing from my diff)


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.17 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


Revision tags: OPENBSD_4_2_BASE
# 1.16 17-Jul-2007 jmc

sync swapon usage(); from Igor Zinovik


# 1.15 16-Jul-2007 millert

Remove dead code and fix incorrect comment. From Igor Zinovik.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 12-Apr-2005 deraadt

handle snprintf potential -1 case


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.13 12-Jan-2004 avsm

- avoid variable sized static array (from millert@)
- check for snprintf overflow
- errx -> err for strdup

commit #1000!


# 1.12 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.11 03-Mar-2003 miod

Fix inaccuracies in comments.


Revision tags: OPENBSD_3_2_BASE
# 1.10 03-Jul-2002 deraadt

ansi


# 1.9 15-May-2002 art

typo in comment.
From Sam Smith S at mSmith.net


# 1.8 15-May-2002 art

Kill commented out stubs for swapoff.


Revision tags: OPENBSD_3_1_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.6 04-Jun-2001 mickey

return from main() don't exit


# 1.5 02-Jun-2001 miod

Various swapctl(8) improvements:
- don't print an error message when trying to enable swap on an
already active swap point.
- better handling of -t option.
- silently ignores swap points which are neither block devices nor
regular files, and don't consider swap points not starting with /dev/
as valid block devices, when invoked with -A.

Work by deraadt@ and myself, ok millert@


Revision tags: OPENBSD_2_9_BASE
# 1.4 09-Mar-2001 deraadt

PATH_MAX+1 is wrong. Not cranking libc/libc_r majors over this, since they just got cranked a little while ago. discussion with millert


Revision tags: OPENBSD_2_8_BASE
# 1.3 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


Revision tags: OPENBSD_2_7_BASE
# 1.2 26-Feb-2000 hugh

branches: 1.2.2;
add rcs idents


# 1.1 22-May-1999 weingart

branches: 1.1.1;
Initial revision


# 1.24 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.23 17-Mar-2016 krw

Last parameter to execl[e]() functions *must* be cast to a pointer.
Just NULL is not good practise as NULL is theoretically allowed to
be an integer rather than a pointer.

Use (char *)NULL consistently instead of scattering a few (char *)0
and (void *)NULL into the mix.

Prompted by and probably ok deraadt@ millert@ kettenis@

Definitely ok mestre@ ratchov@


Revision tags: OPENBSD_5_9_BASE
# 1.22 15-Sep-2015 schwarze

update spacing in usage(); reminded by jmc@


# 1.21 14-Aug-2015 semarie

switch from system(3) to vfork(2)+execl(2) for invoking mount_nfs(8) when fstab
contains option for swapping to NFS files.

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.20 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.19 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_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 29-Dec-2010 stsp

Fix swapctl -A with DUIDs in /etc/fstab, and plug a small memory leak.
ok jsing@ (who also pointed out a DPADD tweak missing from my diff)


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.17 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


Revision tags: OPENBSD_4_2_BASE
# 1.16 17-Jul-2007 jmc

sync swapon usage(); from Igor Zinovik


# 1.15 16-Jul-2007 millert

Remove dead code and fix incorrect comment. From Igor Zinovik.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 12-Apr-2005 deraadt

handle snprintf potential -1 case


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.13 12-Jan-2004 avsm

- avoid variable sized static array (from millert@)
- check for snprintf overflow
- errx -> err for strdup

commit #1000!


# 1.12 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.11 03-Mar-2003 miod

Fix inaccuracies in comments.


Revision tags: OPENBSD_3_2_BASE
# 1.10 03-Jul-2002 deraadt

ansi


# 1.9 15-May-2002 art

typo in comment.
From Sam Smith S at mSmith.net


# 1.8 15-May-2002 art

Kill commented out stubs for swapoff.


Revision tags: OPENBSD_3_1_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.6 04-Jun-2001 mickey

return from main() don't exit


# 1.5 02-Jun-2001 miod

Various swapctl(8) improvements:
- don't print an error message when trying to enable swap on an
already active swap point.
- better handling of -t option.
- silently ignores swap points which are neither block devices nor
regular files, and don't consider swap points not starting with /dev/
as valid block devices, when invoked with -A.

Work by deraadt@ and myself, ok millert@


Revision tags: OPENBSD_2_9_BASE
# 1.4 09-Mar-2001 deraadt

PATH_MAX+1 is wrong. Not cranking libc/libc_r majors over this, since they just got cranked a little while ago. discussion with millert


Revision tags: OPENBSD_2_8_BASE
# 1.3 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


Revision tags: OPENBSD_2_7_BASE
# 1.2 26-Feb-2000 hugh

branches: 1.2.2;
add rcs idents


# 1.1 22-May-1999 weingart

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 17-Mar-2016 krw

Last parameter to execl[e]() functions *must* be cast to a pointer.
Just NULL is not good practise as NULL is theoretically allowed to
be an integer rather than a pointer.

Use (char *)NULL consistently instead of scattering a few (char *)0
and (void *)NULL into the mix.

Prompted by and probably ok deraadt@ millert@ kettenis@

Definitely ok mestre@ ratchov@


Revision tags: OPENBSD_5_9_BASE
# 1.22 15-Sep-2015 schwarze

update spacing in usage(); reminded by jmc@


# 1.21 14-Aug-2015 semarie

switch from system(3) to vfork(2)+execl(2) for invoking mount_nfs(8) when fstab
contains option for swapping to NFS files.

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.20 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.19 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_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.18 29-Dec-2010 stsp

Fix swapctl -A with DUIDs in /etc/fstab, and plug a small memory leak.
ok jsing@ (who also pointed out a DPADD tweak missing from my diff)


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.17 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


Revision tags: OPENBSD_4_2_BASE
# 1.16 17-Jul-2007 jmc

sync swapon usage(); from Igor Zinovik


# 1.15 16-Jul-2007 millert

Remove dead code and fix incorrect comment. From Igor Zinovik.


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.14 12-Apr-2005 deraadt

handle snprintf potential -1 case


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.13 12-Jan-2004 avsm

- avoid variable sized static array (from millert@)
- check for snprintf overflow
- errx -> err for strdup

commit #1000!


# 1.12 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.11 03-Mar-2003 miod

Fix inaccuracies in comments.


Revision tags: OPENBSD_3_2_BASE
# 1.10 03-Jul-2002 deraadt

ansi


# 1.9 15-May-2002 art

typo in comment.
From Sam Smith S at mSmith.net


# 1.8 15-May-2002 art

Kill commented out stubs for swapoff.


Revision tags: OPENBSD_3_1_BASE
# 1.7 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.6 04-Jun-2001 mickey

return from main() don't exit


# 1.5 02-Jun-2001 miod

Various swapctl(8) improvements:
- don't print an error message when trying to enable swap on an
already active swap point.
- better handling of -t option.
- silently ignores swap points which are neither block devices nor
regular files, and don't consider swap points not starting with /dev/
as valid block devices, when invoked with -A.

Work by deraadt@ and myself, ok millert@


Revision tags: OPENBSD_2_9_BASE
# 1.4 09-Mar-2001 deraadt

PATH_MAX+1 is wrong. Not cranking libc/libc_r majors over this, since they just got cranked a little while ago. discussion with millert


Revision tags: OPENBSD_2_8_BASE
# 1.3 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


Revision tags: OPENBSD_2_7_BASE
# 1.2 26-Feb-2000 hugh

branches: 1.2.2;
add rcs idents


# 1.1 22-May-1999 weingart

branches: 1.1.1;
Initial revision