1*1445Sbill static char *sccsid = "@(#)swapon.c 4.4 (Berkeley) 10/16/80"; 21113Sbill #include <stdio.h> 31417Sbill #include <fstab.h> 41113Sbill 51113Sbill #define VSWAPON 85 61113Sbill 71113Sbill main(argc, argv) 81113Sbill int argc; 91113Sbill char *argv[]; 101113Sbill { 111113Sbill int stat = 0; 121113Sbill 131113Sbill --argc, argv++; 141113Sbill if (argc == 0) { 151113Sbill fprintf(stderr, "usage: swapon name...\n"); 161113Sbill exit(1); 171113Sbill } 181417Sbill if (argc == 1 && !strcmp(*argv, "-a")) { 191444Sbill struct fstab *fsp; 201444Sbill if (setfsent() == 0) 211444Sbill perror(FSTAB), exit(1); 221444Sbill while ( (fsp = getfsent()) != 0){ 231444Sbill if (strcmp(fsp->fs_type, FSTAB_SW) != 0) 241417Sbill continue; 25*1445Sbill printf("Adding %s as swap device\n", 261444Sbill fsp->fs_spec); 271444Sbill if (syscall(VSWAPON, fsp->fs_spec) == -1) { 28*1445Sbill extern errno; 29*1445Sbill extern char *sys_errlist[]; 30*1445Sbill printf("%s: %s\n", 31*1445Sbill sys_errlist[errno]); 321417Sbill stat = 1; 331417Sbill } 341417Sbill } 351444Sbill endfsent(); 361417Sbill exit(stat); 371417Sbill } 381113Sbill do { 391113Sbill if (syscall(VSWAPON, *argv++) == -1) { 401113Sbill stat = 1; 411113Sbill perror(argv[-1]); 421113Sbill } 431113Sbill argc--; 441113Sbill } while (argc > 0); 451113Sbill exit(stat); 461113Sbill } 47