diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
commit | cc8ed39b240180b58810784f844e253263594ac3 (patch) | |
tree | 15feebbb4be9a9168209609f48f0b100f9364420 /swapon.c | |
download | busybox-w32-0_29alpha2.tar.gz busybox-w32-0_29alpha2.tar.bz2 busybox-w32-0_29alpha2.zip |
Initial revision0_29alpha2
Diffstat (limited to 'swapon.c')
-rw-r--r-- | swapon.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/swapon.c b/swapon.c new file mode 100644 index 000000000..78360a55f --- /dev/null +++ b/swapon.c | |||
@@ -0,0 +1,34 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <mntent.h> | ||
3 | #include <sys/swap.h> | ||
4 | #include "internal.h" | ||
5 | |||
6 | const char swapon_usage[] = "swapon block-device\n" | ||
7 | "\n" | ||
8 | "\tSwap virtual memory pages on the given device.\n"; | ||
9 | |||
10 | extern int | ||
11 | swapon_fn(const struct FileInfo * i) | ||
12 | { | ||
13 | FILE *swapsTable; | ||
14 | struct mntent m; | ||
15 | |||
16 | if (!(swapon(i->source, 0))) { | ||
17 | if ((swapsTable = setmntent("/etc/swaps", "a+"))) { | ||
18 | /* Needs the cast to avoid warning about conversion from | ||
19 | * const char* to just char* | ||
20 | */ | ||
21 | m.mnt_fsname = (char*)i->source; | ||
22 | m.mnt_dir = "none"; | ||
23 | m.mnt_type = "swap"; | ||
24 | m.mnt_opts = "sw"; | ||
25 | m.mnt_freq = 0; | ||
26 | m.mnt_passno = 0; | ||
27 | addmntent(swapsTable, &m); | ||
28 | endmntent(swapsTable); | ||
29 | } | ||
30 | return (0); | ||
31 | } | ||
32 | return (-1); | ||
33 | } | ||
34 | |||