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:
parent
0694ff1acb
commit
09dca9d224
@ -2062,42 +2062,46 @@ ckok:;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
COUNT media_check(REG struct dpb FAR * dpbp)
|
STATIC int blockio(unsigned char command, struct dpb FAR * dpbp)
|
||||||
{
|
{
|
||||||
if (dpbp == NULL)
|
retry:
|
||||||
return DE_INVLDDRV;
|
MediaReqHdr.r_length = sizeof(request);
|
||||||
|
MediaReqHdr.r_unit = dpbp->dpb_subunit;
|
||||||
/* First test if anyone has changed the removable media */
|
MediaReqHdr.r_command = command;
|
||||||
FOREVER
|
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))
|
||||||
{
|
{
|
||||||
MediaReqHdr.r_length = sizeof(request);
|
FOREVER
|
||||||
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))
|
switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0))
|
||||||
{
|
{
|
||||||
case ABORT:
|
case ABORT:
|
||||||
case FAIL:
|
case FAIL:
|
||||||
return DE_INVLDDRV;
|
return DE_INVLDDRV;
|
||||||
|
|
||||||
case RETRY:
|
case RETRY:
|
||||||
continue;
|
goto retry;
|
||||||
|
|
||||||
case CONTINUE:
|
case CONTINUE:
|
||||||
break;
|
return SUCCESS;
|
||||||
|
|
||||||
default:
|
|
||||||
goto loop1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
COUNT media_check(REG struct dpb FAR * dpbp)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
if (dpbp == NULL)
|
||||||
|
return DE_INVLDDRV;
|
||||||
|
|
||||||
|
/* First test if anyone has changed the removable media */
|
||||||
|
ret = blockio(C_MEDIACHK, dpbp);
|
||||||
|
if (ret < SUCCESS)
|
||||||
|
return ret;
|
||||||
|
|
||||||
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,
|
||||||
|
Loading…
Reference in New Issue
Block a user