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