亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产盗摄一区二区三区| 欧美精品一区二区蜜臀亚洲| 欧美猛男超大videosgay| 久久一区二区视频| 五月婷婷激情综合| 懂色av一区二区夜夜嗨| 欧美一区二区视频在线观看2020| 国产精品污www在线观看| 欧美aaa在线| 欧美日韩午夜在线视频| 亚洲精品国产第一综合99久久 | 韩国精品一区二区| 91久久线看在观草草青青| 国产精品你懂的在线| 国内不卡的二区三区中文字幕| 91福利社在线观看| 亚洲欧洲另类国产综合| 国产精品综合二区| 精品国产乱码久久| 免费观看日韩av| 91精品视频网| 麻豆久久久久久| 日韩一区二区免费电影| 日本不卡不码高清免费观看| 欧美日韩中文字幕精品| 亚洲成人在线免费| 欧美视频第二页| 午夜日韩在线电影| 欧美军同video69gay| 日韩黄色片在线观看| 欧美丰满高潮xxxx喷水动漫| 日本aⅴ亚洲精品中文乱码| 欧美日韩一区二区在线观看 | 中文久久乱码一区二区| 国产69精品一区二区亚洲孕妇| 久久久久久久国产精品影院| 国产高清亚洲一区| 国产精品久久久久久久久动漫| 成人激情免费视频| 亚洲视频免费看| 欧美亚洲综合久久| 青草av.久久免费一区| 精品国产成人系列| 盗摄精品av一区二区三区| 1000精品久久久久久久久| 色综合一区二区| 天堂在线一区二区| 2020国产精品| 91亚洲大成网污www| 亚洲综合网站在线观看| 欧美在线一二三四区| 首页欧美精品中文字幕| 久久久久久久电影| 一本久久精品一区二区| 日韩中文字幕亚洲一区二区va在线| 日韩一级视频免费观看在线| 国产美女视频一区| 亚洲精品欧美综合四区| 日韩欧美一区在线| 粉嫩aⅴ一区二区三区四区五区| 亚洲三级在线免费| 777xxx欧美| 国产精品一二三| 亚洲一区二区三区四区在线| 555夜色666亚洲国产免| 粉嫩av一区二区三区在线播放| 亚洲伦在线观看| 日韩美女一区二区三区四区| www.欧美色图| 免费精品99久久国产综合精品| 欧美激情一区二区在线| 欧美性大战久久| 成人性视频免费网站| 首页国产丝袜综合| 国产精品美女一区二区三区| 7777精品久久久大香线蕉| 成人av网站在线观看| 丝袜诱惑制服诱惑色一区在线观看| 久久久.com| 91精品国产综合久久香蕉麻豆| 国产成人午夜99999| 日本不卡123| 亚洲蜜臀av乱码久久精品蜜桃| 精品理论电影在线| 欧美日韩国产精选| 91免费视频大全| 国产精品123| 精品制服美女久久| 婷婷中文字幕综合| 一区二区三区中文字幕在线观看| 久久九九全国免费| 日韩一级片在线观看| 欧美亚洲综合网| 色94色欧美sute亚洲线路二| 国产成人自拍网| 国产专区欧美精品| 日韩精品乱码av一区二区| 亚洲精品久久7777| 亚洲色图欧洲色图| 中文字幕视频一区| 国产三级一区二区| 亚洲精品一区在线观看| 日韩精品一区二区在线| 91精品国产欧美日韩| 欧美日韩国产精品自在自线| 欧亚一区二区三区| 91成人在线观看喷潮| 色悠悠亚洲一区二区| 97se亚洲国产综合在线| 99热精品国产| 91福利在线免费观看| 色久优优欧美色久优优| 色婷婷av一区二区三区之一色屋| 91年精品国产| 在线日韩国产精品| 91福利视频久久久久| 欧美日韩综合在线免费观看| 欧美日韩一区二区三区高清| 欧美在线观看视频一区二区| 色综合咪咪久久| 欧美日韩一区二区三区高清| 91麻豆精品国产91久久久久| 91精品久久久久久久久99蜜臂| 日韩欧美国产成人一区二区| 久久色在线视频| 国产午夜精品一区二区三区嫩草 | 一区二区成人在线观看| 亚洲午夜在线电影| 日本亚洲视频在线| 国产乱理伦片在线观看夜一区| 成人激情免费电影网址| 91丨porny丨国产入口| 欧美伊人久久久久久久久影院| 欧美一区二区三区视频免费播放| 欧美成人福利视频| 中文字幕国产一区二区| 一区二区三区欧美亚洲| 蜜桃视频免费观看一区| 国产精品91一区二区| 一本色道久久综合狠狠躁的推荐| 欧美日韩二区三区| 国产午夜精品理论片a级大结局| 亚洲丝袜另类动漫二区| 日精品一区二区三区| 国产成人鲁色资源国产91色综| 99精品国产热久久91蜜凸| 6080yy午夜一二三区久久| 国产亚洲欧美在线| 伊人婷婷欧美激情| 激情六月婷婷综合| 91在线看国产| 日韩一区二区精品葵司在线| 中文字幕精品—区二区四季| 午夜精品视频在线观看| 国产成人在线视频网址| 精品视频1区2区| 久久蜜桃av一区精品变态类天堂| 亚洲欧美国产高清| 精久久久久久久久久久| 欧美在线一区二区| 亚洲国产精品99久久久久久久久| 婷婷六月综合亚洲| 91在线小视频| 久久一夜天堂av一区二区三区| 亚洲一区二区成人在线观看| 成人性生交大片免费看视频在线| 欧美精品一二三四| 中文字幕一区二区三区在线观看| 麻豆国产欧美日韩综合精品二区| 色综合一区二区三区| 久久久影视传媒| 蜜臀av国产精品久久久久| 日本乱人伦一区| 综合久久给合久久狠狠狠97色| 国产乱子轮精品视频| 欧美一三区三区四区免费在线看| 亚洲欧美区自拍先锋| 国产成人激情av| 精品日产卡一卡二卡麻豆| 午夜精品福利久久久| 色婷婷久久久综合中文字幕| 国产精品视频一二三区 | va亚洲va日韩不卡在线观看| 欧美草草影院在线视频| 日韩电影在线观看网站| 欧美中文字幕一区二区三区亚洲| 国产精品黄色在线观看| 国产91精品一区二区麻豆亚洲| 精品久久久久久久久久久院品网| 五月婷婷色综合| 欧美三级视频在线观看| 亚洲午夜久久久久久久久电影院| 色婷婷激情一区二区三区| 中文字幕亚洲电影| 91亚洲男人天堂| 一区二区三区四区亚洲| 在线精品国精品国产尤物884a| 一区二区三区毛片| 欧美色视频一区| 奇米精品一区二区三区在线观看|