home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / e2fltsrc.zip / e2filt.c < prev    next >
C/C++ Source or Header  |  1995-07-25  |  3KB  |  66 lines

  1. /************************************************************************/
  2. /*  Linux partition filter (C) Deon van der Westhuysen.                 */
  3. /*                                                                      */
  4. /*  Dedicated to Jesus Christ, my Lord and Saviour.                     */
  5. /*                                                                      */
  6. /*  Permission is granted to freely use and modify this code for non-   */
  7. /*  profit use on the condition that this notice is not removed. All    */
  8. /*  other rights are reserved. No warranty, etc.                        */
  9. /*                                                                      */
  10. /*  This code is still under development; expect some rough edges.      */
  11. /*                                                                      */
  12. /************************************************************************/
  13.  
  14. #include "debug.h"
  15. #include "e2data.h"
  16. #include "e2router.h"
  17. #include "e2filt.h"
  18. #include "e2wrap.h"
  19.  
  20. /* Any IORBs for the base units arrive here, including requests generated */
  21. /* by accesses to the data in the virtual partitions. */
  22. void FilterHandler (PIORB pIORB)
  23. {
  24.  NPBaseUnitRec    pUnitRec;            /* Ptr to unit record */
  25.  
  26.  pUnitRec= (NPBaseUnitRec) pIORB->UnitHandle;    /* Get ptr to unit record */
  27.                         /* from the unit handle */
  28.  pUnitRec->SaveReqCtrl= pIORB->RequestControl;    /* Save request flags */
  29.  pUnitRec->SaveNotify= pIORB->NotifyAddress;    /* Save notify address */
  30.  pUnitRec->SaveReserved= pIORB->Reserved_1;    /* Save reserved field */
  31.  pIORB->Reserved_1= pIORB->UnitHandle;        /* Save unit handle */
  32.  
  33.  pIORB->UnitHandle= pUnitRec->UnitHandle;    /* Restore old unit handle */
  34.  pIORB->NotifyAddress= &FilterNotifyWrapper;    /* Install our routine */
  35.  pIORB->RequestControl|= IORB_ASYNC_POST;    /* Request notification */
  36.  pIORB->RequestControl&= ~IORB_CHAIN;        /* No IORBs to chain */
  37.  
  38.  /* Check for commands that we might wish to change. None yet. */
  39.  /* except allocation- but that was allready done in the router */
  40.  
  41.  /* If we are still here then the command was not intercepted... */
  42.  pUnitRec->pADDEntry(pIORB);    /* Ask the original driver to do the request */
  43. }
  44.  
  45. /* This routine is called by the original device driver as soon as the */
  46. /* filtered request is done. Here the fields we modified in the IORB are */
  47. /* restored before we pass it back to the original caller. */
  48. void FilterNotify (PIORB pIORB)
  49. {
  50.  NPBaseUnitRec    pUnitRec;            /* Ptr to unit record */
  51.  NPIORBQueue    pQueue;                /* Queue request came from */
  52.  
  53.  pUnitRec= (NPBaseUnitRec) pIORB->Reserved_1;    /* Get ptr to unit record */
  54.  
  55.  pIORB->UnitHandle= (USHORT) pUnitRec;        /* Restore old unit handle */
  56.  pIORB->RequestControl= pUnitRec->SaveReqCtrl;    /* Restore rest of IORB */
  57.  pIORB->Reserved_1= pUnitRec->SaveReserved;
  58.  pIORB->NotifyAddress= pUnitRec->SaveNotify;
  59.  
  60.  pQueue= &(pUnitRec->Hdr.IORBQueue);        /* Get ptr to IORB queue */
  61.  
  62.  pQueue->Flags&=~F_REQUEST_BUSY;        /* Indicate queue finished */
  63.  NotifyDone (pIORB);                /* Notify caller */
  64.  StartIORBQueue (pQueue);            /* Try to restart queue */
  65. }
  66.