dev_test.c revision 18c2aff776a775d34a4c9893a4c72e0434d68e36
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <thread.h>
#include <synch.h>
#include <errno.h>
#include "vold.h"
#include "../test/voltestdrv.h"
static int test_getfd(dev_t);
static void test_close(char *, dev_t);
static void test_devmap(vol_t *, int, int);
static void test_thread(char *);
test_use, /* d_use */
test_error, /* d_error */
test_getfd, /* d_getfd */
NULL, /* d_poll */
test_devmap, /* d_devmap */
test_close, /* d_close */
NULL, /* d_eject */
NULL, /* d_find */
NULL, /* d_check */
TEST_MTYPE, /* d_mtype */
TEST_CLASS, /* d_dtype */
(ulong_t)0 /* d_flags */
};
/*
* thread stack size
*/
/*
* this local global keeps track of whether or not the vol test driver
* is "old" or "new" (as defined by which flavor of IOCTLs it likes)
*
* (start out assuming we're up to date)
*/
dev_init(void)
{
return (TRUE);
}
struct t_priv {
int t_fd;
};
/*
* this routine is called when volmgt sees a "use test ..." line
* in its config file
*
* the pathname generally passed in is /dev/voltestdrv, which is expected
* to be a directory containing a voltestdrv node and nodes for each "unit"
*/
/*ARGSUSED*/
static bool_t
{
char namebuf[MAXPATHLEN];
int fd;
int nunits;
int i;
int ttid; /* test thread id */
if (in_use) {
return (TRUE);
}
return (FALSE);
}
/* get the nubmer of test units to manage */
#ifdef DEBUG
#endif
/* XXX: ignore results from this? */
} else {
"test: VTIOCUNITS ioctl failed for \"%s\"; %m\n");
return (FALSE);
}
}
#ifdef DEBUG
else {
}
#endif
/* XXX: should we perform a sanity check on nunits? */
for (i = 1; i < nunits; i++) {
/* only happens if path spec'ed in namebuf is bogus */
return (FALSE);
}
/*
*/
"/dev/voltestdrv/%d", i);
/* we only have character devices */
}
}
return (FALSE);
}
#ifdef DEBUG
#endif
return (TRUE);
}
static int
{
}
/*ARGSUSED*/
static bool_t
{
return (TRUE);
}
/*ARGSUSED*/
static void
{
/* do nothing */
}
/*ARGSUSED*/
static void
{
}
static void
test_thread(char *path)
{
extern int vold_running;
extern cond_t running_cv;
extern mutex_t running_mutex;
int fd;
struct vioc_event vie;
int event_ioctl;
#ifdef DEBUG
#endif
(void) mutex_lock(&running_mutex);
while (vold_running == 0) {
}
(void) mutex_unlock(&running_mutex);
return;
}
/*CONSTCOND*/
while (1) {
#ifdef DEBUG
#endif
/* this ioctl blocks until an event happens */
continue;
}
/* no device -> no event */
continue;
}
#ifdef DEBUG
#endif
"test_thread: read-only open of \"%s\" failed; %m\n",
} else {
/* set close-on-exec */
}
}
/* generate an insert event for this device */
#ifdef DEBUG
#endif
}
}