PXIXCORE_BUFFER xixcore_call xixcore_AllocateBuffer(xc_uint32 size) { PXIX_BUF xbuf = NULL; struct page * page = NULL; int order = 0; #if LINUX_VERSION_KMEM_CACHE_T_DEPRECATED xbuf= kmem_cache_alloc(xbuf_cachep, GFP_KERNEL); #else xbuf= kmem_cache_alloc(xbuf_cachep, SLAB_KERNEL); #endif if(!xbuf) { xbuf = kmalloc(sizeof(XIX_BUF), GFP_KERNEL); if( !xbuf) { return NULL; } memset(xbuf, 0, sizeof(XIX_BUF)); XIXCORE_SET_FLAGS(xbuf->xixcore_buffer.xcb_flags, XIXCORE_BUFF_ALLOC_F_MEMORY); }else{ memset(xbuf, 0, sizeof(XIX_BUF)); XIXCORE_SET_FLAGS(xbuf->xixcore_buffer.xcb_flags, XIXCORE_BUFF_ALLOC_F_POOL); } order = get_order(size); page = alloc_pages(GFP_KERNEL, order); if(!page) { xixcore_FreeBuffer(&xbuf->xixcore_buffer); return NULL; } xixcore_InitializeBuffer( &xbuf->xixcore_buffer, page_address(page), (PAGE_SIZE << order), 0); xbuf->xix_page = page; xbuf->xix_flags = 0; return &xbuf->xixcore_buffer; }
void xixcore_call xixcore_DestroyFCB( PXIXCORE_FCB XixcoreFCB ) { if(XixcoreFCB->AddrLot) { xixcore_FreeBuffer(XixcoreFCB->AddrLot ); XixcoreFCB->AddrLot = NULL; } if(XixcoreFCB->FCBName) { xixcore_FreeMem(XixcoreFCB->FCBName, XCTAG_FCBNAME); XixcoreFCB->FCBName = NULL; XixcoreFCB->FCBNameLength = 0; } }
int xixfs_GetMoreCheckOutLotMap( PXIXFS_LINUX_META_CTX pCtx ) { int RC = 0; PXIXFS_LINUX_VCB pVCB = NULL; PXIXCORE_BITMAP_EMUL_CONTEXT pDiskBitmapEmulCtx= NULL; PXIXCORE_LOT_MAP pTempFreeLotMap ; uint32 size = 0; uint32 BuffSize = 0; uint32 trycount = 0; PXIXCORE_META_CTX xixcoreCtx = NULL; XIXCORE_ASSERT(pCtx); pVCB = pCtx->VCBCtx; XIXFS_ASSERT_VCB(pVCB); xixcoreCtx = &pVCB->XixcoreVcb.MetaContext; pDiskBitmapEmulCtx = kmalloc(sizeof(XIXCORE_BITMAP_EMUL_CONTEXT), GFP_KERNEL); if(!pDiskBitmapEmulCtx) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail xixfs_GetMoreCheckOutLotMap --> can't alloc bitmap emul ctx .\n")); return -1; } memset(pDiskBitmapEmulCtx, 0, sizeof(XIXCORE_BITMAP_EMUL_CONTEXT)); pTempFreeLotMap = kmalloc(sizeof(XIXCORE_LOT_MAP), GFP_KERNEL); if(!pTempFreeLotMap) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail xixfs_GetMoreCheckOutLotMap --> can't alloc pTempFreeLotMap .\n")); kfree(pDiskBitmapEmulCtx); return -1; } memset(pDiskBitmapEmulCtx, 0, sizeof(XIXCORE_LOT_MAP)); DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_FSCTL|DEBUG_TARGET_VOLINFO ), ("Enter xixfs_GetMoreCheckOutLotMap.\n")); retry: RC = xixcore_LotLock( &pVCB->XixcoreVcb, xixcoreCtx->HostRegLotMapIndex, &xixcoreCtx->HostRegLotMapLockStatus, 1, 1 ); if( RC <0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x)xixfs_GetMoreCheckOutLotMap --> xixfs_LotLock .\n", RC)); if(trycount > 3) { kfree(pDiskBitmapEmulCtx); kfree(pTempFreeLotMap); return RC; } trycount++; goto retry; } printk(KERN_DEBUG "Get HOT LOT LOCK \n"); // Zero Bit map context; memset(pDiskBitmapEmulCtx, 0, sizeof(XIXCORE_BITMAP_EMUL_CONTEXT)); // Read Disk Bitmap information RC = xixcore_InitializeBitmapContext( pDiskBitmapEmulCtx, &pVCB->XixcoreVcb, xixcoreCtx->HostCheckOutLotMapIndex, xixcoreCtx->FreeLotMapIndex, xixcoreCtx->CheckOutLotMapIndex ); if( RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap --> xixfs_InitializeBitmapContext (0x%x) .\n", RC)); goto error_out; } memset(pTempFreeLotMap, 0, sizeof(XIXCORE_LOT_MAP)); size = SECTOR_ALIGNED_SIZE(pVCB->XixcoreVcb.SectorSizeBit, (uint32) ((pVCB->XixcoreVcb.NumLots + 7)/8 + sizeof(XIDISK_BITMAP_DATA) -1)); BuffSize = size*2; pTempFreeLotMap->Data = xixcore_AllocateBuffer(BuffSize); if(!pTempFreeLotMap->Data){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap -->Allocate TempFreeLotMap .\n")); RC =-ENOMEM; goto error_out; } memset(xixcore_GetDataBuffer(pTempFreeLotMap->Data),0, BuffSize); // Update Disk Free bitmap , dirty map and Checkout Bitmap from free Bitmap RC = xixcore_ReadDirmapFromBitmapContext(pDiskBitmapEmulCtx); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap --> xixfs_ReadDirmapFromBitmapContext (0x%x) .\n", RC)); goto error_out; } /* { uint32 i = 0; uint8 *Data; Data = xixcore_GetDataBufferOfBitMap(pDiskBitmapEmulCtx->UsedBitmap.Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("Host CheckOut BitMap \n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ RC = xixcore_ReadFreemapFromBitmapContext(pDiskBitmapEmulCtx); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap --> xixfs_ReadFreemapFromBitmapContext(0x%x) .\n", RC)); goto error_out; } /* { uint32 i = 0; uint8 * Data; Data = xixcore_GetDataBufferOfBitMap(pDiskBitmapEmulCtx->UnusedBitmap.Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("Disk Free Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ RC = xixcore_ReadCheckoutmapFromBitmapContext(pDiskBitmapEmulCtx); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap --> xixfs_ReadCheckoutmapFromBitmapContext(0x%x) .\n", RC)); goto error_out; } /* { uint32 i = 0; uint8 * Data; Data = xixcore_GetDataBufferOfBitMap(pDiskBitmapEmulCtx->CheckOutBitmap.Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("Disk CheckOut Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ // Get Real FreeMap without CheckOut xixcore_XORMap(&(pDiskBitmapEmulCtx->UnusedBitmap), &(pDiskBitmapEmulCtx->CheckOutBitmap)); /* { uint32 i = 0; uint8 * Data; Data = xixcore_GetDataBuffer(pDiskBitmapEmulCtx->UnusedBitmap.Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("Disk Real free Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ RC = xixcore_SetCheckOutLotMap((PXIXCORE_LOT_MAP)&pDiskBitmapEmulCtx->UnusedBitmap, pTempFreeLotMap, xixcoreCtx->HostRecordIndex + 1); if( RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail SetCheckOutLotMap Status (0x%x) .\n", RC)); goto error_out; } /* { uint32 i = 0; uint8 *Data; Data = xixcore_GetDataBufferOfBitMap(pTempFreeLotMap->Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("Allocated Bit Map\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ //Update Host CheckOutLotMap xixcore_ORMap(&(pDiskBitmapEmulCtx->UsedBitmap), pTempFreeLotMap); /* { uint32 i = 0; uint8 *Data; Data = xixcore_GetDataBufferOfBitMap(pDiskBitmapEmulCtx->UsedBitmap.Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("After Allocate Host Checkout Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } { uint32 i = 0; uint8 * Data; Data = xixcore_GetDataBufferOfBitMap(xixcoreCtx->HostFreeLotMap->Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("Before Allocate Host free Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ //Update Host FreeLotMap xixcore_ORMap(xixcoreCtx->HostFreeLotMap, pTempFreeLotMap); /* { uint32 i = 0; uint8 *Data; Data = xixcore_GetDataBufferOfBitMap(xixcoreCtx->HostFreeLotMap->Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("After Allocate Host free Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ //Update Disk CheckOut BitMap xixcore_ORMap(&(pDiskBitmapEmulCtx->CheckOutBitmap), pTempFreeLotMap); /* { uint32 i = 0; uint8 * Data; Data = xixcore_GetDataBufferOfBitMap(pDiskBitmapEmulCtx->CheckOutBitmap.Data); DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE,("After Allocate Disk CheckOut Bitmap\n")); for(i = 0; i<2; i++){ DebugTrace(DEBUG_LEVEL_INFO, DEBUG_TARGET_RESOURCE, ("<%i>[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]:[%02x]\n", i*8,Data[i*8],Data[i*8 +1],Data[i*8 +2],Data[i*8 +3], Data[i*8 +4],Data[i*8 +5],Data[i*8 +6],Data[i*8 +7])); } } */ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 0 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); // Added by ILGU HONG 2006 06 12 xixcoreCtx->VolumeFreeMap->BitMapBytes = pDiskBitmapEmulCtx->UnusedBitmap.BitMapBytes; xixcoreCtx->VolumeFreeMap->MapType = pDiskBitmapEmulCtx->UnusedBitmap.MapType; xixcoreCtx->VolumeFreeMap->NumLots = pDiskBitmapEmulCtx->UnusedBitmap.NumLots; /* memcpy(xixcore_GetDataBufferOfBitMap(pCtx->VolumeFreeMap->Data), xixcore_GetDataBufferOfBitMap(pDiskBitmapEmulCtx->UnusedBitmap.Data), pCtx->VolumeFreeMap->BitMapBytes ); */ // Added by ILGU HONG 2006 06 12 End DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 1 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); // Update Disk Information RC = xixcore_WriteCheckoutmapFromBitmapContext(pDiskBitmapEmulCtx); DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 2 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap --> xixfs_WriteCheckoutmapFromBitmapContext(0x%x) .\n", RC)); goto error_out; } // Update Host Record Information RC = xixcore_WriteDirmapFromBitmapContext(pDiskBitmapEmulCtx); DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 3 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap --> xixfs_WriteDirmapFromBitmapContext(0x%x) .\n", RC)); goto error_out; } DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 4 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); RC = xixcore_WriteBitMapWithBuffer( &pVCB->XixcoreVcb, xixcoreCtx->HostUsedLotMapIndex, xixcoreCtx->HostDirtyLotMap, pDiskBitmapEmulCtx->LotHeader, pDiskBitmapEmulCtx->BitmapLotHeader, 0 ); DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 5 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap -->xixfs_WriteBitMapWithBuffer(0x%x) .\n", RC)); goto error_out; } RC = xixcore_WriteBitMapWithBuffer( &pVCB->XixcoreVcb, xixcoreCtx->HostUnUsedLotMapIndex, xixcoreCtx->HostFreeLotMap, pDiskBitmapEmulCtx->LotHeader, pDiskBitmapEmulCtx->BitmapLotHeader, 0 ); DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("STEP 6 pDiskBitmapEmulCtx->BitmapLotHeader(%p)\n", pDiskBitmapEmulCtx->BitmapLotHeader)); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("FAIL xixfs_GetMoreCheckOutLotMap -->xixfs_WriteBitMapWithBuffer(0x%x) .\n", RC)); goto error_out; } error_out: xixcore_LotUnLock( &pVCB->XixcoreVcb, xixcoreCtx->HostRegLotMapIndex, &(xixcoreCtx->HostRegLotMapLockStatus) ); printk(KERN_DEBUG "Free HOT LOT LOCK \n"); if(pDiskBitmapEmulCtx) { xixcore_CleanupBitmapContext(pDiskBitmapEmulCtx); kfree(pDiskBitmapEmulCtx); } if(pTempFreeLotMap){ if(pTempFreeLotMap->Data){ xixcore_FreeBuffer(pTempFreeLotMap->Data); } kfree(pTempFreeLotMap); } DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_FSCTL|DEBUG_TARGET_VOLINFO ), ("Exit XifsdGetMoreCheckOutLotMap Status (0x%x).\n", RC)); return RC; }
int xixfs_UpdateMetaData( PXIXFS_LINUX_META_CTX pCtx ) { int RC = 0; PXIX_BUF tmpBuf = NULL; PXIX_BUF tmpLotHeader = NULL; PXIXFS_LINUX_VCB pVCB = NULL; PXIXCORE_META_CTX xixcoreCtx; DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_FSCTL|DEBUG_TARGET_VOLINFO ), ("Enter xixfs_UpdateMetaData .\n")); XIXCORE_ASSERT(pCtx); pVCB = pCtx->VCBCtx; XIXFS_ASSERT_VCB(pVCB); xixcoreCtx = &pVCB->XixcoreVcb.MetaContext; tmpBuf = (PXIX_BUF)xixcore_AllocateBuffer(XIDISK_DUP_LOT_MAP_INFO_SIZE); if(!tmpBuf) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail allocate xbuf : xixfs_UpdateMetaData Host Dirty map .\n")); RC = - ENOMEM; return RC; } memset(xixcore_GetDataBuffer(&tmpBuf->xixcore_buffer), 0, XIDISK_DUP_LOT_MAP_INFO_SIZE); tmpLotHeader = (PXIX_BUF)xixcore_AllocateBuffer(XIDISK_DUP_COMMON_LOT_HEADER_SIZE); if(!tmpLotHeader) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail allocate xbuf : xixfs_UpdateMetaData Host Dirty map .\n")); RC = - ENOMEM; goto error_out; } memset(xixcore_GetDataBuffer(&tmpLotHeader->xixcore_buffer), 0, XIDISK_DUP_COMMON_LOT_HEADER_SIZE); RC = xixcore_WriteBitMapWithBuffer(&pVCB->XixcoreVcb, xixcoreCtx->HostUsedLotMapIndex, xixcoreCtx->HostDirtyLotMap, &tmpLotHeader->xixcore_buffer, &tmpBuf->xixcore_buffer, 0); if( RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail Status(0x%x) xixfs_UpdateMetaData--> xixfs_WriteBitMapWithBuffer Host Dirty map .\n", RC)); goto error_out; } memset(xixcore_GetDataBuffer(&tmpBuf->xixcore_buffer), 0, XIDISK_MAP_LOT_SIZE); RC = xixcore_WriteBitMapWithBuffer(&pVCB->XixcoreVcb, xixcoreCtx->HostUnUsedLotMapIndex, xixcoreCtx->HostFreeLotMap, &tmpLotHeader->xixcore_buffer, &tmpBuf->xixcore_buffer, 0); if(RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail Status(0x%x) xixfs_UpdateMetaData--> xixfs_WriteBitMapWithBuffer Host Free map.\n", RC)); goto error_out; } error_out: if( tmpBuf ) { xixcore_FreeBuffer( &tmpBuf->xixcore_buffer); } if(tmpLotHeader) { xixcore_FreeBuffer(&tmpLotHeader->xixcore_buffer); } DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_FSCTL|DEBUG_TARGET_VOLINFO ), ("Exit Status(0x%x) xixfs_UpdateMetaData .\n", RC)); return RC; }
static void xixfs_put_super( struct super_block *sb ) { int RC = 0; PXIXFS_LINUX_VCB pVCB = NULL; PXIXFS_LINUX_META_CTX pCtx = NULL; PXIXCORE_META_CTX pXixcoreCtx = NULL; #if LINUX_VERSION_25_ABOVE int TimeOut = 0; #endif XIXCORE_ASSERT(sb); pVCB = XIXFS_SB(sb); XIXFS_ASSERT_VCB(pVCB); pCtx = &(pVCB->MetaCtx); pXixcoreCtx = &pVCB->XixcoreVcb.MetaContext; XIXCORE_ASSERT(pCtx); DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_VFSAPIT|DEBUG_TARGET_VCB), ("Enter xixfs_put_super\n")); xixcore_CleanUpAuxLotLockInfo(&pVCB->XixcoreVcb); if(pVCB->XixcoreVcb.IsVolumeWriteProtected != 1) { #if !LINUX_VERSION_25_ABOVE XIXFS_WAIT_CTX wait; #endif DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_ALL, ("!!request Meta thread stop \n")); spin_lock(&(pCtx->MetaLock)); DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_CHECK, ("spin_lock(&(pCtx->MetaLock)) pCtx(%p)\n", pCtx)); XIXCORE_SET_FLAGS(pXixcoreCtx->VCBMetaFlags, XIXCORE_META_FLAGS_KILL_THREAD); spin_unlock(&(pCtx->MetaLock)); DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_CHECK, ("spin_unlock(&(pCtx->MetaLock)) pCtx(%p)\n", pCtx)); #if !LINUX_VERSION_25_ABOVE xixfs_init_wait_ctx(&wait); xixfs_add_metaThread_stop_wait_list(&wait, pCtx); #endif wake_up(&(pCtx->VCBMetaEvent)); DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_THREAD, ("META THREAD STOP REQ\n")); #if LINUX_VERSION_25_ABOVE TimeOut = DEFAULT_XIXFS_UMOUNTWAIT; RC = wait_for_completion_timeout(&(pCtx->VCBMetaThreadStopCompletion), TimeOut); INIT_COMPLETION(pCtx->VCBMetaThreadStopCompletion); #else wait_for_completion(&(wait.WaitCompletion)); #endif DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_THREAD, ("END META THREAD STOP REQ\n")); DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_ALL, ("!!replyed Meta thread stop \n")); RC = xixcore_DeregisterHost(&pVCB->XixcoreVcb); if(pVCB->XixcoreVcb.MetaContext.HostDirtyLotMap) { xixcore_FreeBuffer(pVCB->XixcoreVcb.MetaContext.HostDirtyLotMap->Data); kfree(pVCB->XixcoreVcb.MetaContext.HostDirtyLotMap); pVCB->XixcoreVcb.MetaContext.HostDirtyLotMap = NULL; } if(pVCB->XixcoreVcb.MetaContext.HostFreeLotMap) { xixcore_FreeBuffer(pVCB->XixcoreVcb.MetaContext.HostFreeLotMap->Data); kfree(pVCB->XixcoreVcb.MetaContext.HostFreeLotMap); pVCB->XixcoreVcb.MetaContext.HostFreeLotMap = NULL; } if(pVCB->XixcoreVcb.MetaContext.VolumeFreeMap) { xixcore_FreeBuffer(pVCB->XixcoreVcb.MetaContext.VolumeFreeMap->Data); kfree(pVCB->XixcoreVcb.MetaContext.VolumeFreeMap); pVCB->XixcoreVcb.MetaContext.VolumeFreeMap = NULL; } } xixcore_DeleteALLChildCacheEntry(&pVCB->XixcoreVcb); if(pVCB->XixcoreVcb.VolumeName){ xixcore_FreeMem(pVCB->XixcoreVcb.VolumeName, XCTAG_VOLNAME); } spin_lock(&(xixfs_linux_global.sb_list_lock)); DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_CHECK, ("spin_lock(&(xixfs_linux_global.sb_list_lock)) \n" )); list_del(&(pVCB->VCBLink)); spin_unlock(&(xixfs_linux_global.sb_list_lock)); DebugTrace(DEBUG_LEVEL_TRACE, DEBUG_TARGET_CHECK, ("spin_unlock(&(xixfs_linux_global.sb_list_lock)) \n" )); DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_VFSAPIT|DEBUG_TARGET_VCB), ("Exit xixfs_put_super\n")); unload_nls(pVCB->nls_map); kfree(pVCB); #if LINUX_VERSION_25_ABOVE sb->s_fs_info = NULL; #else sb->u.generic_sbp = NULL; #endif }
int xixcore_call xixcore_CheckFileDirFromBitMapContext( PXIXCORE_VCB VCB, PXIXCORE_BITMAP_EMUL_CONTEXT BitmapEmulCtx ) { int RC = 0; PXIDISK_COMMON_LOT_HEADER pCommonLotHeader = NULL; PXIXCORE_LOT_MAP HostFreeMap = NULL; PXIXCORE_LOT_MAP HostDirtyMap = NULL; PXIXCORE_LOT_MAP HostCheckOutMap = NULL; xc_int64 SearchIndex = -1; PXIXCORE_BUFFER xbuf = NULL; PXIXCORE_BUFFER LotHeader = NULL; xc_uint32 Size = 0; int Reason = 0; DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_FSCTL|DEBUG_TARGET_VOLINFO ), ("Enter xixcore_CheckFileDirFromBitMapContext .\n")); HostFreeMap = (PXIXCORE_LOT_MAP)&(BitmapEmulCtx->UnusedBitmap); HostDirtyMap = (PXIXCORE_LOT_MAP)&(BitmapEmulCtx->UsedBitmap); HostCheckOutMap = (PXIXCORE_LOT_MAP)&(BitmapEmulCtx->CheckOutBitmap); if(VCB->SectorSize > XIDISK_FILE_INFO_SIZE){ Size = VCB->SectorSize; }else{ Size = XIDISK_FILE_INFO_SIZE; } xbuf = xixcore_AllocateBuffer(XIDISK_DUP_FILE_INFO_SIZE); if(!xbuf) { DebugTrace(DEBUG_LEVEL_ALL, DEBUG_TARGET_ALL, ("Fail xixcore_CheckFileDirFromBitMapContext->Allocate xBuff\n")); return XCCODE_ENOMEM; } LotHeader = xixcore_AllocateBuffer(XIDISK_DUP_COMMON_LOT_HEADER_SIZE); if(!LotHeader) { xixcore_FreeBuffer(xbuf); DebugTrace(DEBUG_LEVEL_ALL, DEBUG_TARGET_ALL, ("Fail xixcore_CheckFileDirFromBitMapContext->Allocate xBuff\n")); return XCCODE_ENOMEM; } // Check Start with Host Dirty map while(1) { SearchIndex = xixcore_FindSetBit( VCB->NumLots, SearchIndex, xixcore_GetDataBufferOfBitMap(HostDirtyMap->Data) ); if((xc_uint64)SearchIndex >= VCB->NumLots){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail xixcore_CheckFileDirFromBitMapContext-->xixcore_FindSetBit End of Lot.\n")); break; } if(SearchIndex < 24){ continue; } DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Searched Index (%lld).\n", SearchIndex)); xixcore_ZeroBufferOffset(LotHeader); memset(xixcore_GetDataBuffer(LotHeader), 0,XIDISK_DUP_COMMON_LOT_HEADER_SIZE); // Read Lot map info RC = xixcore_RawReadLotHeader( VCB->XixcoreBlockDevice, VCB->LotSize, VCB->SectorSize, VCB->SectorSizeBit, SearchIndex, LotHeader, &Reason ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x) (Reason %x)xixcore_CheckFileDirFromBitMapContext-->RawReadLot .\n", RC, Reason)); if(RC == XCCODE_CRCERROR){ pCommonLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(LotHeader); goto invalidate_lot; }else{ goto error_out; } } // Check Lot map info pCommonLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(LotHeader); DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Lot (%lld) Type(0x%x) Flags(0x%x).\n", SearchIndex, pCommonLotHeader->LotInfo.Type, pCommonLotHeader->LotInfo.Flags)); if( (pCommonLotHeader->LotInfo.Type & (LOT_INFO_TYPE_INVALID|LOT_INFO_TYPE_FILE|LOT_INFO_TYPE_DIRECTORY)) && (pCommonLotHeader->LotInfo.LotSignature == VCB->VolumeLotSignature)) { if((pCommonLotHeader->LotInfo.Type == LOT_INFO_TYPE_INVALID) || (pCommonLotHeader->LotInfo.Flags == LOT_FLAG_INVALID )) { DebugTrace(DEBUG_LEVEL_ALL, DEBUG_TARGET_ALL, ("!!!!! Find Null bitmap information Lot %lld !!!!!!\n", SearchIndex)); xixcore_InitializeCommonLotHeader( pCommonLotHeader, VCB->VolumeLotSignature, LOT_INFO_TYPE_INVALID, LOT_FLAG_INVALID, SearchIndex, SearchIndex, 0, 0, 0, 0, 0 ); RC = xixcore_RawWriteLotHeader( VCB->XixcoreBlockDevice, VCB->LotSize, VCB->SectorSize, VCB->SectorSizeBit, SearchIndex, LotHeader, &Reason ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x) (Reason %x)xixcore_CheckFileDirFromBitMapContext-->WriteReadLot .\n", RC, Reason)); goto error_out; } // Update Lot map xixcore_ClearBit(SearchIndex, (unsigned long *)xixcore_GetDataBufferOfBitMap(HostDirtyMap->Data)); xixcore_SetBit(SearchIndex, (unsigned long *)xixcore_GetDataBufferOfBitMap(HostFreeMap->Data)); }else if((pCommonLotHeader->LotInfo.Type == LOT_INFO_TYPE_FILE) && (pCommonLotHeader->LotInfo.Flags == LOT_FLAG_BEGIN)){ PXIDISK_FILE_INFO pFileHeader; xc_uint32 i = 0; xc_uint32 AddrStartIndex = 0; xc_uint32 AddrSavedIndex = 0; xc_uint64 AdditionalAddrLot = 0; xc_uint32 bDelete = 0; xc_uint32 bStop = 0; xc_uint64 *Addr = NULL; xc_uint32 DefaultSecPerLotAddr = (xc_uint32)(VCB->AddrLotSize/sizeof(xc_uint64)); DebugTrace(DEBUG_LEVEL_ALL, DEBUG_TARGET_ALL, ("!!!!! Find a Valid Information Lot %lld !!!!!!\n", SearchIndex)); RC = xixcore_AuxLotLock( VCB, SearchIndex, 0, 0 ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x)xixcore_CheckFileDirFromBitMapContext--> xixcore_AuxLotLock .\n", RC)); continue; } xixcore_ZeroBufferOffset(xbuf); memset(xixcore_GetDataBuffer(xbuf), 0,XIDISK_DUP_FILE_INFO_SIZE); RC = xixcore_RawReadFileHeader( VCB->XixcoreBlockDevice, VCB->LotSize, VCB->SectorSize, VCB->SectorSizeBit, SearchIndex, xbuf, &Reason ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x) (Reason %x)xixcore_CheckFileDirFromBitMapContext-->xixcore_RawReadLotAndFileHeader .\n", RC, Reason)); xixcore_AuxLotUnLock( VCB, SearchIndex ); if(RC == XCCODE_CRCERROR){ pCommonLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(LotHeader); goto invalidate_lot; }else{ goto error_out; } } AddrStartIndex = 0; i = 0; pFileHeader = (PXIDISK_FILE_INFO)xixcore_GetDataBufferWithOffset(xbuf); if(pFileHeader->State == XIFS_FD_STATE_DELETED){ bDelete = 1; } AdditionalAddrLot = pFileHeader->AddressMapIndex; do{ xixcore_ZeroBufferOffset(xbuf); memset(xixcore_GetDataBuffer(xbuf), 0,XIDISK_DUP_FILE_INFO_SIZE); RC = xixcore_RawReadAddressOfFile( VCB->XixcoreBlockDevice, VCB->LotSize, VCB->SectorSize, VCB->SectorSizeBit, SearchIndex, AdditionalAddrLot, VCB->AddrLotSize, &AddrSavedIndex, AddrStartIndex, xbuf, &Reason ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x) (Reason %x)xixcore_CheckFileDirFromBitMapContext-->xixcore_RawReadAddressOfFile .\n", RC, Reason)); bStop = 1; break; } Addr = (xc_uint64 *)xixcore_GetDataBufferWithOffset(xbuf); for(i = 0; i<DefaultSecPerLotAddr; i++){ if((Addr[i] != 0) && (Addr[i] >= 24) && (Addr[i] < VCB->NumLots)){ if(xixcore_TestBit(Addr[i] , (unsigned long *)xixcore_GetDataBufferOfBitMap(HostCheckOutMap->Data))){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Update Addr Info Lo(%lld)\n", Addr[i])); if(bDelete == 1){ xixcore_ClearBit(Addr[i], (unsigned long *)xixcore_GetDataBufferOfBitMap(HostDirtyMap->Data)); xixcore_SetBit(Addr[i], (unsigned long *)xixcore_GetDataBufferOfBitMap(HostFreeMap->Data)); }else{ xixcore_ClearBit(Addr[i], (unsigned long *)xixcore_GetDataBufferOfBitMap(HostFreeMap->Data)); xixcore_SetBit(Addr[i], (unsigned long *)xixcore_GetDataBufferOfBitMap(HostDirtyMap->Data)); } } }else{ bStop = 1; break; } } AddrStartIndex ++; }while(bStop == 0); xixcore_AuxLotUnLock( VCB, SearchIndex ); } }else{ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Failed Lot (%lld) Type(0x%x) Flags(0x%x).\n", SearchIndex, pCommonLotHeader->LotInfo.Type, pCommonLotHeader->LotInfo.Flags)); if(pCommonLotHeader->LotInfo.LotSignature != VCB->VolumeLotSignature){ invalidate_lot: DebugTrace(DEBUG_LEVEL_ALL, DEBUG_TARGET_ALL, ("!!!!! Find a inaccurate bitmap information Lot %lld !!!!!!\n", SearchIndex)); xixcore_InitializeCommonLotHeader( pCommonLotHeader, VCB->VolumeLotSignature, LOT_INFO_TYPE_INVALID, LOT_FLAG_INVALID, SearchIndex, SearchIndex, 0, 0, 0, 0, 0 ); RC = xixcore_RawWriteLotHeader( VCB->XixcoreBlockDevice, VCB->LotSize, VCB->SectorSize, VCB->SectorSizeBit, SearchIndex, LotHeader, &Reason ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x) (Reason %x)xixcore_CheckFileDirFromBitMapContext-->xixcore_RawWriteLotHeader .\n", RC, Reason)); goto error_out; } xixcore_ClearBit(SearchIndex, (unsigned long *)xixcore_GetDataBufferOfBitMap(HostDirtyMap->Data)); xixcore_SetBit(SearchIndex, (unsigned long *)xixcore_GetDataBufferOfBitMap(HostFreeMap->Data)); } } } SearchIndex = -1; // Check Start with Host Free map while(1) { SearchIndex = xixcore_FindSetBit(VCB->NumLots, SearchIndex, xixcore_GetDataBufferOfBitMap(HostFreeMap->Data)); if((xc_uint64)SearchIndex >= VCB->NumLots){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail xixcore_CheckFileDirFromBitMapContext-->xixcore_FindSetBit End of Lot.\n")); break; } if(SearchIndex < 24){ continue; } DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Searched Index (%lld).\n", SearchIndex)); xixcore_ZeroBufferOffset(LotHeader); memset(xixcore_GetDataBuffer(LotHeader), 0,XIDISK_DUP_COMMON_LOT_HEADER_SIZE); // Read Lot map info RC = xixcore_RawReadLotHeader( VCB->XixcoreBlockDevice, VCB->LotSize, VCB->SectorSize, VCB->SectorSizeBit, SearchIndex, LotHeader, &Reason ); if( RC < 0){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Fail(0x%x) (Reason %x)xixcore_CheckFileDirFromBitMapContext-->xixcore_RawReasdLotHeader .\n", RC, Reason)); if(RC == XCCODE_CRCERROR){ continue; }else{ goto error_out; } } pCommonLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(LotHeader); // Check Lot map info if( pCommonLotHeader->LotInfo.Type & (LOT_INFO_TYPE_INVALID | LOT_INFO_TYPE_FILE | LOT_INFO_TYPE_DIRECTORY)) { if( (pCommonLotHeader->LotInfo.Type != LOT_INFO_TYPE_INVALID) && (pCommonLotHeader->LotInfo.Flags != LOT_FLAG_INVALID ) && (pCommonLotHeader->LotInfo.LotSignature == VCB->VolumeLotSignature)) { DebugTrace(DEBUG_LEVEL_ALL, DEBUG_TARGET_ALL, ("!!!!! Find a Used bitmap information Lot %lld !!!!!!\n", SearchIndex)); // Update Lot map xixcore_ClearBit(SearchIndex, (unsigned long *)xixcore_GetDataBufferOfBitMap(HostFreeMap->Data)); xixcore_SetBit(SearchIndex, (unsigned long *)xixcore_GetDataBufferOfBitMap(HostDirtyMap->Data)); } } } error_out: if(xbuf) { xixcore_FreeBuffer(xbuf); } if(LotHeader){ xixcore_FreeBuffer(LotHeader); } DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_FSCTL|DEBUG_TARGET_VOLINFO ), ("Exit xixcore_CheckFileDirFromBitMapContext Status(0x%x).\n", RC)); return RC; }
int xixcore_call xixcore_CreateNewFile( PXIXCORE_VCB pVCB, PXIXCORE_FCB pDir, xc_uint32 bIsFile, xc_uint8 * Name, xc_uint32 NameLength, xc_uint32 FileAttribute, PXIXCORE_DIR_EMUL_CONTEXT DirContext, xc_uint64 *NewFileId ) { int RC = 0; PXIXCORE_BUFFER xbuf = NULL; PXIXCORE_BUFFER LotHeader = NULL; xc_int64 BeginingLotIndex = 0; xc_uint32 bLotAlloc = 0; xc_uint32 IsDirSet = 0; xc_uint32 ChildType = 0; xc_uint64 ChildIndex = 0; xc_int32 Reason = 0; PXIDISK_COMMON_LOT_HEADER pLotHeader = NULL; PXIDISK_FILE_INFO pFileInfo = NULL; PXIDISK_DIR_INFO pDirInfo = NULL; PXIDISK_ADDR_MAP pAddressMap = NULL; xc_uint32 AddrStartSectorIndex = 0; xc_uint64 EntryIndex = 0; DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_DIRINFO|DEBUG_TARGET_FCB|DEBUG_TARGET_FILEINFO), ("Enter xixcore_CreateNewFile \n")); XIXCORE_ASSERT_FCB(pDir); XIXCORE_ASSERT_VCB(pVCB); // Changed by ILGU HONG for readonly 09052006 if(pVCB->IsVolumeWriteProtected){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR xixcore_CreateNewFile : is read only .\n")); RC = XCCODE_EPERM; return RC; } // Changed by ILGU HONG for readonly end ChildType = (bIsFile)?(XIFS_FD_TYPE_FILE):(XIFS_FD_TYPE_DIRECTORY); if(NameLength > (XIFS_MAX_FILE_NAME_LENGTH * sizeof(xc_le16) )){ DebugTrace(DEBUG_LEVEL_INFO, (DEBUG_TARGET_DIRINFO|DEBUG_TARGET_FCB|DEBUG_TARGET_FILEINFO), ("FileNameLen(%d).\n", NameLength)); NameLength = XIFS_MAX_FILE_NAME_LENGTH * sizeof(xc_le16); } xbuf = xixcore_AllocateBuffer(XIDISK_DUP_FILE_INFO_SIZE); if(xbuf == NULL) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR xixcore_CreateNewFile : can't allocate xbuf .\n")); RC = XCCODE_ENOMEM; return RC; } LotHeader = xixcore_AllocateBuffer(XIDISK_DUP_COMMON_LOT_HEADER_SIZE); if(LotHeader == NULL) { xixcore_FreeBuffer(xbuf); DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR xixcore_CreateNewFile : can't allocate LotHeader .\n")); RC = XCCODE_ENOMEM; return RC; } RC = xixcore_FindDirEntry ( pVCB, pDir, (xc_uint8 *)Name, NameLength, DirContext, &EntryIndex, 1 ); if(RC >= 0){ RC = XCCODE_EPERM; goto error_out; } BeginingLotIndex = xixcore_AllocVCBLot(pVCB); if(BeginingLotIndex < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR xixcore_CreateNewFile : can't allocate lot.\n")); RC =XCCODE_ENOSPC; goto error_out; } bLotAlloc = 1; RC = xixcore_AddChildToDir( pVCB, pDir, BeginingLotIndex, ChildType, Name, NameLength, DirContext, &ChildIndex ); if( RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) xixcore_CreateNewFile : xixcore_AddChildToDir.\n", RC)); goto error_out; } IsDirSet =1; xixcore_ZeroBufferOffset(xbuf); memset(xixcore_GetDataBuffer(xbuf), 0,XIDISK_DUP_FILE_INFO_SIZE); xixcore_ZeroBufferOffset(LotHeader); memset(xixcore_GetDataBuffer(LotHeader), 0,XIDISK_DUP_COMMON_LOT_HEADER_SIZE); DebugTrace(DEBUG_LEVEL_INFO, (DEBUG_TARGET_DIRINFO|DEBUG_TARGET_FCB|DEBUG_TARGET_FILEINFO), ("Make File Info.\n")); RC = xixcore_RawReadLotHeader( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, LotHeader, &Reason ); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteLotAndFileHeader.\n", RC, Reason)); if(RC == XCCODE_CRCERROR){ xixcore_ZeroBufferOffset(LotHeader); }else{ goto error_out; } } RC = xixcore_RawReadFileHeader( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, xbuf, &Reason ); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteFileHeader.\n", RC, Reason)); if(RC == XCCODE_CRCERROR){ xixcore_ZeroBufferOffset(xbuf); }else{ goto error_out; } } if(ChildType == XIFS_FD_TYPE_FILE){ pFileInfo = (PXIDISK_FILE_INFO)xixcore_GetDataBufferWithOffset(xbuf); pLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(LotHeader); xixcore_InitializeCommonLotHeader( pLotHeader, pVCB->VolumeLotSignature, LOT_INFO_TYPE_FILE, LOT_FLAG_BEGIN, BeginingLotIndex, BeginingLotIndex, 0, 0, 0, sizeof(XIDISK_FILE_HEADER), pVCB->LotSize - sizeof(XIDISK_FILE_HEADER) ); pLotHeader->Lock.LockState = XIDISK_LOCK_RELEASED; pLotHeader->Lock.LockAcquireTime=0; memcpy(pLotHeader->Lock.LockHostSignature, pVCB->HostId , 16); // Changed by ILGU HONG // chesung suggest //RtlCopyMemory(pLotHeader->Lock.LockHostMacAddress, PtrVCB->HostMac, 6); memcpy(pLotHeader->Lock.LockHostMacAddress, pVCB->HostMac, 32); memset(pFileInfo, 0, (XIDISK_COMMON_LOT_HEADER_SIZE - XIXCORE_MD5DIGEST_AND_SEQSIZE)); pFileInfo->Access_time = xixcore_GetCurrentTime64(); pFileInfo->Change_time = xixcore_GetCurrentTime64(); pFileInfo->Create_time = xixcore_GetCurrentTime64(); pFileInfo->Modified_time = xixcore_GetCurrentTime64(); memcpy(pFileInfo->OwnHostId , pVCB->HostId, 16); pFileInfo->ParentDirLotIndex = pDir->LotNumber; pFileInfo->LotIndex = BeginingLotIndex; pFileInfo->State = XIFS_FD_STATE_CREATE; pFileInfo->ACLState = 0; pFileInfo->FileAttribute = (FileAttribute|FILE_ATTRIBUTE_ARCHIVE); pFileInfo->AccessFlags = FILE_SHARE_READ; pFileInfo->FileSize = 0; pFileInfo->AllocationSize = pVCB->LotSize - XIDISK_FILE_HEADER_SIZE; pFileInfo->AddressMapIndex = 0; pFileInfo->LinkCount = 1; pFileInfo->NameSize = NameLength; pFileInfo->AddressMapIndex = 0; XIXCORE_SET_FLAGS(pFileInfo->Type, XIFS_FD_TYPE_FILE); memcpy(pFileInfo->Name, Name, NameLength); pFileInfo->AddressMapIndex = 0; }else{ pDirInfo = (PXIDISK_DIR_INFO)xixcore_GetDataBufferWithOffset(xbuf); pLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(LotHeader); xixcore_InitializeCommonLotHeader( pLotHeader, pVCB->VolumeLotSignature, LOT_INFO_TYPE_DIRECTORY, LOT_FLAG_BEGIN, BeginingLotIndex, BeginingLotIndex, 0, 0, 0, sizeof(XIDISK_FILE_HEADER_LOT), pVCB->LotSize - sizeof(XIDISK_DIR_HEADER_LOT) ); pLotHeader->Lock.LockState= XIDISK_LOCK_RELEASED; pLotHeader->Lock.LockAcquireTime= 0;; memcpy(pLotHeader->Lock.LockHostSignature, pVCB->HostId , 16); // Changed by ILGU HONG // chesung suggest //RtlCopyMemory(pLotHeader->Lock.LockHostMacAddress, PtrVCB->HostMac, 6); memcpy(pLotHeader->Lock.LockHostMacAddress, pVCB->HostMac, 32); memset(pDirInfo, 0, (XIDISK_COMMON_LOT_HEADER_SIZE - XIXCORE_MD5DIGEST_AND_SEQSIZE)); pDirInfo->Access_time = xixcore_GetCurrentTime64(); pDirInfo->Change_time = xixcore_GetCurrentTime64(); pDirInfo->Create_time = xixcore_GetCurrentTime64(); pDirInfo->Modified_time = xixcore_GetCurrentTime64(); memcpy(pDirInfo->OwnHostId ,pVCB->HostId, 16); pDirInfo->ParentDirLotIndex = pDir->LotNumber; pDirInfo->LotIndex = BeginingLotIndex; pDirInfo->State = XIFS_FD_STATE_CREATE; pDirInfo->ACLState = 0; pDirInfo->FileAttribute = (FileAttribute | FILE_ATTRIBUTE_DIRECTORY); pDirInfo->AccessFlags = FILE_SHARE_READ; pDirInfo->FileSize = 0; pDirInfo->AllocationSize = pVCB->LotSize - XIDISK_DIR_HEADER_SIZE; pDirInfo->LinkCount = 1; XIXCORE_SET_FLAGS(pDirInfo->Type, XIFS_FD_TYPE_DIRECTORY); pDirInfo->NameSize = NameLength; memcpy(pDirInfo->Name, Name, NameLength); pDirInfo->AddressMapIndex = 0; } RC = xixcore_RawWriteFileHeader( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, xbuf, &Reason ); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteFileHeader.\n", RC, Reason)); goto error_out; } RC = xixcore_RawWriteLotHeader( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, LotHeader, &Reason ); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteLotAndFileHeader.\n", RC, Reason)); goto error_out; } xixcore_ZeroBufferOffset(xbuf); memset(xixcore_GetDataBuffer(xbuf), 0, XIDISK_DUP_FILE_INFO_SIZE); pAddressMap = (PXIDISK_ADDR_MAP)xixcore_GetDataBufferWithOffset(xbuf); pAddressMap->LotNumber[0] = BeginingLotIndex; RC = xixcore_RawWriteAddressOfFile( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, 0, pDir->AddrLotSize, &AddrStartSectorIndex, 0, xbuf, &Reason); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteAddressOfFile.\n", RC, Reason)); goto error_out; } if(ChildType == XIFS_FD_TYPE_DIRECTORY) { PXIDISK_HASH_VALUE_TABLE pTable = NULL; xixcore_ZeroBufferOffset(xbuf); memset(xixcore_GetDataBuffer(xbuf), 0, XIDISK_DUP_FILE_INFO_SIZE); RC = xixcore_RawReadDirEntryHashValueTable( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, xbuf, &Reason ); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteDirEntryHashValueTable.\n", RC, Reason)); if(RC == XCCODE_CRCERROR){ xixcore_ZeroBufferOffset(xbuf); }else{ goto error_out; } } pTable = (PXIDISK_HASH_VALUE_TABLE)xixcore_GetDataBufferWithOffset(xbuf); memset(pTable, 0, (XIDISK_HASH_VALUE_TABLE_SIZE - XIXCORE_MD5DIGEST_AND_SEQSIZE)); RC = xixcore_RawWriteDirEntryHashValueTable( pVCB->XixcoreBlockDevice, pVCB->LotSize, pVCB->SectorSize, pVCB->SectorSizeBit, BeginingLotIndex, xbuf, &Reason ); if(RC < 0 ){ DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("ERROR(0x%x) Reason(0x%x) xixcore_CreateNewFile : xixcore_RawWriteDirEntryHashValueTable.\n", RC, Reason)); goto error_out; } } *NewFileId = BeginingLotIndex; //xixcore_NotifyChange(pVCB, XIXCORE_META_FLAGS_UPDATE); RC = XCCODE_SUCCESS; error_out: if( RC < 0 ) { if(IsDirSet == 1){ xixcore_DeleteChildFromDir( pVCB, pDir, ChildIndex, DirContext ); } if(bLotAlloc == 1) { xixcore_FreeVCBLot(pVCB, BeginingLotIndex); } } if(xbuf) { xixcore_FreeBuffer(xbuf); } if(LotHeader){ xixcore_FreeBuffer(LotHeader); } DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_DIRINFO|DEBUG_TARGET_FCB|DEBUG_TARGET_FILEINFO), ("Exit (0x%x) xixcore_CreateNewFile \n", RC)); return RC; }
int xixcore_call xixcore_DumpFileLot( PXIXCORE_BLOCK_DEVICE bdev, xc_uint32 VolLotSignature, xc_uint32 LotSize, xc_uint64 StartIndex, xc_uint32 Type, xc_uint32 SectorSize, xc_uint32 SectorSizeBit, xc_int32 *Reason ) { int RC = 0; PXIXCORE_BUFFER xbuf = NULL; XIXCORE_IO_LOT_INFO AddressInfo; PXIDISK_COMMON_LOT_HEADER pLotHeader = NULL; xc_uint32 size = 0; DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_DEVCTL|DEBUG_TARGET_FCB), ("Enter xixcore_DumpFileLot\n")); size = XIDISK_DUP_COMMON_LOT_HEADER_SIZE; xbuf = xixcore_AllocateBuffer(size); if( !xbuf ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_DumpFileLot : can't allocate Xbuf size%d\n", size)); *Reason = XCREASON_BUF_NOT_ALLOCATED; return XCCODE_ENOMEM; } RC = xixcore_RawReadLotHeader(bdev,LotSize,SectorSize, SectorSizeBit, StartIndex, xbuf, Reason); if ( RC < 0 ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_DumpFileLot : call xixcore_RawReadLotHeader\n")); goto exit; } pLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(xbuf); RC = xixcore_CheckLotInfo((PXIDISK_LOT_INFO)&(pLotHeader->LotInfo), VolLotSignature, StartIndex,Type,LOT_FLAG_BEGIN, Reason); if ( RC < 0 ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_DumpFileLot : call xixcore_CheckLotInfo\n")); goto exit; } memset(&AddressInfo, 0, sizeof(XIXCORE_IO_LOT_INFO)); xixcore_GetLotInfo((PXIDISK_LOT_INFO)&(pLotHeader->LotInfo), &AddressInfo); //Debug Print Lot Information while( AddressInfo.NextLotIndex != 0) { memset(&AddressInfo, 0, sizeof(XIXCORE_IO_LOT_INFO)); xixcore_ZeroBufferOffset(xbuf); (void)xixcore_FillBuffer(xbuf, 0); RC = xixcore_RawReadLotHeader(bdev,LotSize,SectorSize, SectorSizeBit, AddressInfo.NextLotIndex, xbuf, Reason); if ( RC < 0 ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_DumpFileLot : call xixcore_RawReadLotHeader\n")); goto exit; } pLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(xbuf); RC = xixcore_CheckLotInfo((PXIDISK_LOT_INFO)&(pLotHeader->LotInfo), VolLotSignature, AddressInfo.NextLotIndex,Type,LOT_FLAG_BODY,Reason); if ( RC < 0 ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_DumpFileLot : call xixcore_CheckLotInfo\n")); goto exit; } memset(&AddressInfo, 0, sizeof(XIXCORE_IO_LOT_INFO)); xixcore_GetLotInfo((PXIDISK_LOT_INFO)&(pLotHeader->LotInfo), &AddressInfo); } DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_DEVCTL|DEBUG_TARGET_FCB), ("Exit xixcore_DumpFileLot\n")); exit: xixcore_FreeBuffer(xbuf); return RC; }
int xixcore_call xixcore_CheckOutLotHeader( PXIXCORE_BLOCK_DEVICE bdev, xc_uint32 VolLotSignature, xc_uint64 LotIndex, xc_uint32 LotSize, xc_uint32 LotType, xc_uint32 LotFlag, xc_uint32 SectorSize, xc_uint32 SectorSizeBit, xc_int32 *Reason ) { int RC = 0; PXIXCORE_BUFFER xbuf = NULL; PXIDISK_COMMON_LOT_HEADER pLotHeader = NULL; PXIDISK_LOT_INFO pLotInfo = NULL; xc_uint32 size = 0; DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_DEVCTL|DEBUG_TARGET_FCB), ("Enter xixcore_CheckOutLotHeader\n")); size = XIDISK_DUP_COMMON_LOT_HEADER_SIZE; xbuf = xixcore_AllocateBuffer(size); if( !xbuf ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_CheckOutLotHeader : can't allocate Xbuf size(%d)\n", size)); *Reason = XCREASON_BUF_NOT_ALLOCATED; return XCCODE_ENOMEM; } (void)xixcore_FillBuffer(xbuf, 0); RC = xixcore_RawReadLotHeader(bdev,LotSize,SectorSize, SectorSizeBit, LotIndex, xbuf,Reason); if ( RC < 0 ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_CheckOutLotHeader : call xixcore_RawReadLotHeader\n")); goto exit; } pLotHeader = (PXIDISK_COMMON_LOT_HEADER)xixcore_GetDataBufferWithOffset(xbuf); pLotInfo = &(pLotHeader->LotInfo); RC = xixcore_CheckLotInfo(pLotInfo,VolLotSignature,LotIndex,LotType,LotFlag,Reason); if ( RC < 0 ) { DebugTrace(DEBUG_LEVEL_ERROR, DEBUG_TARGET_ALL, ("Error xixcore_CheckOutLotHeader : call xixcore_CheckLotInfo\n")); goto exit; } DebugTrace(DEBUG_LEVEL_TRACE, (DEBUG_TARGET_DEVCTL|DEBUG_TARGET_FCB), ("Exit xixcore_CheckOutLotHeader\n")); exit: xixcore_FreeBuffer(xbuf); return RC; }