|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <fstab.h> ! 3: ! 4: main(argc, argv) ! 5: int argc; ! 6: char *argv[]; ! 7: { ! 8: int stat = 0; ! 9: ! 10: --argc, argv++; ! 11: if (argc == 0) { ! 12: fprintf(stderr, "usage: swapon name...\n"); ! 13: exit(1); ! 14: } ! 15: if (argc == 1 && !strcmp(*argv, "-a")) { ! 16: struct fstab *fsp; ! 17: if (setfsent() == 0) ! 18: perror(FSTAB), exit(1); ! 19: while ((fsp = getfsent()) != 0){ ! 20: if (fsp->fs_ftype != FSSWAP) ! 21: continue; ! 22: printf("Adding %s as swap device\n", ! 23: fsp->fs_spec); ! 24: fflush(stdout); ! 25: if (swapon(fsp->fs_spec) < 0) { ! 26: stat = 1; ! 27: perror(fsp->fs_spec); ! 28: } ! 29: } ! 30: endfsent(); ! 31: exit(stat); ! 32: } ! 33: do { ! 34: if (swapon(*argv) < 0) { ! 35: stat = 1; ! 36: perror(*argv); ! 37: } ! 38: argc--; ! 39: argv++; ! 40: } while (argc > 0); ! 41: exit(stat); ! 42: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.