From c41380e5784c6be7076d0b161bb29ba0faf98ee1 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 6 Mar 2005 16:58:33 +0000 Subject: [PATCH] merge from dev kernel, Jason Hood's patch for extended DPBs and Set Extended Error function git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1120 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 17 +++++++++++------ kernel/inthndlr.c | 25 +++++++++++++++++++++++++ kernel/proto.h | 1 + 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 59608bd..1012bae 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1978,6 +1978,16 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) #endif #ifdef WITHFAT32 +VOID dpb16to32(struct dpb FAR *dpbp) +{ + dpbp->dpb_xflags = 0; + dpbp->dpb_xfsinfosec = 0xffff; + dpbp->dpb_xbackupsec = 0xffff; + dpbp->dpb_xrootclst = 0; + dpbp->dpb_xdata = dpbp->dpb_data; + dpbp->dpb_xsize = dpbp->dpb_size; +} + VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended) #else VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) @@ -2037,12 +2047,7 @@ ckok:; dpbp->dpb_xcluster = UNKNCLUSTER; dpbp->dpb_xnfreeclst = XUNKNCLSTFREE; /* number of free clusters */ - dpbp->dpb_xflags = 0; - dpbp->dpb_xfsinfosec = 0xffff; - dpbp->dpb_xbackupsec = 0xffff; - dpbp->dpb_xrootclst = 0; - dpbp->dpb_xdata = dpbp->dpb_data; - dpbp->dpb_xsize = dpbp->dpb_size; + dpb16to32(dpbp); if (ISFAT32(dpbp)) { diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 456ed5d..7448c84 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -200,6 +200,17 @@ int int21_fat32(lregs *r) fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); xddp->xdd_dpbsize = sizeof(struct dpb); + + /* if it doesn't look like an extended DPB, fill in those fields */ + if (!ISFAT32(dpb) && dpb->dpb_xsize != dpb->dpb_size) + { + xddp->xdd_dpb.dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_hi = + (dpb->dpb_nfreeclst == 0xFFFF ? 0xFFFF : 0); + dpb16to32(&xddp->xdd_dpb); + xddp->xdd_dpb.dpb_xfatsize = dpb->dpb_fatsize; + xddp->xdd_dpb.dpb_xcluster = (dpb->dpb_cluster == 0xFFFF ? + 0xFFFFFFFFuL : dpb->dpb_cluster); + } break; } /* Get extended free drive space */ @@ -1215,6 +1226,20 @@ dispatch: goto error_exit; break; + /* Set Extended Error */ + case 0x0a: + { + lregs er; + fmemcpy(&er, FP_DS_DX, sizeof(er)); + CritErrCode = er.AX; + CritErrDev = MK_FP(er.ES, er.DI); + CritErrLocus = er.CH; + CritErrClass = er.BH; + CritErrAction = er.BL; + CLEAR_CARRY_FLAG(); + break; + } + default: CritErrCode = SUCCESS; goto error_invalid; diff --git a/kernel/proto.h b/kernel/proto.h index b13700c..f966d29 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -173,6 +173,7 @@ COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); CLUSTER dos_free(struct dpb FAR * dpbp); BOOL dir_exists(char * path); +VOID dpb16to32(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s);