~kris/9p

9hist

8326d934d357f96eed694d59e47200e09462d2bb — David du Colombier 31 years ago 9350f1d
Plan 9 from Bell Labs 1995-04-16
1 files changed, 32 insertions(+), 18 deletions(-)

M port/devsd.c
M port/devsd.c => port/devsd.c +32 -18
@@ 184,11 184,36 @@ sdinit(void)
Chan*
sdattach(char *spec)
{
	int i;
	int i, nfound;
	Disk *d;

	for(i = 0; i < ndisk; i++)
		sdrdpart(&disk[i]);
	
	/*
	 * If the drive wasn't ready when we tried to do a
	 * read-capacity earlier (in sdinit()), try again.
	 * It might be possible to be smarter here, and look at the
	 * response from a test-unit-ready which would show if the
	 * target was in the process of becoming ready.
	 */
	nfound = 0;
	for(i = 0; i < ndisk; i++){	
		d = &disk[i];
		if(waserror()){
			poperror();
			continue;
		}
		if(d->size == 0 || d->bsize == 0){
			if(scsicap(d->t, d->lun, &d->size, &d->bsize) != STok){
				d->size = d->bsize = 0;
				continue;
			}
		}
		sdrdpart(d);
		nfound++;
		poperror();
	}

	if(nfound == 0)
		return 0;
	return devattach('w', spec);
}



@@ 284,20 309,6 @@ sdrdpart(Disk *d)
	char *b, *line[Npart+2], *field[3];
	static char MAGIC[] = "plan9 partitions";

	/*
	 * If the drive wasn't ready when we tried to do a
	 * read-capacity earlier (in sdinit()), try again.
	 * It might be possible to be smarter here, and look at the
	 * response from a test-unit-ready which would show if the
	 * target was in the process of becoming ready.
	 */
	if(d->size == 0 || d->bsize == 0){
		if(scsicap(d->t, d->lun, &d->size, &d->bsize) != STok){
			d->size = d->bsize = 0;
			error(Eio);
		}
	}

	b = scsialloc(d->bsize);
	if(b == 0)
		error(Enomem);


@@ 363,6 374,9 @@ sdio(Chan *c, int write, char *a, ulong len, ulong offset)
	d = &disk[DRIVE(c->qid)];
	p = &d->table[PART(c->qid)];

	if(d->bsize == 0)
		error(Eio);

	if(write && (d->inquire[0] & 0x1F) == TypeCD)
		error(Eperm);