/*
 * |-----------------------------------------------------------|
 * | Copyright (c) 1990 MIPS Computer Systems, Inc.            |
 * | All Rights Reserved                                       |
 * |-----------------------------------------------------------|
 * |          Restricted Rights Legend                         |
 * | Use, duplication, or disclosure by the Government is      |
 * | subject to restrictions as set forth in                   |
 * | subparagraph (c)(1)(ii) of the Rights in Technical        |
 * | Data and Computer Software Clause of DFARS 52.227-7013.   |
 * |         MIPS Computer Systems, Inc.                       |
 * |         950 DeGuigne Drive                                |
 * |         Sunnyvale, CA 94086                               |
 * |-----------------------------------------------------------|
 */
/* $Header: span.c,v 1.6.2.1 92/06/24 13:55:45 marker Exp $ */

#include <sys/types.h>
#include <sys/vdisk.h>
#include <sys/dkio.h>
#include <fcntl.h>
#include <stdio.h>
#include "vdisk.h"

span(argc, argv)
	int argc;
	char **argv;
{
	struct dktab *dktab, *old_dktab;
	struct io_arg io_arg;
	int idx;
	dev_t first;
	int vdisk;
	dev_t before, after;
	int start, skip;

	if (argc == 0) {
		vdisk_usage (DK_SPAN, VDISK_DEFAULT);
		exit (1);
	}

	if (!strcmp (argv[0], "add")) {
		if (argc < 3) {
			vdisk_usage (DK_SPAN, VDISK_ADD);
			exit (1);
		}

		suser ();
		start = 1;
		get_control_args (DK_SPAN, argc, argv, &start, &after, &before, &skip);
		vdisk_ioctl (DIOCADDDKTAB, argc, argv, start, DK_SPAN, after, before, 0, 0);
	} else if (!strcmp (argv[0], "delete")) {
		if (argc < 3) {
			vdisk_usage (DK_SPAN, VDISK_DELETE);
			exit (1);
		}
		suser ();
		vdisk_ioctl (DIOCDELDKTAB, argc, argv, 1, DK_SPAN, -1, -1, 0, 0);
	} else if (!strcmp (argv[0], "info")) {
		if (argc == 2) {
			vdisk_info (DK_SPAN, argv[1]);
		} else if (argc == 1) {
			vdisk_info (DK_SPAN, NULL);
		} else {
			vdisk_usage (DK_SPAN, VDISK_INFO);
		}
		exit (0);
	} else {
		vdisk_usage (DK_SPAN, VDISK_DEFAULT);
		exit (1);
	}

}
