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