示例#1
0
static int open_scsi_device (int unitnum)
{
    int result = 0;

    DEBUG_LOG ("SCSIDEV: unit=%d: open_scsi_device\n", unitnum);

    if (unitnum < total_drives) {
	struct scsidevdata *sdd = &drives[unitnum];

	if (!sdd->scgp) {
	    if ((sdd->scgp = openscsi (sdd->bus, sdd->target, sdd->lun)) != 0)
		result = 1;
	} else
	    /* already open */
	    result = 1;
    }
    return result;
}
示例#2
0
void
threadmain(int argc, char **argv)
{
	Scsi *s;
	Drive *d;
	char buf[80];

	ARGBEGIN{
	case 'v':
		debug++;
		scsiverbose++;
	}ARGEND

	if(argc != 1)
		usage();

	fmtinstall('M', msfconv);

	if((s = openscsi(argv[0])) == nil)
		error("opening scsi: %r");

	d = malloc(sizeof(*d));
	if(d == nil)
		error("out of memory");
	memset(d, 0, sizeof d);

	d->scsi = s;
	d->w = newwindow();
	d->ctocdisp = chancreate(sizeof(Toc), 0);
	d->cdbreq = chancreate(sizeof(Toc), 0);
	d->cdbreply = chancreate(sizeof(Toc), 0);
	d->cstatus = chancreate(sizeof(Cdstatus), 0);

	proccreate(wineventproc, d->w, STACK);
	proccreate(cddbproc, d, STACK);
	proccreate(cdstatusproc, d, STACK);

	cleanname(argv[0]);
	snprint(buf, sizeof(buf), "%s/", argv[0]);
	winname(d->w, buf);

	wintagwrite(d->w, "Stop Pause Resume Eject Ingest ", 5+6+7+6+7);
	eventwatcher(d);
}