예제 #1
0
파일: scuzz.c 프로젝트: 99years/plan9
static long
cmdopen(ScsiReq *rp, int argc, char *argv[])
{
	int raw;
	long status;

	raw = 0;
	if(argc && strcmp("-r", argv[0]) == 0){
		raw = 1;
		argc--, argv++;
	}
	if(argc != 1){
		rp->status = Status_BADARG;
		return -1;
	}
	if(raw == 0){
		if((status = SRopen(rp, argv[0])) != -1 && verbose)
			Bprint(&bout, "%sblock size: %ld\n",
				rp->flags&Fbfixed? "fixed ": "", rp->lbsize);
	}
	else {
		status = SRopenraw(rp, argv[0]);
		rp->lbsize = 512;
	}
	return status;
}
예제 #2
0
파일: scsireq.c 프로젝트: npe9/harvey
int
SRopen(ScsiReq *rp, char *unit)
{
	if(SRopenraw(rp, unit) == -1)
		return -1;
	SRready(rp);
	if(SRinquiry(rp) >= 0){
		switch(rp->inquiry[0]){

		default:
			fprint(2, "unknown device type 0x%.2x\n", rp->inquiry[0]);
			rp->status = Status_SW;
			break;

		case Devdir:
		case Devcd:
		case Devmo:
			if(dirdevopen(rp) == -1)
				break;
			return 0;

		case Devseq:
			rp->flags |= Fseqdev;
			if(seqdevopen(rp) == -1)
				break;
			return 0;

		case Devprint:
			rp->flags |= Fprintdev;
			return 0;

		case Devworm:
			rp->flags |= Fwormdev;
			if(wormdevopen(rp) == -1)
				break;
			return 0;

		case Devjuke:
			rp->flags |= Fchanger;
			return 0;
		}
	}
	SRclose(rp);
	return -1;
}
예제 #3
0
파일: scuzz.c 프로젝트: 99years/plan9
static long
cmdprobe(ScsiReq *rp, int argc, char *argv[])
{
	char buf[32];
	ScsiReq scsireq;
	char *ctlr, *unit;

	USED(argc, argv);
	rp->status = STok;
	scsireq.flags = 0;

	for(ctlr="CDEFGHIJ0123456789abcdef"; *ctlr; ctlr++) {
		/*
		 * I can guess how many units you have.
		 * SATA controllers can have more than two drives each.
		 */
		if(*ctlr >= 'C' && *ctlr <= 'D')
			unit = "01";
		else if((*ctlr >= '0' && *ctlr <= '9')
		     || (*ctlr >= 'a' && *ctlr <= 'f'))
			unit = "0123456789abcdef";	/* allow wide scsi */
		else
			unit = "01234567";

		for(; *unit; unit++){
			sprint(buf, "/dev/sd%c%c", *ctlr, *unit);
			if(SRopenraw(&scsireq, buf) == -1)
				continue;
			SRreqsense(&scsireq);
			switch(scsireq.status){
			case STok:
			case Status_SD:
				Bprint(&bout, "%s: ", buf);
				cmdinquiry(&scsireq, 0, 0);
				break;
			}
			SRclose(&scsireq);
		}
	}
	return 0;
}