In case of "not sure" if the removable media has changed, the

IBM PCDOS technical reference says to call BLDBPB if there are no used
buffers, so we only do it then, instead of flushing the buffers.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1458 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-06-26 20:12:33 +00:00
parent e597bb20d4
commit 924f6d1bfd
3 changed files with 23 additions and 2 deletions

View File

@ -259,6 +259,24 @@ VOID setinvld(REG COUNT dsk)
while (FP_OFF(bp) != FP_OFF(firstbuf));
}
/* Check if there is at least one dirty buffer */
/* */
BOOL dirty_buffers(REG COUNT dsk)
{
struct buffer FAR *bp = firstbuf;
do
{
if (bp->b_unit == dsk &&
(bp->b_flag & (BFR_VALID | BFR_DIRTY)) == (BFR_VALID | BFR_DIRTY))
return TRUE;
bp = b_next(bp);
}
while (FP_OFF(bp) != FP_OFF(firstbuf));
return FALSE;
}
/* */
/* */
/* Flush all buffers for a disk */
/* */

View File

@ -1687,8 +1687,10 @@ COUNT media_check(REG struct dpb FAR * dpbp)
/* If it is forced or the media may have changed, */
/* rebuild the bpb */
case M_DONT_KNOW:
/* hazard: no error checking! */
flush_buffers(dpbp->dpb_unit);
/* IBM PCDOS technical reference says to call BLDBPB if */
/* there are no used buffers */
if (dirty_buffers(dpbp->dpb_unit))
return SUCCESS;
/* If it definitely changed, don't know (falls through) */
/* or has been changed, rebuild the bpb. */

View File

@ -38,6 +38,7 @@ struct buffer FAR *getblk(ULONG blkno, COUNT dsk, BOOL overwrite);
#define getblock(blkno, dsk) getblk(blkno, dsk, FALSE);
#define getblockOver(blkno, dsk) getblk(blkno, dsk, TRUE);
VOID setinvld(REG COUNT dsk);
BOOL dirty_buffers(REG COUNT dsk);
BOOL flush_buffers(REG COUNT dsk);
BOOL flush(void);
BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk);