void create_fs ( ){ /*进入此函数证明当前硬盘无任何操作系统,需要初始化superBlock,扇区位图,文件分配表*/ /*superBlock*/ memcpy8("TINY",superBlock.sign,5);/*文件系统标识*/ superBlock.n_sects=hd_info.sectorNum; superBlock.n_inode=MAX_FILE; /*扇区位图,注:前32个扇区存储文件系统的信息,一定处于使用状态*/ int i; for(i=0;i<DATA_START;i++) mask1(i); for(i=DATA_START;i<superBlock.n_sects;i++) mask0(i); /*文件分配表,初始时全部无效化*/ fat.size=0; for(i=0;i<MAX_FILE;i++) fat.i_node_arr[i].status=I_NODE_INVALID; /*将信息全部写入硬盘*/ u_int8 buf[512]; /*写superBlock*/ memcpy8((u_int8*)&superBlock,buf,SUPERBLOCK_SIZE); while(write_sector(SUPERBLOCK_START,buf)==FALSE); /*写位图*/ u_int32 bmp_sect=((superBlock.n_sects%4096)==0)?(superBlock.n_sects/4096):(superBlock.n_sects/4096+1); u_int32 pos=0; for(i=HD_BMP_START;i<HD_BMP_START+bmp_sect;i++,pos+=512) while(write_sector(i,hd_bmp+pos)==FALSE); /*写文件分配表*/ pos=0; for(i=FAT_START;i<FAT_START+MAX_FAT;i++,pos+=512) while(write_sector(i,((u_int8*)&fat+pos))==FALSE); }
bool dgDynamicBody::IsInEquilibrium () const { if (m_equilibrium) { dgVector forceError (m_accel - m_prevExternalForce); dgVector torqueError (m_alpha - m_prevExternalTorque); dgVector mask0 ((forceError.DotProduct4(forceError) < m_equilibriumError2) & (torqueError.DotProduct4(torqueError) < m_equilibriumError2)); if (mask0.GetSignMask()) { dgVector invMassMag2 (m_invMass[3] * m_invMass[3]); dgVector mask1 ((invMassMag2.CompProduct4 (m_netForce.DotProduct4(m_netForce)) < m_equilibriumError2) & (invMassMag2.CompProduct4 (m_netTorque.DotProduct4(m_netTorque)) < m_equilibriumError2)); if (mask1.GetSignMask()) { dgVector mask2 ((m_veloc.DotProduct4(m_veloc) < m_equilibriumError2) & (m_omega.DotProduct4(m_omega) < m_equilibriumError2)); return mask2.GetSignMask() ? true : false; } } } return false; }
u_int32 delete_file ( u_int32 handle ,u_int32 send_pid ){ /*patch:判断权限*/ /*清除文件分配表表项*/ int i; u_int32 start=fat.i_node_arr[handle].startSector; u_int32 n_sects=fat.i_node_arr[handle].sectorNum; fat.i_node_arr[handle].byte_size=0; fat.i_node_arr[handle].startSector=0; fat.i_node_arr[handle].sectorNum=0; fat.i_node_arr[handle].status=I_NODE_INVALID; fat.size--; for(i=0;i<MAX_FILE_NAME;i++) fat.i_node_arr[handle].file_name[i]='\0'; for(i=start;i<start+n_sects;i++) mask0(i); return TRUE; }