diff options
-rw-r--r-- | toys/other/swapon.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/toys/other/swapon.c b/toys/other/swapon.c index 838d382a..0d65040a 100644 --- a/toys/other/swapon.c +++ b/toys/other/swapon.c @@ -2,15 +2,17 @@ * * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> -USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) +USE_SWAPON(NEWTOY(swapon, "<1>1p#<0>32767d", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) config SWAPON bool "swapon" default y help - usage: swapon [-p priority] filename + usage: swapon [-d] [-p priority] filename Enable swapping on a given device/file. + + -d Discard freed SSD pages */ #define FOR_swapon @@ -22,10 +24,11 @@ GLOBALS( void swapon_main(void) { - int flags = 0; + // 0x70000 = SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE|SWAP_FLAG_DISCARD_PAGES + int flags = (toys.optflags&FLAG_d)*0x70000; if (toys.optflags) - flags = SWAP_FLAG_PREFER | (TT.priority << SWAP_FLAG_PRIO_SHIFT); + flags |= SWAP_FLAG_PREFER | (TT.priority << SWAP_FLAG_PRIO_SHIFT); if (swapon(*toys.optargs, flags)) perror_exit("Couldn't swapon '%s'", *toys.optargs); |