aboutsummaryrefslogtreecommitdiff
path: root/sbin/swapon
Commit message (Collapse)AuthorAgeFilesLines
* The -F flag of swapon(8) requires -a to work.Benedict Reuschling2020-05-191-3/+4
| | | | | | | | | | | | | Before this change, swapon(8) implied that -F works as a standalone option, which is not the case and would produce a usage message. This change extends the description of the -F option to mention that -a is required with it. PR: 238551 Submitted by: Christian Baltini MFC after: 5 days Notes: svn path=/head/; revision=361250
* - Fix logic error in swapoff case: follow same handling of p andXin LI2020-05-041-6/+4
| | | | | | | | | | linelen in the swapon case. - Use strlcpy instead of strncpy. MFC after: 1 week Notes: svn path=/head/; revision=360619
* Fix a logic bug in error handling code. It is an error if p == NULL.Don Lewis2019-12-091-1/+1
| | | | | | | | | | | The linelen tests are only meaningful when p != NULL. Reported by: Coverity Coverity CID: 1368655 MFC after: 1 month Notes: svn path=/head/; revision=355553
* swap_pager.c reserves 2 blocks for a bsd label. Change that 2 to theDoug Moore2019-08-152-3/+14
| | | | | | | | | | | | | | | | | | | | | expression howmany(BBSIZE, PAGE_SIZE), where BBSIZE is the size of the boot block area. That can be less than 2 if PAGE_SIZE is big. swapon(8) has an option to trim (delete) all the blocks of a device at startup. However, if the first of those blocks is a bsd label, then trimming those blocks is destructive. Change swapon to leave the first BBSIZE bytes untrimmed. Update manual pages to reflect changes in how swapon and how it may be used, espeically in association with savecore. Reviewed by: alc Approved by: markj (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D21191 Notes: svn path=/head/; revision=351064
* Rewrite the comments that explain swapon_trim() to make them moreDoug Moore2019-07-261-5/+11
| | | | | | | | | | | comprehensible. Suggested by: rpokala Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D21034 Notes: svn path=/head/; revision=350359
* In trimming on startup, invoke swapon before closing the fd used forDoug Moore2019-07-201-8/+15
| | | | | | | | | | | | | trimming so that a geli device isn't detached before swapon is invoked. Submitted by: sigsys_gmail.com Discussed with: alc Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D21006 Notes: svn path=/head/; revision=350183
* You can't use block special nodes for swap, so don't let that happen.Doug Moore2019-06-221-3/+2
| | | | | | | | | | | Fix a style violation with regard to header file arrangement. Improved by: alc Approved by: markj, kib (mentor) Differential Revision: https://reviews.freebsd.org/D20723 Notes: svn path=/head/; revision=349293
* Modify swapon(8) to invoke BIO_DELETE to trim swap devices, either ifDoug Moore2019-06-222-7/+61
| | | | | | | | | | | | | | '-E' appears on the swapon command line, or if "trimonce" appears as an fstab option. Discussed at: BSDCAN Tested by: markj Reviewed by: markj Approved by: markj (mentor) Differential Revision:https://reviews.freebsd.org/D20599 Notes: svn path=/head/; revision=349286
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Fix late and noauto with geli swapDmitry Marakasov2017-03-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | With the following in /etc/fstab: /dev/gpt/swap.eli none swap sw,late 0 0 swap will not be enabled, with `swapon -aL' complaining: swapon: Invalid option: late This happens because swap_on_geli_args() which parses geli arguments out of all mount options does not expect late or noauto among them. Fix this by explicitly allowing these arguments. Reviewed by: jilles Approved by: jilles MFC after: 2 weeks Differential Revision: D9835 Notes: svn path=/head/; revision=315242
* Renumber copyright clause 4Warner Losh2017-02-282-2/+2
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* swapoff: Remove only late devices with -aL.Jilles Tjoelker2016-10-212-1/+11
| | | | | | | | | | | | | | | | | | | | | Currently, '/etc/rc.d/swaplate stop' removes all swap devices. This can be very slow and may not even be possible if there is a lot of swap space in use. However, removing swap devices is only needed for late swap devices that may depend on daemons that subsequent shutdown steps stop. Normal swap devices such as hard disk partitions will remain available throughout the shutdown process and need not be removed. In swapoff, interpret -aL to remove late swap devices only, and use this in etc/rc.d/swaplate. The meaning of -aL in swapon remains unchanged (add all swap devices, both normal and late). PR: 187081 Reviewed by: wblock (man page only), ngie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8126 Notes: svn path=/head/; revision=307755
* swapon(8): Update to reality: swapoff ignores -L and the late option in fstab.Jilles Tjoelker2016-10-021-9/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=306585
* Stop using the non-standard basename_r() function.Ed Schouten2016-05-311-4/+10
| | | | | | | | | | | | | | | | This change makes the code use the POSIX basename() function. It has the advantage that (if implemented correctly), it also imposes no restrict on the pathname length. Notice that I haven't added any error handling to the strdup() call. It looks like none of the other calls to strdup() and malloc() performed by this utility do it either. Reviewed by: hrs Differential Revision: https://reviews.freebsd.org/D6626 Notes: svn path=/head/; revision=301024
* sbin: minor spelling fixes.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298858
* Explicitly add more files to the 'runtime' package.Glen Barber2016-02-091-0/+1
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295450
* Delete argsize to fix a -Wunused-but-set-variable warning with gcc 4.9Enji Cooper2016-02-011-2/+2
| | | | | | | | | | | | | The variable isn't actually checked -- just the end result which gets returned from the function Differential Revision: https://reviews.freebsd.org/D5156 Reviewed by: araujo, delphij MFC after: 1 month Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=295121
* Call va_end on ap when vsnprintf fails in run_cmd(..) to clean upEnji Cooper2015-12-091-0/+1
| | | | | | | | | | | the variable state MFC after: 1 week Reported by: cppcheck Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=292005
* Allow to disable BIO_DELETE passthru in fstab for swap-on-geli devices byPawel Jakub Dawidek2015-08-081-4/+6
| | | | | | | | | | passing 'notrim' option. PR: 198863 Submitted by: Matthew D. Fuller fullermd at over-yonder dot net Notes: svn path=/head/; revision=286445
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+19
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-271-2/+1
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Merge from head@274682Simon J. Gerraty2014-11-191-8/+1
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=274683
| * | Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * | Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * | Merge headSimon J. Gerraty2014-04-282-7/+6
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * \ \ Merge headSimon J. Gerraty2013-09-111-58/+59
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=255477
| * \ \ \ Merge from headSimon J. Gerraty2013-09-052-29/+574
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=255263
| * | | | | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | Convert sbin/ to LIBADDBaptiste Daroussin2014-11-251-2/+1
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce overlinking Notes: svn path=/head/; revision=275030
* | | | | Do not add late flag when file= is specified because it has a badHiroki Sato2014-10-101-8/+1
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | side-effect. The specified file should exist before the fstab line. Reported by: wblock (long time ago) MFC after: 1 day Notes: svn path=/head/; revision=272885
* | | | swapon: Fix buffer overflow when configuring encrypted swap on GBDE.Jilles Tjoelker2013-12-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: bin/184950 Tested by: Radim Kolar MFC after: 3 days Notes: svn path=/head/; revision=259677
* | | | - Purge one more reference to ad(4)[1].Sergey Kandaurov2013-11-221-6/+4
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | - NSWAPDEV limit has gone. Noticed by: Sergey V. Dyatko [1] MFC after: 1 week Notes: svn path=/head/; revision=258469
* | | Style clean-ups.Hiroki Sato2013-09-051-54/+48
| | | | | | | | | | | | | | | | | | | | | Reviewed by: md5 Notes: svn path=/head/; revision=255267
* | | Enable "late" option when a file= option is specified in /etc/fstab.Hiroki Sato2013-09-051-4/+11
| |/ |/| | | | | | | | | | | | | | | The file= option requires rw mount where the backing store exists but it does not work because rc.d/swap runs before rc.d/fsck. Reported by: wblock Notes: svn path=/head/; revision=255265
* | Make two buffer variables static for now. It is not safe toXin LI2013-07-311-1/+1
| | | | | | | | | | | | | | | | | | reference stack memory after return. MFC after: 2 weeks Notes: svn path=/head/; revision=253834
* | Plug a memory leak.Xin LI2013-07-021-0/+7
| | | | | | | | Notes: svn path=/head/; revision=252514
* | Correct a typo in comment.Xin LI2013-07-011-1/+1
| | | | | | | | Notes: svn path=/head/; revision=252480
* | - Modify swapon(8) so that it uses most of geli(8) defaults for swap,Xin LI2013-06-291-160/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which is presently: AES-XTS, no authentication. Create provider with pagesize as sectorsize by default. - Rewrite parsing code for geli(8)-backed swap options, now options are required to be exact match, and unrecognized options will trigger a warning. - Don't initialize GELI device if it's already initialized. This restores previous behavior. - Don't duplicate file descriptor when working with geli(8) and gbde(8) as there is no need to communicate with the utility other than exit status. - When calling swap_on_off_* routines, which_prog can only be SWAP_ON or SWAP_OFF. Eliminate unneeded case branches by replacing switch with if's. - Plug a few memory leaks. Reviewed by: hrs (but bugs are mine) MFC after: 1 week X-MFC-with: r252310, r252332, r252345 Notes: svn path=/head/; revision=252388
* | Fix build with gcc.Hiroki Sato2013-06-281-3/+5
| | | | | | | | Notes: svn path=/head/; revision=252345
* | Fix build.Hiroki Sato2013-06-281-11/+11
| | | | | | | | | | | | | | Spotted by: gjb Notes: svn path=/head/; revision=252332
* | - Add vnode-backed swap space specification support. This is enabled whenHiroki Sato2013-06-272-29/+566
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | device names "md" or "md[0-9]*" and a "file" option are specified in /etc/fstab like this: md none swap sw,file=/swap.bin 0 0 - Add GBDE/GELI encrypted swap space specification support, which rc.d/encswap supported. The /etc/fstab lines are like the following: /dev/ada1p1.bde none swap sw 0 0 /dev/ada1p2.eli none swap sw 0 0 .eli devices accepts aalgo, ealgo, keylen, and sectorsize as options. swapctl(8) can understand an encrypted device in the command line like this: # swapctl -a /dev/ada2p1.bde - "-L" flag is added to support "late" option to defer swapon until rc.d/mountlate runs. - rc.d script change: rc.d/encswap -> removed rc.d/addswap -> just display a warning message if $swapfile is defined rc.d/swap1 -> renamed to rc.d/swap rc.d/swaplate -> newly added to support "late" option These changes alleviate a race condition between device creation/removal and swapon/swapoff. MFC after: 1 week Reviewed by: wblock (manual page) Notes: svn path=/head/; revision=252310
* Add missing static keywords for global variables to tools in sbin/.Ed Schouten2011-11-041-1/+1
| | | | | | | | | These tools declare global variables without using the static keyword, even though their use is limited to a single C-file, or without placing an extern declaration of them in the proper header file. Notes: svn path=/head/; revision=227081
* Build swapon with WARNS=6.Ed Schouten2011-10-252-6/+5
| | | | | | | Don't use a variable called stat, because it collides with stat(2). Notes: svn path=/head/; revision=226742
* Add new option -F to specify alternative location of the /etc/fstabMaxim Sobolev2011-10-252-4/+29
| | | | | | | | | file. MFC after: 1 month Notes: svn path=/head/; revision=226712
* Raise WARNS for various tools where possible.Ed Schouten2010-01-171-1/+1
| | | | | | | Submitted by: Marius Nünnerich <marius@nuenneri.ch> Notes: svn path=/head/; revision=202532
* Switch the default WARNS level for sbin/ to 6.Ruslan Ermilov2009-10-191-0/+1
| | | | | | | Submitted by: Ulrich Spörlein Notes: svn path=/head/; revision=198236