亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fs.c

?? 基于lpc2148(arm7)的wav音樂格式播放器的設計
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*****************************************************************************\
*              efs - General purpose Embedded Filesystem library              *
*          --------------------- -----------------------------------          *
*                                                                             *
* Filename : fs.c                                                             *
* Description : These are general filesystem functions, supported by the      *
*               functions of dir.c and fat.c  file.c uses these functions     *
*               heavily, but is not used by fs.c (not true anymore)           *
*                                                                             *
* This program is free software; you can redistribute it and/or               *
* modify it under the terms of the GNU General Public License                 *
* as published by the Free Software Foundation; version 2                     *
* of the License.                                                             *
*                                                                              *
* This program is distributed in the hope that it will be useful,             *
* but WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
* GNU General Public License for more details.                                *
*                                                                             *
* As a special exception, if other files instantiate templates or             *
* use macros or inline functions from this file, or you compile this          *
* file and link it with other works to produce a work based on this file,     *
* this file does not by itself cause the resulting work to be covered         *
* by the GNU General Public License. However the source code for this         *
* file must still be made available in accordance with section (3) of         *
* the GNU General Public License.                                             *
*                                                                             *
* This exception does not invalidate any other reasons why a work based       *
* on this file might be covered by the GNU General Public License.            *
*                                                                             *
*                                                    (c)2006 Lennart Yseboodt *
*                                                    (c)2006 Michael De Nil   *
\*****************************************************************************/

/*****************************************************************************/
#include "fs.h"
#include "fat.h"
#include "dir.h"
/*****************************************************************************/

/* ****************************************************************************  
 * eint16 fs_initFs(FileSystem *fs,Partition *part)
 * Description: This functions glues the initialisation of the filesystem together.
 * It loads the volumeID, computes the FS type and searches for the rootsector.
 * Return value: Returns 0 on succes and -1 on error (if magic code is wrong)
*/
eint16 fs_initFs(FileSystem *fs,Partition *part)
{
	if(!fs_isValidFat(part)){
		return(-1);
	}
	fs->part=part;
	fs_loadVolumeId(fs,part);
	if(!fs_verifySanity(fs))return(-2);
  	fs_countDataSectors(fs);
	fs_determineFatType(fs);
	fs_findFirstSectorRootDir(fs);
	fs_initCurrentDir(fs); 
	return(0);
}
/*****************************************************************************/ 

/* ****************************************************************************  
 * eint16 fs_isValidFat(Partition *part)
 * Description: This functions loads the volumeID and checks if the magic
 * value is present.
 * Return value: returns 0 when magic code is missing, 1 if it is there.
*/
eint16 fs_isValidFat(Partition *part)
{
	euint8 *buf;
	
	buf=part_getSect(part,0,IOM_MODE_READONLY|IOM_MODE_EXP_REQ); /* Load Volume label */
	if( ex_getb16(buf,0x1FE) != 0xAA55 ){
		return (0);
	}
	part_relSect(part,buf);
	return(1);
}
/*****************************************************************************/ 

/* ****************************************************************************  
 * void fs_loadVolumeId(FileSystem *fs, Partition *part)
 * Description: This function loads all relevant fields from the volumeid.
*/
void fs_loadVolumeId(FileSystem *fs, Partition *part)
{
	euint8 *buf;
	
	buf=part_getSect(part,0,IOM_MODE_READONLY|IOM_MODE_EXP_REQ);
	
	fs->volumeId.BytesPerSector=ex_getb16(buf,0x0B);
	fs->volumeId.SectorsPerCluster=*((eint8*)(buf+0x0D));
	fs->volumeId.ReservedSectorCount=ex_getb16(buf,0x0E);
	fs->volumeId.NumberOfFats=*((eint8*)(buf+0x10));
	fs->volumeId.RootEntryCount=ex_getb16(buf,0x11);
	fs->volumeId.SectorCount16=ex_getb16(buf,0x13);
	fs->volumeId.FatSectorCount16=ex_getb16(buf,0x16);
	fs->volumeId.SectorCount32=ex_getb32(buf,0x20);
	fs->volumeId.FatSectorCount32=ex_getb32(buf,0x24);
	fs->volumeId.RootCluster=ex_getb32(buf,0x2C);
	
	part_relSect(part,buf);
	
}
/*****************************************************************************/ 

