/*
 *   Copyright (c) 1996 David Parsons. All rights reserved.
 *   
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *  3. All advertising materials mentioning features or use of this
 *     software must display the following acknowledgement:
 *     
 *   This product includes software developed by David Parsons
 *   (orc@pell.chi.il.us)
 *
 *  4. My name may not be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *     
 *  THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
 *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 *  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
 *  PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 *  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 *  THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _MEDIA_D
#define _MEDIA_D

#include "util.h"

/*
 * media descriptor table: this gives all the ways we can mount installation
 * sets on the machine, indexed by mediatype (see above)
 */
enum mediatypes { M_VOID=0, M_ZIP, M_NFS, M_CDROM, M_DOS, M_FLOP };

struct media {
    enum mediatypes m_type;	/* what this media is */
    char *m_name;		/* what this media is called by humans */
    char *m_dev;		/* what device it's attached to */
    char *m_fstype;		/* what filesystem we expect to find */
    char *m_opts;		/* mount options */
    int (*mount)(__const char*, __const char*,		/* mount function */
		 __const char*, unsigned long,
		 __const void*);
    int (*umount)(__const char*);			/* unmount function */
    int (*eject)(int);					/* eject the media */
    int (*load)(int);					/* reload the media */
};

extern void *getmedia(enum mediatypes mtype);
extern int open_media(void *);
extern void close_media(void *);
extern void eject_media(void *);
extern char *mediadesc(struct idiskinfo *);

#define MEDIATYPE(x)	((struct media*)x)->m_type
#define	MEDIANAME(x)	((struct media*)x)->m_name
#define MEDIA(x)	((struct media*)x)->m_dev
#define MEDIAFS(x)	((struct media*)x)->m_fstype
#define MEDIAOPTS(x)	((struct media*)x)->m_opts
#define MOUNT(x)	(*(((struct media*)x)->mount))
#define UMOUNT(x)	(*(((struct media*)x)->umount))
#define	EJECT(x)	(*(((struct media*)x)->eject))
#define	LOAD(x)		(*(((struct media*)x)->load))

#endif/*_MEDIA_D*/
