/*
 * |-----------------------------------------------------------|
 * | 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: split.c,v 1.5.2.1 92/06/24 13:55:46 marker Exp $ */

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

split(argc, argv)
	int	argc;
	char	**argv;
{
	dev_t	first;
	int	start, end;
	struct	io_arg io_arg;
	struct	dktab *dktab, *old_dktab;

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

	
	if (!strcmp (argv[0], "add")) {
		if (argc != 5) {
			vdisk_usage (DK_SPLIT, VDISK_ADD);
			exit (1);
		}

		suser ();
		start = atoi (argv[3]);
		end = atoi (argv[4]);
		vdisk_ioctl (DIOCADDDKTAB, 3, argv, 1, DK_SPLIT, -1, -1, start, end);
	} else if (!strcmp (argv[0], "delete")) {
		if (argc != 2) {
			vdisk_usage (DK_SPLIT, VDISK_DELETE);
			exit (1);
		}

		suser ();
		vdisk_ioctl (DIOCDELDKTAB, argc, argv, 1, DK_SPLIT, -1, -1, 0, 0);
	} else if (!strcmp (argv[0], "info")) {
		if (argc == 2) {
			vdisk_info (DK_SPLIT, argv[1]);
		} else if (argc == 1) {
			vdisk_info (DK_SPLIT, NULL);
		} else {
			vdisk_usage (DK_SPLIT, VDISK_INFO);
			exit (1);
		}
		exit (0);
	} else {
		vdisk_usage (DK_SPLIT, VDISK_DEFAULT);
		exit (1);
	}
}
