Ejemplo n.º 1
0
int getPartErrorName(u32 device, char *name)
{
	int lba;
	int rv=0;
	apa_cache *clink;

	if((rv=getPartErrorSector(device, APA_SECTOR_PART_ERROR, &lba)) <= 0)
		return rv;
	if(!(clink=cacheGetHeader(device, 0, THEADER_MODE_READ, &rv)))
		return rv;

	while(clink)
	{
		if(clink->header->type!=APA_TYPE_FREE && 
			!(clink->header->flags & CACHE_FLAG_DIRTY) && 
			clink->header->start==lba) {
				if(name) {
					strncpy(name, clink->header->id, APA_IDMAX - 1);
					name[APA_IDMAX - 1] = '\0';
				}
				cacheAdd(clink);
				return 1;
		}
		clink=apaGetNextHeader(clink, &rv);
	}

	// clear error if no errors and partitions was not found...
	if(rv==0)
		setPartErrorSector(device, 0);
	return rv;
}
Ejemplo n.º 2
0
int hddIoctl2(iop_file_t *f, int req, void *argp, unsigned int arglen,
			  void *bufp, unsigned int buflen)
{
	u32 rv=0;
	hdd_file_slot_t *fileSlot=f->privdata;

	WaitSema(fioSema);
	switch(req)
	{
	// cmd set 1
	case APA_IOCTL2_ADD_SUB:
		rv=ioctl2AddSub(fileSlot, (char *)argp);
		break;

	case APA_IOCTL2_DELETE_LAST_SUB:
		rv=ioctl2DeleteLastSub(fileSlot);
		break;

	case APA_IOCTL2_NUMBER_OF_SUBS:
		rv=fileSlot->nsub;
		break;

	case APA_IOCTL2_FLUSH_CACHE:
		atadFlushCache(f->unit);
		break;

	// cmd set 2
	case APA_IOCTL2_TRANSFER_DATA:
		rv=ioctl2Transfer(f->unit, fileSlot, argp);
		break;

	case APA_IOCTL2_GETSIZE:
		//	rv=fileSlot->subs[*(u32 *)argp].length;
		rv=((apa_subs *)(&fileSlot->start))[*(u32 *)argp].length;	// !HACK!
		break;

	case APA_IOCTL2_GETHEADER:
		if(atadDmaTransfer(f->unit, bufp, fileSlot->start, sizeof(apa_header)/512, ATAD_MODE_READ))
			rv=-EIO;
		rv=sizeof(apa_header);
		break;

	case APA_IOCTL2_SET_PART_ERROR:
		setPartErrorSector(f->unit, fileSlot->start); rv=0;
		break;

	case APA_IOCTL2_GET_PART_ERROR:
		if((rv=getPartErrorSector(f->unit, APA_SECTOR_PART_ERROR, bufp)) > 0) {
			if(*(u32 *)bufp==fileSlot->start) {
				rv=0; setPartErrorSector(f->unit, 0);// clear last error :)
			}
		}
		break;

	default:
		rv=-EINVAL;
		break;
	}
	SignalSema(fioSema);
	return rv;
}