/* ****************************************************************************  
 * esint16 fs_verifySanity(FileSystem *fs)
 * Description: Does some sanity calculations.
 * Return value: 1 on success, 0 when discrepancies were found.
*/
esint16 fs_verifySanity(FileSystem *fs)
{
	esint16 sane=1; /* Sane until proven otherwise */
	/* First check, BPS, we only support 512 */
	if(fs->volumeId.BytesPerSector!=512)sane=0;
	/* Check is SPC is valid (multiple of 2, and clustersize >=32KB */
	if(!((fs->volumeId.SectorsPerCluster == 1 ) |
	     (fs->volumeId.SectorsPerCluster == 2 ) |
	     (fs->volumeId.SectorsPerCluster == 4 ) |
	     (fs->volumeId.SectorsPerCluster == 8 ) |
	     (fs->volumeId.SectorsPerCluster == 16) |
	     (fs->volumeId.SectorsPerCluster == 32) |
	     (fs->volumeId.SectorsPerCluster == 64) ))sane=0;
	/* Any number of FAT's should be supported... (untested) */
	/* There should be at least 1 reserved sector */
	if(fs->volumeId.ReservedSectorCount==0)sane=0;
	if(fs->volumeId.FatSectorCount16 != 0){
		if(fs->volumeId.FatSectorCount16 > fs->part->disc->partitions[fs->part->activePartition].numSectors)sane=0;
	}else{
		if(fs->volumeId.FatSectorCount32 > fs->part->disc->partitions[fs->part->activePartition].numSectors)sane=0;
	} 
	return(sane);
}
/*****************************************************************************/

/* ****************************************************************************  
 * void fs_countDataSectors(FileSystem *fs)
 * Description: This functions calculates the sectorcounts, fatsectorcounts and
 * dataclustercounts. It fills in the general fields.
*/
void fs_countDataSectors(FileSystem *fs)
{
  euint32 rootDirSectors,dataSectorCount;

  rootDirSectors=((fs->volumeId.RootEntryCount*32) +
                 (fs->volumeId.BytesPerSector - 1)) /
                 fs->volumeId.BytesPerSector;

  if(fs->volumeId.FatSectorCount16 != 0)
  {
    fs->FatSectorCount=fs->volumeId.FatSectorCount16;
    fs->volumeId.FatSectorCount32=0;
  }
  else
  {
    fs->FatSectorCount=fs->volumeId.FatSectorCount32;
    fs->volumeId.FatSectorCount16=0;
  }

  if(fs->volumeId.SectorCount16!=0)
  {
    fs->SectorCount=fs->volumeId.SectorCount16;
    fs->volumeId.SectorCount32=0;
  }
  else
  {
    fs->SectorCount=fs->volumeId.SectorCount32;
    fs->volumeId.SectorCount16=0;
  }

  dataSectorCount=fs->SectorCount - (
                  fs->volumeId.ReservedSectorCount +
                  (fs->volumeId.NumberOfFats * fs->FatSectorCount) +
                  rootDirSectors);

  fs->DataClusterCount=dataSectorCount/fs->volumeId.SectorsPerCluster;
}
/*****************************************************************************/ 

/* ****************************************************************************  
 * void fs_determineFatType(FileSystem *fs)
 * Description: This function looks af the Dataclustercount and determines the
 * FAT type. It fills in fs->type.
*/
void fs_determineFatType(FileSystem *fs)
{
	if(fs->DataClusterCount < 4085)
	{
		fs->type=FAT12;
		fs->volumeId.RootCluster=0;
	}
	else if(fs->DataClusterCount < 65525)
	{
		fs->type=FAT16;
		fs->volumeId.RootCluster=0;
	}
	else
	{
		fs->type=FAT32;
	}
}
/*****************************************************************************/ 

/* ****************************************************************************  
 * void fs_findFirstSectorRootDir(FileSystem *fs)
 * Description: This functions fills in the fs->FirstSectorRootDir field, even
 * for FAT32, although that is not necessary (because you have FirstClusterRootDir).
*/
void fs_findFirstSectorRootDir(FileSystem *fs)
{
	if(fs->type==FAT32)
		fs->FirstSectorRootDir = fs->volumeId.ReservedSectorCount + 
		                         (fs->volumeId.NumberOfFats*fs->volumeId.FatSectorCount32) +
								 (fs->volumeId.RootCluster-2)*fs->volumeId.SectorsPerCluster;
	else
		fs->FirstSectorRootDir = fs->volumeId.ReservedSectorCount + 
		                         (fs->volumeId.NumberOfFats*fs->volumeId.FatSectorCount16);
}
/*****************************************************************************/ 

