Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 391144 Details for
Bug 468598
sys-apps/busybox: swapon: add support for the -e option
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for busybox 1.20 and 1.21
busybox-1.20-swaponoff-ifexists.patch (text/plain), 2.82 KB, created by
René Rhéaume
on 2014-12-07 17:05:16 UTC
(
hide
)
Description:
Patch for busybox 1.20 and 1.21
Filename:
MIME Type:
Creator:
René Rhéaume
Created:
2014-12-07 17:05:16 UTC
Size:
2.82 KB
patch
obsolete
>--- a/util-linux/swaponoff.c >+++ b/util-linux/swaponoff.c >@@ -8,19 +8,21 @@ > */ > > //usage:#define swapon_trivial_usage >-//usage: "[-a]" IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]" >+//usage: "[-a] [-e]" IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]" > //usage:#define swapon_full_usage "\n\n" > //usage: "Start swapping on DEVICE\n" > //usage: "\n -a Start swapping on all swap devices" >+//usage: "\n -e Silently skip devices that do not exist" > //usage: IF_FEATURE_SWAPON_PRI( > //usage: "\n -p PRI Set swap device priority" > //usage: ) > //usage: > //usage:#define swapoff_trivial_usage >-//usage: "[-a] [DEVICE]" >+//usage: "[-a] [-e] [DEVICE]" > //usage:#define swapoff_full_usage "\n\n" > //usage: "Stop swapping on DEVICE\n" > //usage: "\n -a Stop swapping on all swap devices" >+//usage: "\n -e Silently skip devices that do not exist" > > #include "libbb.h" > #include <mntent.h> >@@ -49,13 +51,14 @@ struct globals { > #endif > #define INIT_G() do { } while (0) > >-static int swap_enable_disable(char *device) >+static int swap_enable_disable(char *device, bool ifexists) > { > int status; > struct stat st; > > resolve_mount_spec(&device); >- xstat(device, &st); >+ if (!ifexists) >+ xstat(device, &st); > > #if ENABLE_DESKTOP > /* test for holes */ >@@ -70,14 +73,16 @@ static int swap_enable_disable(char *device) > status = swapoff(device); > > if (status != 0) { >- bb_simple_perror_msg(device); >- return 1; >+ if ((!ifexists) || (errno != ENOENT)) { >+ bb_simple_perror_msg(device); >+ return 1; >+ } > } > > return 0; > } > >-static int do_em_all(void) >+static int do_em_all(bool ifexists) > { > struct mntent *m; > FILE *f; >@@ -95,7 +100,7 @@ static int do_em_all(void) > if (applet_name[5] != 'n' > || hasmntopt(m, MNTOPT_NOAUTO) == NULL > ) { >- err += swap_enable_disable(m->mnt_fsname); >+ err += swap_enable_disable(m->mnt_fsname, ifexists); > } > } > } >@@ -114,21 +119,21 @@ int swap_on_off_main(int argc UNUSED_PARAM, char **argv) > INIT_G(); > > #if !ENABLE_FEATURE_SWAPON_PRI >- ret = getopt32(argv, "a"); >+ ret = getopt32(argv, "ae"); > #else > if (applet_name[5] == 'n') > opt_complementary = "p+"; >- ret = getopt32(argv, (applet_name[5] == 'n') ? "ap:" : "a", &g_flags); >+ ret = getopt32(argv, (applet_name[5] == 'n') ? "aep:" : "ae", &g_flags); > >- if (ret & 2) { // -p >+ if (ret & 4) { // -p > g_flags = SWAP_FLAG_PREFER | > ((g_flags & SWAP_FLAG_PRIO_MASK) << SWAP_FLAG_PRIO_SHIFT); > ret &= 1; > } > #endif > >- if (ret /* & 1: not needed */) // -a >- return do_em_all(); >+ if (ret & 1) // -a >+ return do_em_all((ret & 2) > 0); > > argv += optind; > if (!*argv) >@@ -136,7 +141,7 @@ int swap_on_off_main(int argc UNUSED_PARAM, char **argv) > > /* ret = 0; redundant */ > do { >- ret += swap_enable_disable(*argv); >+ ret += swap_enable_disable(*argv, ((ret & 2) > 0)); > } while (*++argv); > > return ret;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 468598
: 391144 |
391146
|
391148