Move common code in media_check() to a new blockio() function.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@724 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-10-30 14:34:39 +00:00
parent 0694ff1acb
commit 09dca9d224

View File

@ -2062,42 +2062,46 @@ ckok:;
#endif #endif
} }
STATIC int blockio(unsigned char command, struct dpb FAR * dpbp)
{
retry:
MediaReqHdr.r_length = sizeof(request);
MediaReqHdr.r_unit = dpbp->dpb_subunit;
MediaReqHdr.r_command = command;
MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb;
MediaReqHdr.r_status = 0;
execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device);
if ((MediaReqHdr.r_status & S_ERROR) || !(MediaReqHdr.r_status & S_DONE))
{
FOREVER
{
switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0))
{
case ABORT:
case FAIL:
return DE_INVLDDRV;
case RETRY:
goto retry;
case CONTINUE:
return SUCCESS;
}
}
}
return SUCCESS;
}
COUNT media_check(REG struct dpb FAR * dpbp) COUNT media_check(REG struct dpb FAR * dpbp)
{ {
int ret;
if (dpbp == NULL) if (dpbp == NULL)
return DE_INVLDDRV; return DE_INVLDDRV;
/* First test if anyone has changed the removable media */ /* First test if anyone has changed the removable media */
FOREVER ret = blockio(C_MEDIACHK, dpbp);
{ if (ret < SUCCESS)
MediaReqHdr.r_length = sizeof(request); return ret;
MediaReqHdr.r_unit = dpbp->dpb_subunit;
MediaReqHdr.r_command = C_MEDIACHK;
MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb;
MediaReqHdr.r_status = 0;
execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device);
if ((MediaReqHdr.r_status & S_ERROR)
|| !(MediaReqHdr.r_status & S_DONE))
{
loop1:
switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0))
{
case ABORT:
case FAIL:
return DE_INVLDDRV;
case RETRY:
continue;
case CONTINUE:
break;
default:
goto loop1;
}
}
break;
}
switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags)
{ {
@ -2116,37 +2120,9 @@ COUNT media_check(REG struct dpb FAR * dpbp)
case M_CHANGED: case M_CHANGED:
default: default:
setinvld(dpbp->dpb_unit); setinvld(dpbp->dpb_unit);
FOREVER ret = blockio(C_BLDBPB, dpbp);
{ if (ret < SUCCESS)
MediaReqHdr.r_length = sizeof(request); return ret;
MediaReqHdr.r_unit = dpbp->dpb_subunit;
MediaReqHdr.r_command = C_BLDBPB;
MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb;
MediaReqHdr.r_status = 0;
execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device);
if ((MediaReqHdr.r_status & S_ERROR)
|| !(MediaReqHdr.r_status & S_DONE))
{
loop2:
switch (block_error
(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0))
{
case ABORT:
case FAIL:
return DE_INVLDDRV;
case RETRY:
continue;
case CONTINUE:
break;
default:
goto loop2;
}
}
break;
}
#ifdef WITHFAT32 #ifdef WITHFAT32
/* extend dpb only for internal or FAT32 devices */ /* extend dpb only for internal or FAT32 devices */
bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp,