FX_MA.C
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:9k
- /**************************************************************************/
- /* */
- /* Copyright (c) 1996-2002 by Express Logic Inc. */
- /* */
- /* This software is copyrighted by and is the sole property of Express */
- /* Logic, Inc. All rights, title, ownership, or other interests */
- /* in the software remain the property of Express Logic, Inc. This */
- /* software may only be used in accordance with the corresponding */
- /* license agreement. Any unauthorized use, duplication, transmission, */
- /* distribution, or disclosure of this software is expressly forbidden. */
- /* */
- /* This Copyright notice may not be removed or modified without prior */
- /* written consent of Express Logic, Inc. */
- /* */
- /* Express Logic, Inc. reserves the right to modify this software */
- /* without notice. */
- /* */
- /* Express Logic, Inc. info@expresslogic.com */
- /* 11423 West Bernardo Court http://www.expresslogic.com */
- /* San Diego, CA 92127 */
- /* */
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /** */
- /** FileX Component */
- /** */
- /** Media (MED) */
- /** */
- /**************************************************************************/
- /**************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef ENABLE_FILEX
- #ifdef _DEBUG
- #undef IFTRACE
- #define IFTRACE if (gTraceFileSys)
- #include "DebugDbgMain.h"
- #endif //_DEBUG
- #define FX_SOURCE_CODE
- /* Include necessary system files. */
- #include "PlaycoreFileSysFileXfx_api.h"
- #include "PlaycoreFileSysFileXfx_sys.h"
- #include "PlaycoreFileSysFileXfx_med.h"
- #include "PlaycoreFileSysFileXfx_fil.h"
- #include "PlaycoreFileSysFileXfx_uti.h"
- /**************************************************************************/
- /* */
- /* FUNCTION RELEASE */
- /* */
- /* _fx_media_abort PORTABLE C */
- /* 3.0 */
- /* AUTHOR */
- /* */
- /* William E. Lamie, Express Logic, Inc. */
- /* */
- /* DESCRIPTION */
- /* */
- /* This function marks all open files for the specified media as */
- /* aborted and then removes the media control block from the open */
- /* media list and marks it as aborted as well. */
- /* */
- /* INPUT */
- /* */
- /* media_ptr Media control block pointer */
- /* */
- /* OUTPUT */
- /* */
- /* return status */
- /* */
- /* CALLS */
- /* */
- /* None */
- /* */
- /* CALLED BY */
- /* */
- /* Application Code */
- /* */
- /* RELEASE HISTORY */
- /* */
- /* DATE NAME DESCRIPTION */
- /* */
- /* 01-01-1999 William E. Lamie Initial Version 1.0 */
- /* 03-01-2000 William E. Lamie Modified comment(s), */
- /* resulting in version 1.0b. */
- /* 01-28-2001 William E. Lamie Modified comment(s), */
- /* resulting in version 2.0. */
- /* 03-01-2002 William E. Lamie Modified comment(s), */
- /* resulting in version 3.0. */
- /* */
- /**************************************************************************/
- UINT _fx_media_abort(FX_MEDIA *media_ptr)
- {
- ULONG open_count;
- FX_FILE *file_ptr;
- /* Check the media to make sure it is open. */
- if (media_ptr -> fx_media_id != FX_MEDIA_ID)
- {
- /* Return the media not opened error. */
- return(FX_MEDIA_NOT_OPEN);
- }
- /* Protect against other threads accessing the media. */
- FX_PROTECT
- /* Loop through the media's open files. */
- open_count = media_ptr -> fx_media_opened_file_count;
- file_ptr = media_ptr -> fx_media_opened_file_list;
- while(open_count)
- {
- /* Mark the file as aborted. */
- file_ptr -> fx_file_id = FX_FILE_ABORTED_ID;
- /* Adjust the pointer and decrement the file opened count. */
- file_ptr = file_ptr -> fx_file_opened_next;
- open_count--;
- }
- /* Build the "abort" I/O driver request. */
- media_ptr -> fx_media_driver_request = FX_DRIVER_ABORT;
- media_ptr -> fx_media_driver_status = FX_IO_ERROR;
- /* Call the specified I/O driver with the abort request. */
- (media_ptr -> fx_media_driver_entry) (media_ptr);
- /* Now remove this media from the open list. */
- /* See if the media is the only one on the media opened list. */
- if (_fx_system_media_opened_ptr == media_ptr -> fx_media_opened_next)
- {
- /* Only opened media, just set the opened list to NULL. */
- _fx_system_media_opened_ptr = FX_NULL;
- }
- else
- {
- /* Otherwise, not the only opened media, link-up the neighbors. */
- (media_ptr -> fx_media_opened_next) -> fx_media_opened_previous =
- media_ptr -> fx_media_opened_previous;
- (media_ptr -> fx_media_opened_previous) -> fx_media_opened_next =
- media_ptr -> fx_media_opened_next;
- /* See if we have to update the opened list head pointer. */
- if (_fx_system_media_opened_ptr == media_ptr)
-
- /* Yes, move the head pointer to the next opened media. */
- _fx_system_media_opened_ptr = media_ptr -> fx_media_opened_next;
- }
- /* Decrement the opened media counter. */
- _fx_system_media_opened_count--;
- /* Finally, Indicate that this media is aborted. */
- media_ptr -> fx_media_id = FX_MEDIA_ABORTED_ID;
- /* Release media protection. */
- FX_UNPROTECT
- /* Return status to the caller. */
- return(FX_SUCCESS);
- }
- #endif