FX_MA.C
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:9k
源码类别:

DVD

开发平台:

Others

  1. /**************************************************************************/ 
  2. /*                                                                        */ 
  3. /*            Copyright (c) 1996-2002 by Express Logic Inc.               */ 
  4. /*                                                                        */ 
  5. /*  This software is copyrighted by and is the sole property of Express   */ 
  6. /*  Logic, Inc.  All rights, title, ownership, or other interests         */ 
  7. /*  in the software remain the property of Express Logic, Inc.  This      */ 
  8. /*  software may only be used in accordance with the corresponding        */ 
  9. /*  license agreement.  Any unauthorized use, duplication, transmission,  */ 
  10. /*  distribution, or disclosure of this software is expressly forbidden.  */ 
  11. /*                                                                        */
  12. /*  This Copyright notice may not be removed or modified without prior    */ 
  13. /*  written consent of Express Logic, Inc.                                */ 
  14. /*                                                                        */ 
  15. /*  Express Logic, Inc. reserves the right to modify this software        */ 
  16. /*  without notice.                                                       */ 
  17. /*                                                                        */ 
  18. /*  Express Logic, Inc.                     info@expresslogic.com         */
  19. /*  11423 West Bernardo Court               http://www.expresslogic.com   */
  20. /*  San Diego, CA  92127                                                  */
  21. /*                                                                        */
  22. /**************************************************************************/
  23. /**************************************************************************/
  24. /**************************************************************************/
  25. /**                                                                       */ 
  26. /** FileX Component                                                       */ 
  27. /**                                                                       */
  28. /**   Media (MED)                                                         */
  29. /**                                                                       */
  30. /**************************************************************************/
  31. /**************************************************************************/
  32. #include "Config.h" // Global Configuration - do not remove!
  33. #ifdef ENABLE_FILEX
  34. #ifdef _DEBUG
  35. #undef IFTRACE
  36. #define IFTRACE if (gTraceFileSys)
  37. #include "DebugDbgMain.h"
  38. #endif //_DEBUG
  39. #define FX_SOURCE_CODE
  40. /* Include necessary system files.  */
  41. #include "PlaycoreFileSysFileXfx_api.h"
  42. #include "PlaycoreFileSysFileXfx_sys.h"
  43. #include "PlaycoreFileSysFileXfx_med.h"
  44. #include "PlaycoreFileSysFileXfx_fil.h"
  45. #include "PlaycoreFileSysFileXfx_uti.h"
  46. /**************************************************************************/ 
  47. /*                                                                        */ 
  48. /*  FUNCTION                                               RELEASE        */ 
  49. /*                                                                        */ 
  50. /*    _fx_media_abort                                     PORTABLE C      */ 
  51. /*                                                           3.0          */ 
  52. /*  AUTHOR                                                                */ 
  53. /*                                                                        */ 
  54. /*    William E. Lamie, Express Logic, Inc.                               */ 
  55. /*                                                                        */ 
  56. /*  DESCRIPTION                                                           */ 
  57. /*                                                                        */ 
  58. /*    This function marks all open files for the specified media as       */ 
  59. /*    aborted and then removes the media control block from the open      */ 
  60. /*    media list and marks it as aborted as well.                         */ 
  61. /*                                                                        */ 
  62. /*  INPUT                                                                 */ 
  63. /*                                                                        */ 
  64. /*    media_ptr                             Media control block pointer   */ 
  65. /*                                                                        */ 
  66. /*  OUTPUT                                                                */ 
  67. /*                                                                        */ 
  68. /*    return status                                                       */ 
  69. /*                                                                        */ 
  70. /*  CALLS                                                                 */ 
  71. /*                                                                        */ 
  72. /*    None                                                                */ 
  73. /*                                                                        */ 
  74. /*  CALLED BY                                                             */ 
  75. /*                                                                        */ 
  76. /*    Application Code                                                    */ 
  77. /*                                                                        */ 
  78. /*  RELEASE HISTORY                                                       */ 
  79. /*                                                                        */ 
  80. /*    DATE              NAME                      DESCRIPTION             */ 
  81. /*                                                                        */ 
  82. /*  01-01-1999     William E. Lamie         Initial Version 1.0           */ 
  83. /*  03-01-2000     William E. Lamie         Modified comment(s),          */ 
  84. /*                                            resulting in version 1.0b.  */ 
  85. /*  01-28-2001     William E. Lamie         Modified comment(s),          */ 
  86. /*                                            resulting in version 2.0.   */ 
  87. /*  03-01-2002     William E. Lamie         Modified comment(s),          */ 
  88. /*                                            resulting in version 3.0.   */ 
  89. /*                                                                        */ 
  90. /**************************************************************************/ 
  91. UINT  _fx_media_abort(FX_MEDIA  *media_ptr)
  92. {
  93. ULONG       open_count;
  94. FX_FILE     *file_ptr;
  95.     /* Check the media to make sure it is open.  */
  96.     if (media_ptr -> fx_media_id != FX_MEDIA_ID)
  97.     {
  98.         /* Return the media not opened error.  */
  99.         return(FX_MEDIA_NOT_OPEN);
  100.     }
  101.     /* Protect against other threads accessing the media.  */
  102.     FX_PROTECT
  103.     /* Loop through the media's open files.  */
  104.     open_count =  media_ptr -> fx_media_opened_file_count;
  105.     file_ptr =    media_ptr -> fx_media_opened_file_list;
  106.     while(open_count)
  107.     {
  108.         /* Mark the file as aborted.  */
  109.         file_ptr -> fx_file_id =  FX_FILE_ABORTED_ID;
  110.         /* Adjust the pointer and decrement the file opened count.  */
  111.         file_ptr =  file_ptr -> fx_file_opened_next;
  112.         open_count--;
  113.     }
  114.     /* Build the "abort" I/O driver request.  */
  115.     media_ptr -> fx_media_driver_request =      FX_DRIVER_ABORT;
  116.     media_ptr -> fx_media_driver_status =       FX_IO_ERROR;
  117.     /* Call the specified I/O driver with the abort request.  */
  118.     (media_ptr -> fx_media_driver_entry) (media_ptr);
  119.     /* Now remove this media from the open list.  */
  120.     /* See if the media is the only one on the media opened list.  */
  121.     if (_fx_system_media_opened_ptr == media_ptr -> fx_media_opened_next)
  122.     {
  123.         /* Only opened media, just set the opened list to NULL.  */
  124.         _fx_system_media_opened_ptr =  FX_NULL;
  125.     }
  126.     else
  127.     {
  128.         /* Otherwise, not the only opened media, link-up the neighbors.  */
  129.         (media_ptr -> fx_media_opened_next) -> fx_media_opened_previous =
  130.                                             media_ptr -> fx_media_opened_previous;
  131.         (media_ptr -> fx_media_opened_previous) -> fx_media_opened_next =
  132.                                             media_ptr -> fx_media_opened_next;
  133.         /* See if we have to update the opened list head pointer.  */
  134.         if (_fx_system_media_opened_ptr == media_ptr)
  135.             
  136.             /* Yes, move the head pointer to the next opened media. */
  137.             _fx_system_media_opened_ptr =  media_ptr -> fx_media_opened_next; 
  138.     }
  139.     /* Decrement the opened media counter.  */
  140.     _fx_system_media_opened_count--;
  141.     /* Finally, Indicate that this media is aborted.  */
  142.     media_ptr -> fx_media_id =  FX_MEDIA_ABORTED_ID;
  143.     /* Release media protection.  */
  144.     FX_UNPROTECT
  145.     /* Return status to the caller.  */
  146.     return(FX_SUCCESS);
  147. }
  148. #endif