void fmt_copy_hdlr(local_para_struct *local_para_ptr, peer_buff_struct *peer_buff_ptr) { mmi_fmt_copy_req_strcut *msg_ptr; mmi_fmt_copy_rsp_strcut param_ptr; S32 fs_ret; msg_ptr = (mmi_fmt_copy_req_strcut *)local_para_ptr; if (msg_ptr->action == FMT_COPY) { fs_ret = FS_Move((WCHAR *)msg_ptr->src_file, (WCHAR *)msg_ptr->dest_file, FS_MOVE_COPY, NULL); } else { fs_ret = FS_Move((WCHAR *)msg_ptr->src_file, (WCHAR *)msg_ptr->dest_file, FS_MOVE_KILL, NULL); } param_ptr.result = fs_ret; fmgr_copy_rsp_hdlr(¶m_ptr); return; }
static void handle_file_content(msf_sas_handle_t* handle, msf_sas_op_t *op) { int ret; kal_uint8 *src; if(!op->pathname) { msf_sas_create_error_dialog (handle, op, MSF_WIDGET_STRING_GET_PREDEFINED(BRA_STR_ID_SAVE_AS_FAIL)); op->state = MSF_SAS_STATE_MESSAGE_WAIT; return; } src = HDI_FileNameTranslate(op->pathname); if(handle->modid == MSF_MODID_MEA || handle->modid == MSF_MODID_SMA) { HDIa_widgetExtDisplayTransitionAnimationNoEnd(KAL_TRUE); } else { HDIa_widgetExtDisplayTransitionAnimationNoEnd(KAL_FALSE); } ret = FS_Move((const WCHAR *)src, (const WCHAR *)op->file_name, FS_MOVE_COPY | FS_MOVE_OVERWRITE, 0, NULL, 0); HDI_FileNameFree(src); if (ret != FS_NO_ERROR) { if(ret == FS_ROOT_DIR_FULL || ret == FS_DISK_FULL) { HDIa_widgetExtShowPopup( handle->modid, HDIa_widgetStringGetPredefined(MSF_STR_ID_SAS_ERROR_FULL), MsfError, 0); } else { HDIa_widgetExtShowPopup( handle->modid, HDIa_widgetStringGetPredefined(BRA_STR_ID_SAVE_AS_FAIL), MsfError, 0); } op->status = MSF_SAS_RETURN_ERROR; op->state = MSF_SAS_STATE_FINISHED; } else { op->status = MSF_SAS_RETURN_OK; op->state = MSF_SAS_STATE_FINISHED; } return; }
void FFS_Ioctl(struct IPCMessage *msg) { FIL fil; u8 *bufin = (u8*)msg->ioctl.buffer_in; u32 lenin = msg->ioctl.length_in; u8 *bufout = (u8*)msg->ioctl.buffer_io; u32 lenout = msg->ioctl.length_io; s32 ret; //if( ((((vu32)bufin>>24)==0)&&lenin) || ((((vu32)bufout>>24)==0)&&lenout) ) //{ // dbgprintf("FFS:in:0x%p\tout:0x%p\n", bufin, bufout ); //} #ifdef EDEBUG dbgprintf("FFS:IOS_Ioctl( %d 0x%x 0x%p 0x%x 0x%p 0x%x )\n", msg->fd, msg->ioctl.command, bufin, lenin, bufout, lenout); #endif ret = FS_SUCCESS; switch(msg->ioctl.command) { case IOCTL_IS_USB: { ret = FS_SUCCESS; } break; case IOCTL_NANDSTATS: { if( lenout < 0x1C ) ret = -1017; else { NANDStat fs; //TODO: get real stats from SD CARD? fs.BlockSize = 0x4000; fs.FreeBlocks = 0x5DEC; fs.UsedBlocks = 0x1DD4; fs.unk3 = 0x10; fs.unk4 = 0x02F0; fs.Free_INodes = 0x146B; fs.unk5 = 0x0394; memcpy( bufout, &fs, sizeof(NANDStat) ); } ret = FS_SUCCESS; #ifdef DEBUG dbgprintf("FFS:GetNANDStats( %d, %p ):%d\n", msg->fd, msg->ioctl.buffer_io, ret ); #endif } break; case IOCTL_CREATEDIR: { ret = FS_CreateDir( (char*)(bufin+6) ); #ifdef USEATTR if( ret == FS_SUCCESS ) { //create attribute file char *path = (char*)heap_alloc_aligned( 0, 0x40, 32 ); _sprintf( path, "%s.attr", (char*)(bufin+6) ); if( f_open( &fil, path, FA_CREATE_ALWAYS | FA_WRITE ) == FR_OK ) { u32 wrote; f_lseek( &fil, 6 ); f_write( &fil, bufin+0x46, 4, &wrote); f_close( &fil ); } heap_free( 0, path ); } #endif #ifdef DEBUG dbgprintf("FFS:CreateDir(\"%s\", %02X, %02X, %02X, %02X ):%d\n", (char*)(bufin+6), *(u8*)(bufin+0x46), *(u8*)(bufin+0x47), *(u8*)(bufin+0x48), *(u8*)(bufin+0x49), ret ); #endif } break; case IOCTL_SETATTR: { if( lenin != 0x4A && lenin != 0x4C ) { ret = FS_EFATAL; } else { ret = FS_SetAttr( (char*)(bufin+6) ); } #ifdef USEATTR if( ret == FS_SUCCESS ) { //create attribute file char *path = (char*)heap_alloc_aligned( 0, 0x40, 32 ); _sprintf( path, "%s.attr", (char*)(bufin+6) ); if( f_open( &fil, (char*)path, FA_CREATE_ALWAYS | FA_WRITE ) == FR_OK ) { u32 wrote; if( lenin == 0x4A ) f_write( &fil, bufin, 4+2, &wrote); else f_lseek( &fil, 6 ); f_write( &fil, bufin+0x46, 4, &wrote); f_close( &fil ); } heap_free( 0, path ); } #endif #ifdef DEBUG dbgprintf("FFS:SetAttr(\"%s\", %08X, %04X, %02X, %02X, %02X, %02X):%d in:%X out:%X\n", (char*)(bufin+6), *(u32*)(bufin), *(u16*)(bufin+4), *(u8*)(bufin+0x46), *(u8*)(bufin+0x47), *(u8*)(bufin+0x48), *(u8*)(bufin+0x49), ret, lenin, lenout ); #endif } break; case IOCTL_GETATTR: { char *s=NULL; switch( lenin ) { case 0x40: s = (char*)(bufin); ret= FS_SUCCESS; break; case 0x4A: hexdump( bufin, lenin ); s = (char*)(bufin+6); ret= FS_SUCCESS; break; default: hexdump( bufin, lenin ); ret = FS_EFATAL; break; } if( ret != FS_EFATAL ) { if( f_open( &fil, s, FA_READ ) == FR_OK ) { f_close( &fil ); ret = FS_SUCCESS; } else { DIR d; if( f_opendir( &d, s ) == FR_OK ) { ret = FS_SUCCESS; } else { ret = FS_ENOENT2; } } #ifdef USEATTR //read attribute file char *path = (char*)heap_alloc_aligned( 0, 0x40, 32 ); _sprintf( path, "%s.attr", s ); if( f_open( &fil, path, FA_OPEN_EXISTING | FA_READ ) == FR_OK ) { u32 read; f_read( &fil, bufout, 4+2, &read); f_read( &fil, bufout+0x46, 4, &read); f_close( &fil ); } heap_free( 0, path ); #else *(u32*)(bufout) = 0x0000; *(u16*)(bufout) = 0x1000; *(u8*)(bufout+0x46) = 3; *(u8*)(bufout+0x47) = 3; *(u8*)(bufout+0x48) = 3; *(u8*)(bufout+0x49) = 3; #endif } #ifdef DEBUG dbgprintf("FFS:GetAttr(\"%s\", %02X, %02X, %02X, %02X ):%d in:%X out:%X\n", s, *(u8*)(bufout+0x46), *(u8*)(bufout+0x47), *(u8*)(bufout+0x48), *(u8*)(bufout+0x49), ret, lenin, lenout ); #endif } break; case IOCTL_DELETE: { ret = FS_DeleteFile( (char*)bufin ) ; #ifdef DEBUG dbgprintf("FFS:Delete(\"%s\"):%d\n", (char*)bufin, ret ); #endif } break; case IOCTL_RENAME: { ret = FS_Move( (char*)bufin, (char*)(bufin + 0x40) ); #ifdef USEATTR if( ret == FS_SUCCESS ) { //move attribute file char *src = (char*)heap_alloc_aligned( 0, 0x80, 32 ); char *dst = (char*)heap_alloc_aligned( 0, 0x80, 32 ); _sprintf( src, "%s.attr", (char*)bufin ); _sprintf( dst, "%s.attr", (char*)(bufin + 0x40) ); ret = FS_Move( src, dst ); //dbgprintf("FFS:Rename(\"%s\", \"%s\"):%d\n", src, dst, ret ); heap_free( 0, src ); heap_free( 0, dst ); } #endif #ifdef DEBUG dbgprintf("FFS:Rename(\"%s\", \"%s\"):%d\n", (char*)bufin, (char*)(bufin + 0x40), ret ); #endif } break; case IOCTL_CREATEFILE: { ret = FS_CreateFile( (char*)(bufin+6) ); #ifdef USEATTR if( ret == FS_SUCCESS ) { //create attribute file char *path = (char*)heap_alloc_aligned( 0, 0x40, 32 ); _sprintf( path, "%s.attr", (char*)(bufin+6) ); if( f_open( &fil, path, FA_CREATE_ALWAYS | FA_WRITE ) == FR_OK ) { u32 wrote; if( lenin == 0x4A ) f_write( &fil, bufin, 4+2, &wrote); else f_lseek( &fil, 6 ); f_write( &fil, bufin+0x46, 4, &wrote); f_close( &fil ); } heap_free( 0, path ); } #endif #ifdef DEBUG //if( ret != -105 ) dbgprintf("FFS:CreateFile(\"%s\", %02X, %02X, %02X, %02X):%d\n", (char*)(bufin+6), *(u8*)(bufin+0x46), *(u8*)(bufin+0x47), *(u8*)(bufin+0x48), *(u8*)(bufin+0x49), ret ); #endif } break; case IOCTL_GETSTATS: { ret = FS_GetStats( msg->fd, (FDStat*)bufout ); #ifdef DEBUG dbgprintf("FFS:GetStats( %d, %d, %d ):%d\n", msg->fd, ((FDStat*)bufout)->file_length, ((FDStat*)bufout)->file_length, ret ); #endif } break; case IOCTL_SHUTDOWN: //dbgprintf("FFS:Shutdown()\n"); //Close all open FS handles //u32 i; //for( i=0; i < MAX_FILE; ++i) //{ // if( fd_stack[i].fs != NULL ) // f_close( &fd_stack[i] ); //} ret = FS_SUCCESS; break; default: #ifdef EDEBUG dbgprintf("FFS:Unknown IOS_Ioctl( %d 0x%x 0x%p 0x%x 0x%p 0x%x )\n", msg->fd, msg->ioctl.command, bufin, lenin, bufout, lenout); #endif ret = FS_EFATAL; break; } #ifdef EDEBUG dbgprintf("FFS:IOS_Ioctl():%d\n", ret); #endif mqueue_ack( (void *)msg, ret); }