From e597bb20d49494703e52d3bd20f55f65865d1dca Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Jun 2009 20:00:41 +0000 Subject: [PATCH] Merged int21/ax=7304, subfunctions 3 and 4, which work very similarly. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1457 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/xstructs.h | 17 ++++++------- kernel/inthndlr.c | 64 ++++++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/hdr/xstructs.h b/hdr/xstructs.h index 42d2ab7..c5584bc 100644 --- a/hdr/xstructs.h +++ b/hdr/xstructs.h @@ -64,20 +64,19 @@ struct xdpbforformat { } rebuilddpb; struct { - DWORD newmirroring; /* new active FAT/mirroring state, or -1 to get + DWORD new; /* new active FAT/mirroring state, or -1 to get bits 3-0: the 0-based FAT number of the active FAT bits 6-4: reserved (0) bit 7: do not mirror active FAT to inactive FATs + or: + set new root directory cluster, -1 - get current + */ + DWORD old; /* previous active FAT/mirroring state (as above) + or + get previous root directory cluster */ - DWORD oldmirroring; /* previous active FAT/mirroring state (as above) */ UDWORD reserved[2]; - } setmirroring; - - struct { - DWORD newrootclst; /* set new root directory cluster, -1 - get current */ - DWORD oldrootclst; /* get previous root directory cluster */ - UDWORD reserved[2]; - } setroot; + } setget; } xdff_f; }; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 7266522..56a202d 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -293,53 +293,43 @@ int int21_fat32(lregs *r) break; } case 0x03: - { - struct buffer FAR *bp; - bpb FAR *bpbp; - DWORD newmirroring = - xdffp->xdff_f.setmirroring.newmirroring; - - if (newmirroring != -1 - && (ISFAT32(dpb) - && (newmirroring & ~(0xf | 0x80)))) - { - return DE_INVLDPARM; - } - xdffp->xdff_f.setmirroring.oldmirroring = - (ISFAT32(dpb) ? dpb->dpb_xflags : 0); - if (newmirroring != -1 && ISFAT32(dpb)) - { - bp = getblock(1, dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); - bp->b_flag |= BFR_VALID | BFR_DIRTY; - bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; - bpbp->bpb_xflags = (UWORD)newmirroring; - } - goto rebuild_dpb; - } case 0x04: { - struct buffer FAR *bp; - bpb FAR *bpbp; - DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; - if (!ISFAT32(dpb) - || (rootclst != -1 - && (rootclst == 1 - || (ULONG)rootclst > dpb->dpb_xsize))) - { + ULONG value; + if (!ISFAT32(dpb)) return DE_INVLDPARM; - } - xdffp->xdff_f.setroot.oldrootclst = dpb->dpb_xrootclst; - if (rootclst != -1) + + value = xdffp->xdff_f.setget.new; + if ((UWORD) xdffp->xdff_function == 0x03) { - bp = getblock(1, dpb->dpb_unit); + /* FAT mirroring */ + if (value != 0xFFFFFFFF && (value & ~(0xf | 0x80))) + return DE_INVLDPARM; + xdffp->xdff_f.setget.old = dpb->dpb_xflags; + } + else + { + /* root cluster */ + if (value != 0xFFFFFFFF && (value < 2 || value > dpb->dpb_xsize)) + return DE_INVLDPARM; + xdffp->xdff_f.setget.old = dpb->dpb_xrootclst; + } + if (value != 0xFFFFFFFF) + { + bpb FAR *bpbp; + struct buffer FAR *bp = getblock(1, dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); bp->b_flag |= BFR_VALID | BFR_DIRTY; bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; - bpbp->bpb_xrootclst = rootclst; + if ((UWORD) xdffp->xdff_function == 0x03) + bpbp->bpb_xflags = (UWORD)value; + else + bpbp->bpb_xrootclst = value; } goto rebuild_dpb; } + default: + return DE_INVLDFUNC; } break;