File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / etc / swapon.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:29 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

static char *sccsid = "@(#)swapon.c	4.4 (Berkeley) 10/16/80";
#include <stdio.h>
#include <errno.h>
#include <fstab.h>

#define	VSWAPON	85

extern errno;

main(argc, argv)
	int argc;
	char *argv[];
{
	int stat = 0;

	--argc, argv++;
	if (argc == 0) {
		fprintf(stderr, "usage: swapon name...\n");
		exit(1);
	}
	if (argc == 1 && !strcmp(*argv, "-a")) {
		struct	fstab	*fsp;
		if (setfsent() == 0)
			perror(FSTAB), exit(1);
		while ( (fsp = getfsent()) != 0){
			if (strcmp(fsp->fs_type, FSTAB_SW) != 0)
				continue;
			printf("Adding %s as swap device\n",
			    fsp->fs_spec);
			if (syscall(VSWAPON, fsp->fs_spec) == -1) {
				extern char *sys_errlist[];

				stat = 1;
				if (errno == ENODEV) {
					printf("swap table full\n");
					exit(stat);
				}
				printf("%s: %s\n",
				    sys_errlist[errno], fsp->fs_spec);
			}
		}
		endfsent();
		exit(stat);
	}
	do {
		if (syscall(VSWAPON, *argv++) == -1) {
			stat = 1;
			if (errno == ENODEV) {
				printf("swap table full\n");
				exit(stat);
			}
			perror(argv[-1]);
		}
		argc--;
	} while (argc > 0);
	exit(stat);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.