void fs_initCurrentDir(FileSystem *fs)
{
	fs->FirstClusterCurrentDir = fs_getFirstClusterRootDir(fs);
}
/*****************************************************************************/

/* ****************************************************************************  
 * long fs_clusterToSector(FileSystem *fs,euint32 cluster)
 * Description: This function converts a clusternumber in the effective sector
 * number where this cluster starts. Boundary check is not implemented
 * Return value: A long is returned representing the sectornumber.
*/
euint32 fs_clusterToSector(FileSystem *fs,euint32 cluster)
{
	eint32 base;
	
	if(fs->type==FAT32)
	{
		base=
			fs->volumeId.ReservedSectorCount+
			fs->FatSectorCount*fs->volumeId.NumberOfFats;
	}
	else
	{
		base=
			fs->volumeId.ReservedSectorCount+
			fs->FatSectorCount*fs->volumeId.NumberOfFats+
			fs->volumeId.RootEntryCount/16;
	}
	return( base + (cluster-2)*fs->volumeId.SectorsPerCluster );
}
/*****************************************************************************/ 

/* Function is unused, but may be usefull */
euint32 fs_sectorToCluster(FileSystem *fs,euint32 sector)
{
	eint32 base;
	
	if(fs->type==FAT32)
	{
		base=
			fs->volumeId.ReservedSectorCount+
			fs->FatSectorCount*fs->volumeId.NumberOfFats;
	}
	else
	{
		base=
			fs->volumeId.ReservedSectorCount+
			fs->FatSectorCount*fs->volumeId.NumberOfFats+
			fs->volumeId.RootEntryCount/16;
	}
	return(((sector-base)-((sector-base)%fs->volumeId.SectorsPerCluster))/fs->volumeId.SectorsPerCluster+2 );
}
/*****************************************************************************/

/* ****************************************************************************  
 * euint32 fs_getNextFreeCluster(FileSystem *fs,euint32 startingcluster)
 * Description: This functions searches for a free cluster, starting it's search at
 * cluster startingcluster. This allow to speed up searches and try to avoid 
 * fragmentation. Implementing rollover search is still to be done.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区二区三区高清| 精品国产一区a| 日韩一区二区三区av| 久久综合九色综合97婷婷女人| 欧美激情一区不卡| 午夜电影久久久| 高清不卡一区二区| 欧美日韩免费电影| 国产亚洲成av人在线观看导航| 亚洲男帅同性gay1069| 蜜臀av一级做a爰片久久| 成人av免费网站| 日韩免费看的电影| 一区二区三区四区不卡在线| 国产成人av资源| 本田岬高潮一区二区三区| 精品国产123| 日韩福利电影在线| 不卡av在线免费观看| 欧美老肥妇做.爰bbww| 日韩欧美国产wwwww| 亚洲午夜视频在线观看| 粉嫩高潮美女一区二区三区 | 99久久亚洲一区二区三区青草| 欧美日韩久久一区| 中文字幕一区在线观看| 一区二区三区在线免费播放| 国产福利一区二区三区视频在线 | 日本韩国视频一区二区| 久久综合九色综合97婷婷女人| 亚洲高清在线精品| 不卡视频在线看| 日韩欧美三级在线| 夜夜嗨av一区二区三区网页 | 天天影视网天天综合色在线播放| 成人a区在线观看| 国产香蕉久久精品综合网| 麻豆精品视频在线| 制服丝袜亚洲精品中文字幕| 亚洲自拍与偷拍| 91麻豆123| 亚洲视频免费看| 成人午夜看片网址| 欧美激情艳妇裸体舞| 国产一区视频导航| 日韩欧美黄色影院| 视频在线观看91| 91精品国产综合久久小美女| 亚洲h在线观看| 欧美色视频一区| 日韩高清不卡一区二区| 欧美一区2区视频在线观看| 免费看欧美女人艹b| 欧美一级午夜免费电影| 蜜芽一区二区三区| 亚洲精品一区在线观看| 国产98色在线|日韩| 国产精品免费人成网站| 97超碰欧美中文字幕| 亚洲欧美区自拍先锋| 欧美在线观看视频一区二区 | 久久国产麻豆精品| 精品三级av在线| 国产精品综合二区| 国产精品国产三级国产有无不卡| 色婷婷综合久久久| 日韩成人伦理电影在线观看| 精品国产一区二区三区忘忧草| 国产成人亚洲综合a∨婷婷| 中文字幕在线不卡国产视频| 在线观看日韩av先锋影音电影院| 婷婷成人综合网| 久久久噜噜噜久久中文字幕色伊伊| 成人午夜av在线| 亚洲激情一二三区| 91.麻豆视频| 国产精品中文欧美| 国产精品网站一区| 91同城在线观看| 亚洲午夜羞羞片| 久久婷婷色综合| 99精品一区二区三区| 日本中文字幕一区二区视频| 久久久久九九视频| 欧美日韩综合不卡| 国产福利一区二区三区在线视频| 亚洲欧美日韩电影| 久久久久一区二区三区四区| 欧美午夜免费电影| 国产一区二区不卡| 亚洲一区成人在线| 日韩欧美一卡二卡| 99国产精品久久久久久久久久久| 亚洲 欧美综合在线网络| 日本一区二区电影| 欧美精品日韩精品| 色综合咪咪久久| 国产乱码一区二区三区| 亚洲成人av中文| 中文字幕制服丝袜成人av| 欧美一区二区精品久久911| 99国内精品久久| 国产丶欧美丶日本不卡视频| 午夜久久电影网| 一区二区在线观看视频| 久久精品在这里| 日韩欧美亚洲另类制服综合在线 | 久久99这里只有精品| 亚洲视频狠狠干| 日韩免费观看高清完整版 | 成人黄色在线网站| 久久99久久99| 午夜精品久久久久久久久| 最近中文字幕一区二区三区| 久久欧美一区二区| 日韩视频国产视频| 在线中文字幕一区二区| 国产一区二区三区日韩| 天天色天天操综合| 亚洲电影在线播放| 一区二区三区在线观看欧美| 国产精品久久久一本精品 | 91在线视频播放| 国产精品一区二区在线观看不卡 | 欧洲av一区二区嗯嗯嗯啊| 成人不卡免费av| 不卡视频免费播放| 懂色av一区二区三区免费观看 | 久久精品国产网站| 秋霞成人午夜伦在线观看| 石原莉奈在线亚洲三区| 午夜精品在线看| 免费成人性网站| 九九视频精品免费| 国产乱码精品一区二区三区五月婷| 男人的j进女人的j一区| 麻豆精品一区二区三区| 国产一区二区精品久久| 精品综合久久久久久8888| 免费一级片91| 国产一区二区三区不卡在线观看 | 欧美男男青年gay1069videost| 91精彩视频在线| 5月丁香婷婷综合| 欧美影院一区二区| 欧美日韩国产一区二区三区地区| 欧美日韩亚洲另类| 欧美一个色资源| 国产亚洲欧洲997久久综合| 国产精品热久久久久夜色精品三区 | 欧美专区日韩专区| 日韩美女主播在线视频一区二区三区| 久久久精品国产免费观看同学| 亚洲美女免费在线| 国产一区二区在线观看视频| 一本色道久久加勒比精品| 欧美成人伊人久久综合网| 亚洲女厕所小便bbb| 九九精品一区二区| 欧美中文字幕一区二区三区亚洲| 久久久久免费观看| 天天综合日日夜夜精品| 91视频www| 国产亚洲精品7777| 蜜桃视频一区二区| 欧美色图激情小说| 一色桃子久久精品亚洲| 久久精工是国产品牌吗| 色综合久久久久久久久久久| 久久综合国产精品| 丝袜美腿亚洲一区| 91老师片黄在线观看| 国产三级精品三级| 韩国av一区二区三区在线观看| 91黄色激情网站| 中文字幕一区二区日韩精品绯色| 美女久久久精品| 欧美精品日日鲁夜夜添| 亚洲精品久久7777| 91社区在线播放| 国产精品天美传媒沈樵| 国内精品伊人久久久久av影院| 欧美二区三区91| 亚洲午夜视频在线观看| 日本韩国精品一区二区在线观看| 国产欧美日韩另类视频免费观看| 狠狠色狠狠色综合| 日韩亚洲欧美高清| 日本女人一区二区三区| 9191成人精品久久| 日韩av一区二区三区四区| 欧美日韩一本到| 天堂在线一区二区| 7777精品伊人久久久大香线蕉的 | 成人av在线观| 中文天堂在线一区| 成av人片一区二区| 日韩一区欧美小说| 色综合久久中文字幕综合网| 亚洲欧美日韩国产另类专区|