Upload Tizen:Base source
[framework/base/util-linux-ng.git] / mount / swapon.c
1 /*
2  * A swapon(8)/swapoff(8) for Linux 0.99.
3  */
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <getopt.h>
7 #include <string.h>
8 #include <mntent.h>
9 #include <errno.h>
10 #include <sys/stat.h>
11 #include <unistd.h>
12 #include <sys/types.h>
13 #include <sys/wait.h>
14 #include <fcntl.h>
15 #include <stdint.h>
16 #include <err.h>
17
18 #include "bitops.h"
19 #include "blkdev.h"
20 #include "swap_constants.h"
21 #include "nls.h"
22 #include "fsprobe.h"
23 #include "pathnames.h"
24 #include "swapheader.h"
25
26 #define PATH_MKSWAP     "/sbin/mkswap"
27
28 #ifdef HAVE_SYS_SWAP_H
29 # include <sys/swap.h>
30 #endif
31
32 #ifndef SWAPON_HAS_TWO_ARGS
33 /* libc is insane, let's call the kernel */
34 # include <sys/syscall.h>
35 # define swapon(path, flags) syscall(SYS_swapon, path, flags)
36 # define swapoff(path) syscall(SYS_swapoff, path)
37 #endif
38
39 #define streq(s, t)     (strcmp ((s), (t)) == 0)
40
41 #define QUIET   1
42 #define CANONIC 1
43
44 #define MAX_PAGESIZE    (64 * 1024)
45
46 enum {
47         SIG_SWAPSPACE = 1,
48         SIG_SWSUSPEND
49 };
50
51 #define SWAP_SIGNATURE          "SWAPSPACE2"
52 #define SWAP_SIGNATURE_SZ       (sizeof(SWAP_SIGNATURE) - 1)
53
54 int all;
55 int priority = -1;      /* non-prioritized swap by default */
56
57 /* If true, don't complain if the device/file doesn't exist */
58 int ifexists;
59 int fixpgsz;
60
61 int verbose;
62 char *progname;
63
64 static struct option longswaponopts[] = {
65                 /* swapon only */
66         { "priority", required_argument, 0, 'p' },
67         { "ifexists", 0, 0, 'e' },
68         { "summary", 0, 0, 's' },
69         { "fixpgsz", 0, 0, 'f' },
70                 /* also for swapoff */
71         { "all", 0, 0, 'a' },
72         { "help", 0, 0, 'h' },
73         { "verbose", 0, 0, 'v' },
74         { "version", 0, 0, 'V' },
75         { NULL, 0, 0, 0 }
76 };
77
78 static struct option *longswapoffopts = &longswaponopts[4];
79
80 static int cannot_find(const char *special);
81
82 #define PRINT_USAGE_SPECIAL(_fp) \
83                 fprintf(_fp, _( \
84         "The <special> parameter:\n" \
85         " {-L label | LABEL=label}             LABEL of device to be used\n" \
86         " {-U uuid  | UUID=uuid}               UUID of device to be used\n" \
87         " <device>                             name of device to be used\n" \
88         " <file>                               name of file to be used\n\n"))
89
90 static void
91 swapon_usage(FILE *fp, int n) {
92         fprintf(fp, _("\nUsage:\n"
93         " %1$s -a [-e] [-v] [-f]             enable all swaps from /etc/fstab\n"
94         " %1$s [-p priority] [-v] [-f] <special>  enable given swap\n"
95         " %1$s -s                            display swap usage summary\n"
96         " %1$s -h                            display help\n"
97         " %1$s -V                            display version\n\n"), progname);
98
99         PRINT_USAGE_SPECIAL(fp);
100
101         exit(n);
102 }
103
104 static void
105 swapoff_usage(FILE *fp, int n) {
106         fprintf(fp, _("\nUsage:\n"
107         " %1$s -a [-v]                      disable all swaps\n"
108         " %1$s [-v] <special>               disable given swap\n"
109         " %1$s -h                           display help\n"
110         " %1$s -V                           display version\n\n"), progname);
111
112         PRINT_USAGE_SPECIAL(fp);
113
114         exit(n);
115 }
116
117 /*
118  * contents of /proc/swaps
119  */
120 static int numSwaps;
121 static char **swapFiles;        /* array of swap file and partition names */
122
123 static void
124 read_proc_swaps(void) {
125         FILE *swaps;
126         char line[1024];
127         char *p, **q;
128
129         numSwaps = 0;
130         swapFiles = NULL;
131
132         swaps = fopen(_PATH_PROC_SWAPS, "r");
133         if (swaps == NULL)
134                 return;         /* nothing wrong */
135
136         /* skip the first line */
137         if (!fgets(line, sizeof(line), swaps)) {
138                 /* do not whine about an empty file */
139                 if (ferror(swaps))
140                         warn(_("%s: unexpected file format"), _PATH_PROC_SWAPS);
141                 fclose(swaps);
142                 return;
143         }
144         /* make sure the first line is the header */
145         if (line[0] != '\0' && strncmp(line, "Filename\t", 9))
146                 goto valid_first_line;
147
148         while (fgets(line, sizeof(line), swaps)) {
149  valid_first_line:
150                 /*
151                  * Cut the line "swap_device  ... more info" after device.
152                  * This will fail with names with embedded spaces.
153                  */
154                 for (p = line; *p && *p != ' '; p++);
155                 *p = 0;
156
157                 q = realloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
158                 if (q == NULL)
159                         break;
160                 swapFiles = q;
161
162                 swapFiles[numSwaps++] = strdup(line);
163         }
164         fclose(swaps);
165 }
166
167 static int
168 is_in_proc_swaps(const char *fname) {
169         int i;
170
171         for (i = 0; i < numSwaps; i++)
172                 if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
173                         return 1;
174         return 0;
175 }
176
177 static int
178 display_summary(void)
179 {
180        FILE *swaps;
181        char line[1024] ;
182
183        if ((swaps = fopen(_PATH_PROC_SWAPS, "r")) == NULL) {
184                warn(_("%s: open failed"), _PATH_PROC_SWAPS);
185                return -1;
186        }
187
188        while (fgets(line, sizeof(line), swaps))
189                printf("%s", line);
190
191        fclose(swaps);
192        return 0 ;
193 }
194
195 /* calls mkswap */
196 static int
197 swap_reinitialize(const char *device) {
198         const char *label = fsprobe_get_label_by_devname(device);
199         const char *uuid  = fsprobe_get_uuid_by_devname(device);
200         pid_t pid;
201         int status, ret;
202         char *cmd[7];
203         int idx=0;
204
205         warnx(_("%s: reinitializing the swap."), device);
206
207         switch((pid=fork())) {
208         case -1: /* fork error */
209                 warn(_("fork failed"));
210                 return -1;
211
212         case 0: /* child */
213                 cmd[idx++] = PATH_MKSWAP;
214                 if (label && *label) {
215                         cmd[idx++] = "-L";
216                         cmd[idx++] = (char *) label;
217                 }
218                 if (uuid && *uuid) {
219                         cmd[idx++] = "-U";
220                         cmd[idx++] = (char *) uuid;
221                 }
222                 cmd[idx++] = (char *) device;
223                 cmd[idx++] = NULL;
224                 execv(cmd[0], cmd);
225                 err(EXIT_FAILURE, _("execv failed"));
226
227         default: /* parent */
228                 do {
229                         if ((ret = waitpid(pid, &status, 0)) < 0
230                                         && errno == EINTR)
231                                 continue;
232                         else if (ret < 0) {
233                                 warn(_("waitpid failed"));
234                                 return -1;
235                         }
236                 } while (0);
237
238                 /* mkswap returns: 0=suss, 1=error */
239                 if (WIFEXITED(status) && WEXITSTATUS(status)==0)
240                         return 0; /* ok */
241         }
242         return -1; /* error */
243 }
244
245 static int
246 swap_rewrite_signature(const char *devname, unsigned int pagesize)
247 {
248         int fd, rc = -1;
249
250         fd = open(devname, O_WRONLY);
251         if (fd == -1) {
252                 warn(_("%s: open failed"), devname);
253                 return -1;
254         }
255
256         if (lseek(fd, pagesize - SWAP_SIGNATURE_SZ, SEEK_SET) < 0) {
257                 warn(_("%s: lseek failed"), devname);
258                 goto err;
259         }
260
261         if (write(fd, (void *) SWAP_SIGNATURE,
262                         SWAP_SIGNATURE_SZ) != SWAP_SIGNATURE_SZ) {
263                 warn(_("%s: write signature failed"), devname);
264                 goto err;
265         }
266
267         rc  = 0;
268 err:
269         close(fd);
270         return rc;
271 }
272
273 static int
274 swap_detect_signature(const char *buf, int *sig)
275 {
276         if (memcmp(buf, "SWAP-SPACE", 10) == 0 ||
277             memcmp(buf, "SWAPSPACE2", 10) == 0)
278                 *sig = SIG_SWAPSPACE;
279
280         else if (memcmp(buf, "S1SUSPEND", 9) == 0 ||
281                  memcmp(buf, "S2SUSPEND", 9) == 0 ||
282                  memcmp(buf, "ULSUSPEND", 9) == 0 ||
283                  memcmp(buf, "\xed\xc3\x02\xe9\x98\x56\xe5\x0c", 8) == 0)
284                 *sig = SIG_SWSUSPEND;
285         else
286                 return 0;
287
288         return 1;
289 }
290
291 static char *
292 swap_get_header(int fd, int *sig, unsigned int *pagesize)
293 {
294         char *buf;
295         ssize_t datasz;
296         unsigned int page;
297
298         *pagesize = 0;
299         *sig = 0;
300
301         buf = malloc(MAX_PAGESIZE);
302         if (!buf)
303                 return NULL;
304
305         datasz = read(fd, buf, MAX_PAGESIZE);
306         if (datasz == (ssize_t) -1)
307                 goto err;
308
309         for (page = 0x1000; page <= MAX_PAGESIZE; page <<= 1) {
310                 /* skip 32k pagesize since this does not seem to
311                  * be supported */
312                 if (page == 0x8000)
313                         continue;
314                 /* the smallest swap area is PAGE_SIZE*10, it means
315                  * 40k, that's less than MAX_PAGESIZE */
316                 if (datasz < (page - SWAP_SIGNATURE_SZ))
317                         break;
318                 if (swap_detect_signature(buf + page - SWAP_SIGNATURE_SZ, sig)) {
319                         *pagesize = page;
320                         break;
321                 }
322         }
323
324         if (*pagesize)
325                 return buf;
326 err:
327         free(buf);
328         return NULL;
329 }
330
331 /* returns real size of swap space */
332 unsigned long long
333 swap_get_size(const char *hdr, const char *devname, unsigned int pagesize)
334 {
335         unsigned int last_page = 0;
336         int swap_version = 0;
337         int flip = 0;
338         struct swap_header_v1_2 *s;
339
340         s = (struct swap_header_v1_2 *) hdr;
341         if (s->version == 1) {
342                 swap_version = 1;
343                 last_page = s->last_page;
344         } else if (swab32(s->version) == 1) {
345                 flip = 1;
346                 swap_version = 1;
347                 last_page = swab32(s->last_page);
348         }
349         if (verbose)
350                 warnx(_("%s: found %sswap v%d signature string"
351                                 " for %d KiB PAGE_SIZE\n"),
352                         devname,
353                         flip ? "other-endian " : "",
354                         swap_version,
355                         pagesize / 1024);
356
357         return (last_page + 1) * pagesize;
358 }
359
360 static int
361 swapon_checks(const char *special)
362 {
363         struct stat st;
364         int fd = -1, sig;
365         char *hdr = NULL;
366         unsigned int pagesize;
367         unsigned long long devsize = 0;
368
369         if (stat(special, &st) < 0) {
370                 warn(_("%s: stat failed"), special);
371                 goto err;
372         }
373
374         /* people generally dislike this warning - now it is printed
375            only when `verbose' is set */
376         if (verbose) {
377                 int permMask = (S_ISBLK(st.st_mode) ? 07007 : 07077);
378
379                 if ((st.st_mode & permMask) != 0)
380                         warnx(_("%s: insecure permissions %04o, %04o suggested."),
381                                 special, st.st_mode & 07777,
382                                 ~permMask & 0666);
383         }
384
385         /* test for holes by LBT */
386         if (S_ISREG(st.st_mode)) {
387                 if (st.st_blocks * 512 < st.st_size) {
388                         warnx(_("%s: skipping - it appears to have holes."),
389                                 special);
390                         goto err;
391                 }
392                 devsize = st.st_size;
393         }
394
395         fd = open(special, O_RDONLY);
396         if (fd == -1) {
397                 warn(_("%s: open failed"), special);
398                 goto err;
399         }
400
401         if (S_ISBLK(st.st_mode) && blkdev_get_size(fd, &devsize)) {
402                 warn(_("%s: get size failed"), special);
403                 goto err;
404         }
405
406         hdr = swap_get_header(fd, &sig, &pagesize);
407         if (!hdr) {
408                 warn(_("%s: read swap header failed"), special);
409                 goto err;
410         }
411
412         if (sig == SIG_SWAPSPACE && pagesize) {
413                 unsigned long long swapsize =
414                                 swap_get_size(hdr, special, pagesize);
415                 if (verbose)
416                         warnx("%s: pagesize=%d, swapsize=%llu, devsize=%llu",
417                                 special, pagesize, swapsize, devsize);
418
419                 if (swapsize > devsize) {
420                         if (verbose)
421                                 warnx(_("%s: last_page 0x%08llx is larger"
422                                         " than actual size of swapspace"),
423                                         special, swapsize);
424                 } else if (getpagesize() != pagesize) {
425                         if (fixpgsz) {
426                                 warnx(_("%s: swap format pagesize does not match."),
427                                         special);
428                                 if (swap_reinitialize(special) < 0)
429                                         goto err;
430                         } else
431                                 warnx(_("%s: swap format pagesize does not match. "
432                                         "(Use --fixpgsz to reinitialize it.)"),
433                                         special);
434                 }
435         } else if (sig == SIG_SWSUSPEND) {
436                 /* We have to reinitialize swap with old (=useless) software suspend
437                  * data. The problem is that if we don't do it, then we get data
438                  * corruption the next time an attempt at unsuspending is made.
439                  */
440                 warnx(_("%s: software suspend data detected. "
441                                 "Rewriting the swap signature."),
442                         special);
443                 if (swap_rewrite_signature(special, pagesize) < 0)
444                         goto err;
445         }
446
447         free(hdr);
448         close(fd);
449         return 0;
450 err:
451         if (fd != -1)
452                 close(fd);
453         free(hdr);
454         return -1;
455 }
456
457 static int
458 do_swapon(const char *orig_special, int prio, int canonic) {
459         int status;
460         const char *special = orig_special;
461         int flags = 0;
462
463         if (verbose)
464                 printf(_("%s on %s\n"), progname, orig_special);
465
466         if (!canonic) {
467                 special = fsprobe_get_devname_by_spec(orig_special);
468                 if (!special)
469                         return cannot_find(orig_special);
470         }
471
472         if (swapon_checks(special))
473                 return -1;
474
475 #ifdef SWAP_FLAG_PREFER
476         if (prio >= 0) {
477                 if (prio > SWAP_FLAG_PRIO_MASK)
478                         prio = SWAP_FLAG_PRIO_MASK;
479                 flags = SWAP_FLAG_PREFER
480                         | ((prio & SWAP_FLAG_PRIO_MASK)
481                            << SWAP_FLAG_PRIO_SHIFT);
482         }
483 #endif
484         status = swapon(special, flags);
485         if (status < 0)
486                 warn(_("%s: swapon failed"), orig_special);
487
488         return status;
489 }
490
491 static int
492 cannot_find(const char *special) {
493         warnx(_("cannot find the device for %s"), special);
494         return -1;
495 }
496
497 static int
498 swapon_by_label(const char *label, int prio) {
499         const char *special = fsprobe_get_devname_by_label(label);
500         return special ? do_swapon(special, prio, CANONIC) : cannot_find(label);
501 }
502
503 static int
504 swapon_by_uuid(const char *uuid, int prio) {
505         const char *special = fsprobe_get_devname_by_uuid(uuid);
506         return special ? do_swapon(special, prio, CANONIC) : cannot_find(uuid);
507 }
508
509 static int
510 do_swapoff(const char *orig_special, int quiet, int canonic) {
511         const char *special = orig_special;
512
513         if (verbose)
514                 printf(_("%s on %s\n"), progname, orig_special);
515
516         if (!canonic) {
517                 special = fsprobe_get_devname_by_spec(orig_special);
518                 if (!special)
519                         return cannot_find(orig_special);
520         }
521
522         if (swapoff(special) == 0)
523                 return 0;       /* success */
524
525         if (errno == EPERM)
526                 errx(EXIT_FAILURE, _("Not superuser."));
527
528         if (!quiet || errno == ENOMEM)
529                 warn(_("%s: swapoff failed"), orig_special);
530
531         return -1;
532 }
533
534 static int
535 swapoff_by_label(const char *label, int quiet) {
536         const char *special = fsprobe_get_devname_by_label(label);
537         return special ? do_swapoff(special, quiet, CANONIC) : cannot_find(label);
538 }
539
540 static int
541 swapoff_by_uuid(const char *uuid, int quiet) {
542         const char *special = fsprobe_get_devname_by_uuid(uuid);
543         return special ? do_swapoff(special, quiet, CANONIC) : cannot_find(uuid);
544 }
545
546 static int
547 swapon_all(void) {
548         FILE *fp;
549         struct mntent *fstab;
550         int status = 0;
551
552         read_proc_swaps();
553
554         fp = setmntent(_PATH_MNTTAB, "r");
555         if (fp == NULL)
556                 err(2, _("%s: open failed"), _PATH_MNTTAB);
557
558         while ((fstab = getmntent(fp)) != NULL) {
559                 const char *special;
560                 int skip = 0;
561                 int pri = priority;
562                 char *opt, *opts;
563
564                 if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
565                         continue;
566
567                 opts = strdup(fstab->mnt_opts);
568
569                 for (opt = strtok(opts, ","); opt != NULL;
570                      opt = strtok(NULL, ",")) {
571                         if (strncmp(opt, "pri=", 4) == 0)
572                                 pri = atoi(opt+4);
573                         if (strcmp(opt, "noauto") == 0)
574                                 skip = 1;
575                 }
576                 free(opts);
577
578                 if (skip)
579                         continue;
580
581                 special = fsprobe_get_devname_by_spec(fstab->mnt_fsname);
582                 if (!special) {
583                         if (!ifexists)
584                                 status |= cannot_find(fstab->mnt_fsname);
585                         continue;
586                 }
587
588                 if (!is_in_proc_swaps(special) &&
589                     (!ifexists || !access(special, R_OK)))
590                         status |= do_swapon(special, pri, CANONIC);
591
592                 free((void *) special);
593         }
594         fclose(fp);
595
596         return status;
597 }
598
599 static const char **llist = NULL;
600 static int llct = 0;
601 static const char **ulist = NULL;
602 static int ulct = 0;
603
604 static void addl(const char *label) {
605         llist = (const char **) realloc(llist, (++llct) * sizeof(char *));
606         if (!llist)
607                 exit(EXIT_FAILURE);
608         llist[llct-1] = label;
609 }
610
611 static void addu(const char *uuid) {
612         ulist = (const char **) realloc(ulist, (++ulct) * sizeof(char *));
613         if (!ulist)
614                 exit(EXIT_FAILURE);
615         ulist[ulct-1] = uuid;
616 }
617
618 static int
619 main_swapon(int argc, char *argv[]) {
620         int status = 0;
621         int c, i;
622
623         while ((c = getopt_long(argc, argv, "ahefp:svVL:U:",
624                                 longswaponopts, NULL)) != -1) {
625                 switch (c) {
626                 case 'a':               /* all */
627                         ++all;
628                         break;
629                 case 'h':               /* help */
630                         swapon_usage(stdout, 0);
631                         break;
632                 case 'p':               /* priority */
633                         priority = atoi(optarg);
634                         break;
635                 case 'L':
636                         addl(optarg);
637                         break;
638                 case 'U':
639                         addu(optarg);
640                         break;
641                 case 'e':               /* ifexists */
642                         ifexists = 1;
643                         break;
644                 case 'f':
645                         fixpgsz = 1;
646                         break;
647                 case 's':               /* status report */
648                         status = display_summary();
649                         exit(status);
650                 case 'v':               /* be chatty */
651                         ++verbose;
652                         break;
653                 case 'V':               /* version */
654                         printf("%s: (%s)\n", progname, PACKAGE_STRING);
655                         exit(0);
656                 case 0:
657                         break;
658                 case '?':
659                 default:
660                         swapon_usage(stderr, 1);
661                 }
662         }
663         argv += optind;
664
665         if (!all && !llct && !ulct && *argv == NULL)
666                 swapon_usage(stderr, 2);
667
668         if (ifexists && (!all || strcmp(progname, "swapon")))
669                 swapon_usage(stderr, 1);
670
671         if (all)
672                 status |= swapon_all();
673
674         for (i = 0; i < llct; i++)
675                 status |= swapon_by_label(llist[i], priority);
676
677         for (i = 0; i < ulct; i++)
678                 status |= swapon_by_uuid(ulist[i], priority);
679
680         while (*argv != NULL)
681                 status |= do_swapon(*argv++, priority, !CANONIC);
682
683         return status;
684 }
685
686 static int
687 main_swapoff(int argc, char *argv[]) {
688         FILE *fp;
689         struct mntent *fstab;
690         int status = 0;
691         int c, i;
692
693         while ((c = getopt_long(argc, argv, "ahvVL:U:",
694                                  longswapoffopts, NULL)) != -1) {
695                 switch (c) {
696                 case 'a':               /* all */
697                         ++all;
698                         break;
699                 case 'h':               /* help */
700                         swapoff_usage(stdout, 0);
701                         break;
702                 case 'v':               /* be chatty */
703                         ++verbose;
704                         break;
705                 case 'V':               /* version */
706                         printf("%s (%s)\n", progname, PACKAGE_STRING);
707                         exit(0);
708                 case 'L':
709                         addl(optarg);
710                         break;
711                 case 'U':
712                         addu(optarg);
713                         break;
714                 case 0:
715                         break;
716                 case '?':
717                 default:
718                         swapoff_usage(stderr, 1);
719                 }
720         }
721         argv += optind;
722
723         if (!all && !llct && !ulct && *argv == NULL)
724                 swapoff_usage(stderr, 2);
725
726         /*
727          * swapoff any explicitly given arguments.
728          * Complain in case the swapoff call fails.
729          */
730         for (i = 0; i < llct; i++)
731                 status |= swapoff_by_label(llist[i], !QUIET);
732
733         for (i = 0; i < ulct; i++)
734                 status |= swapoff_by_uuid(ulist[i], !QUIET);
735
736         while (*argv != NULL)
737                 status |= do_swapoff(*argv++, !QUIET, !CANONIC);
738
739         if (all) {
740                 /*
741                  * In case /proc/swaps exists, unswap stuff listed there.
742                  * We are quiet but report errors in status.
743                  * Errors might mean that /proc/swaps
744                  * exists as ordinary file, not in procfs.
745                  * do_swapoff() exits immediately on EPERM.
746                  */
747                 read_proc_swaps();
748                 for(i=0; i<numSwaps; i++)
749                         status |= do_swapoff(swapFiles[i], QUIET, CANONIC);
750
751                 /*
752                  * Unswap stuff mentioned in /etc/fstab.
753                  * Probably it was unmounted already, so errors are not bad.
754                  * Doing swapoff -a twice should not give error messages.
755                  */
756                 fp = setmntent(_PATH_MNTTAB, "r");
757                 if (fp == NULL)
758                         err(2, _("%s: open failed"), _PATH_MNTTAB);
759
760                 while ((fstab = getmntent(fp)) != NULL) {
761                         const char *special;
762
763                         if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
764                                 continue;
765
766                         special = fsprobe_get_devname_by_spec(fstab->mnt_fsname);
767                         if (!special)
768                                 continue;
769
770                         if (!is_in_proc_swaps(special))
771                                 do_swapoff(special, QUIET, CANONIC);
772                 }
773                 fclose(fp);
774         }
775
776         return status;
777 }
778
779 int
780 main(int argc, char *argv[]) {
781
782         setlocale(LC_ALL, "");
783         bindtextdomain(PACKAGE, LOCALEDIR);
784         textdomain(PACKAGE);
785
786         progname = program_invocation_short_name;
787         if (!progname) {
788                 char *p = strrchr(argv[0], '/');
789                 progname = p ? p+1 : argv[0];
790         }
791
792         if (streq(progname, "swapon"))
793                 return main_swapon(argc, argv);
794         else
795                 return main_swapoff(argc, argv);
796 }