aboutsummaryrefslogtreecommitdiff
path: root/swapon.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-10-05 16:24:54 +0000
committerEric Andersen <andersen@codepoet.org>1999-10-05 16:24:54 +0000
commitcc8ed39b240180b58810784f844e253263594ac3 (patch)
tree15feebbb4be9a9168209609f48f0b100f9364420 /swapon.c
downloadbusybox-cc8ed39b240180b58810784f844e253263594ac3.tar.gz
Initial revision
Diffstat (limited to 'swapon.c')
-rw-r--r--swapon.c34
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 @@
+#include <stdio.h>
+#include <mntent.h>
+#include <sys/swap.h>
+#include "internal.h"
+
+const char swapon_usage[] = "swapon block-device\n"
+"\n"
+"\tSwap virtual memory pages on the given device.\n";
+
+extern int
+swapon_fn(const struct FileInfo * i)
+{
+ FILE *swapsTable;
+ struct mntent m;
+
+ if (!(swapon(i->source, 0))) {
+ if ((swapsTable = setmntent("/etc/swaps", "a+"))) {
+ /* Needs the cast to avoid warning about conversion from
+ * const char* to just char*
+ */
+ m.mnt_fsname = (char*)i->source;
+ m.mnt_dir = "none";
+ m.mnt_type = "swap";
+ m.mnt_opts = "sw";
+ m.mnt_freq = 0;
+ m.mnt_passno = 0;
+ addmntent(swapsTable, &m);
+ endmntent(swapsTable);
+ }
+ return (0);
+ }
+ return (-1);
+}
+