1 From 8c7fcbd7521c1bafcf6e792af8b140c256e2cbfd Mon Sep 17 00:00:00 2001
2 From: Tito Ragusa <farmatito@tiscali.it>
3 Date: Thu, 8 Aug 2013 10:21:27 +0200
4 Subject: [PATCH] swapon: support "pri=NNN" in fstab
7 swap_on_off_main 244 365 +121
9 Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 util-linux/swaponoff.c | 14 ++++++++++++++
13 1 file changed, 14 insertions(+)
15 diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
16 index 54867ec..afad4ab 100644
17 --- a/util-linux/swaponoff.c
18 +++ b/util-linux/swaponoff.c
19 @@ -95,6 +95,20 @@ static int do_em_all(void)
20 if (applet_name[5] != 'n'
21 || hasmntopt(m, MNTOPT_NOAUTO) == NULL
23 +#if ENABLE_FEATURE_SWAPON_PRI
25 + g_flags = 0; /* each swap space might have different flags */
26 + p = strstr(m->mnt_opts, "pri=");
28 + /* Max allowed 32767 (==SWAP_FLAG_PRIO_MASK) */
29 + int swap_prio = MIN(bb_strtoull(p + 4 , NULL, 10), SWAP_FLAG_PRIO_MASK);
30 + /* We want to allow "NNNN,foo", thus errno == EINVAL is allowed too */
31 + if (errno != ERANGE) {
32 + g_flags = SWAP_FLAG_PREFER |
33 + (swap_prio << SWAP_FLAG_PRIO_SHIFT);
37 err += swap_enable_disable(m->mnt_fsname);