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

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

?? fat.c

?? fat16文件系統源碼。需要的請下
?? C
?? 第 1 頁 / 共 3 頁
字號:


#include "datatype.h"
#include "file.h"          /* file function definition */
#include "fat.h" 
#include "hard.h"
                           /* fat file-system definition */



extern  Uchar   reserved_disk_space;
extern  Byte    gl_buffer[];
extern  Byte    fat_buf_sector[];  /* 512 bytes buffer */
extern  Uint32  total_capacity;
extern  char    lfn_name[]; /* long filename limited to MAX_FILENAME_LEN chars */
extern  char    song_name[];

/* disk management */
extern  Uint32  fat_ptr_fats;         /* address of the first byte of FAT */
extern  Uint32  fat_ptr_rdir;         /* address of the first byte of root dir */
extern  Uint32  fat_ptr_data;         /* address of the first byte of data */
extern  Byte    fat_cluster_size;     /* cluster size (sector count) */
extern  Byte    fat_cluster_mask;     /* mask for end of cluster test */
extern  Uchar   dir_is_root;          /* TRUE: point the root directory  */
extern  Uchar   fat_is_fat16;         /* TRUE: FAT16 - FALSE: FAT12 */
extern  Uchar   fat_is_fat32;         /* TRUE: FAT32 - FALSE: FAT12/FAT16 */
extern  Uchar   fat_open_mode;        /* READ or WRITE */
extern  Uchar   fat_2_is_present;     /* TRUE: 2 FATs - FALSE: 1 FAT */
extern  Uchar   flag_end_disk_file;
extern  Uint32  fat_count_of_clusters;/* number of cluster - 2 */
extern  Uint16  fat_root_entry;       /* position in root dir */
extern  Union32 fat_file_size;
extern  Uint16  fat_fat_size;         /* FAT size in sector count */
extern  Uint32  fat_nb_sector;

/* directory management */
extern   Uint32  fat_dir_current_sect; /* sector of selected entry in dir list */
extern   Uint16  fat_dir_list_index;   /* index of current entry in dir list */
extern   Uint16  fat_dir_list_last;    /* index of last entry in dir list */
extern   Uint16  fat_dclust_byte_count;/* byte counter in directory sector */
extern   Uint16  fat_dchain_index;     /* the number of the fragment of the dir, in fact*/
                                       /* the index of the table in the cluster chain */
extern   Byte    fat_dchain_nb_clust;  /* the offset of the cluster from the first cluster*/
                                       /* of the dir fragment */
extern   Uint32  fat_dir_start_sect;   /* start sector of dir list */
extern   Uint16  fat_dir_current_offs; /* entry offset from fat_dir_current_sect */
extern   Byte    fat_last_dclust_index;/* index of the last cluster in directory chain */
extern   fat_st_cache   fat_cache;     /* The cache structure, see the .h for more info */
extern   fat_st_clust_chain dclusters[MAX_DIR_FRAGMENT_NUMBER];
                                       /* cluster chain for the current directory */
extern   char  ext[3];                 /* file extension (limited to 3 characters) */
extern   Byte  fat_dir_entry_list[512];
//#define  fat_dir_entry_list  fat_buf_sector  /* manual variable overlay */

/* file management */
extern   Uint16  fat_fclust_byte_count;/* byte counter in file cluster */
extern   Byte    fat_last_clust_index; /* index of the last cluster in file chain */
extern   Byte    fat_fchain_index;     /* the number of the fragment of the file, in fact*/
                                       /*the index of the table in the cluster chain */
extern   Uint16  fat_fchain_nb_clust;  /* the offset of the cluster from the first cluster*/
                                       /*of the file fragment */
extern   fat_st_clust_chain fclusters[MAX_FILE_FRAGMENT_NUMBER];
                                       /* cluster chain for the current file */
/* Mode repeat A/B variables */
extern   Byte    fat_fchain_index_save;         
extern   Byte    fat_fchain_nb_clust_save;
extern   Uint16  fat_fclust_byte_count_save;
extern   Uint32  fat_bpb_add;
extern   fat_st_free_space free_space;


//----------------------------------------------------------------------------
INT32U fat_caculate_offset(INT8U data0, INT8U data1, INT8U data2, INT8U data3)
{
    INT32U u32Temp0;
    INT32U u32Temp1;
    INT32U u32Temp2;
    INT32U u32Temp3;
 
    u32Temp0 = data0;
    u32Temp1 = data1;
    u32Temp2 = data2;
    u32Temp3 = data3;
    
    u32Temp1 <<= 8;
    u32Temp2 <<= 16;
    u32Temp3 <<= 24;    
    return(u32Temp0 + u32Temp1 + u32Temp2 + u32Temp3);
}


/*F**************************************************************************
* NAME: fat_load_sector
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   This function load a sector in fat_buf_sector
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*   
*****************************************************************************/
INT8U fat_load_sector(Uint32 sector)
{
  Uint16 i;
  
  if(Hard_read_open(sector) == OK)
  {
    for (i = 0; i < (SECTOR_SIZE); i++)
    {
      fat_buf_sector[i] = gl_buffer[i];
    }
    return OK;
  }
  else
  {
    return KO;
  }
}

/*F**************************************************************************
* NAME: fat_install
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - OK: intallation succeeded
*   - KO: - partition 1 signature not recognized
*         - FAT type is not FAT12/FAT16
*         - sector size is not 512 bytes
*         - MBR or PBR signatures are not correct
*         - low level read open failure
*----------------------------------------------------------------------------
* PURPOSE:
*   Install the fat system, read mbr, bootrecords...
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   if MBR not found, try to mount unpartitionned FAT
*   sector size is fixed to 512 bytes to simplify low level drivers
*   fat_ptr_fats = partition offset + nb_reserved_sector
*   fat_ptr_rdir = fat_ptr_fat + fat_size * nb_fat
*   fat_ptr_data = fat_ptr_rdir + nb_root_entries * 32 / 512
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
INT8U fat_install (void)
{          
  Uint32 fat_nb_sector;

  /* MBR/PBR determination */
  fat_ptr_fats = 1;
  if (fat_load_sector(MBR_ADDRESS) == OK)
  {
    if ((fat_buf_sector[0] == 0xEB) &&      /* PBR Byte 0 */
        (fat_buf_sector[2] == 0x90) &&      /* PBR Byte 2 */
        ((fat_buf_sector[21] & 0xF0) == 0xF0)) /* PBR Byte 21 : Media byte */
    {
      if ((fat_buf_sector[510] != LOW(BR_SIGNATURE)) &&         /* check PBR signature */
          (fat_buf_sector[511] != HIGH(BR_SIGNATURE)))
      {
        return KO;
      }
      else
      {
        fat_ptr_fats = 0x00000000; /* first sector is PBR */
      }
    }
    else
    {   /* first sector is MBR */
      if ((fat_buf_sector[446] != PARTITION_ACTIVE) && 
          (fat_buf_sector[446] != 0x00))
      {
        return KO;                            /* not a MBR */
      }
      else
      {
        /* read partition offset (in sectors) at offset 8 */
        fat_ptr_fats = fat_caculate_offset(fat_buf_sector[454],
                                           fat_buf_sector[455],
                                           fat_buf_sector[456],
                                           fat_buf_sector[457]
                                          );
         fat_bpb_add = fat_ptr_fats;

        if ((fat_buf_sector[510] != LOW(BR_SIGNATURE)) &&         /* check PBR signature */
            (fat_buf_sector[511] != HIGH(BR_SIGNATURE)))
        {
          return KO;
        }

      }

    }
  }
  else
  {
    return KO;
  }

  /* read and check usefull PBR info */
  if (fat_load_sector(fat_ptr_fats) == OK) 
  {
    if ((fat_buf_sector[11] != LOW(SECTOR_SIZE)) ||  /* read sector size (in bytes) */
        (fat_buf_sector[12] != HIGH(SECTOR_SIZE)))
    {
      return KO;
    }

    /* read cluster size (in sector) */
    fat_cluster_size = fat_buf_sector[13];
    fat_cluster_mask = HIGH((Uint16)fat_cluster_size * SECTOR_SIZE) - 1;
    /* compute FATs sector address: add reserved sector number */
    fat_ptr_fats += fat_buf_sector[14];
    fat_ptr_fats += (Uint16)fat_buf_sector[15] << 8;
    /* read number of FATs */
    if (fat_buf_sector[16] == 2)
      fat_2_is_present = TRUE;
    else
      fat_2_is_present = FALSE;
    /* read number of dir entries  and compute rdir offset */
    fat_ptr_data = fat_caculate_offset(fat_buf_sector[17],fat_buf_sector[18],0,0);
    
    fat_ptr_data = (fat_ptr_data * DIR_SIZE) / SECTOR_SIZE;
    /* read number of sector in partition (<32Mb) */
    fat_nb_sector = fat_caculate_offset(fat_buf_sector[19],fat_buf_sector[20],0,0);
    /* compute root directory sector address */
    fat_fat_size = (INT16U)fat_caculate_offset(fat_buf_sector[22],fat_buf_sector[23],0,0);
    
    fat_ptr_rdir = fat_buf_sector[16] * fat_fat_size;
    fat_ptr_rdir += fat_ptr_fats;

    /* read number of sector in partition (>32Mb) */
    if (!fat_nb_sector)
    {
      fat_nb_sector = fat_caculate_offset(fat_buf_sector[32],fat_buf_sector[33],fat_buf_sector[34],fat_buf_sector[35]);
     // ((Byte*)&fat_nb_sector)[3] = fat_buf_sector[32];
    //  ((Byte*)&fat_nb_sector)[2] = fat_buf_sector[33];
    //  ((Byte*)&fat_nb_sector)[1] = fat_buf_sector[34];
    //  ((Byte*)&fat_nb_sector)[0] = fat_buf_sector[35];
    }
    total_capacity = fat_nb_sector;

    fat_count_of_clusters = (fat_nb_sector - (1 + (fat_buf_sector[16] * fat_fat_size) + fat_ptr_data)) / fat_cluster_size;
    if (fat_count_of_clusters <= MAX_CLUSTERS12)
    {
      fat_is_fat16 = FALSE;
      fat_is_fat32 = FALSE;
    }
    else if(fat_count_of_clusters <= MAX_CLUSTERS16)
    {
        fat_is_fat16 = TRUE;
        fat_is_fat32 = FALSE;
    }
	else 
	{      
	   fat_is_fat16 = FALSE;
       fat_is_fat32 = TRUE;
	}/* else is FAT32 not supported */

    /* compute data sector address */
    fat_ptr_data += fat_ptr_rdir;
    /* check partition signature */
    if ((fat_buf_sector[510] != LOW(BR_SIGNATURE)) &&
        (fat_buf_sector[511] != HIGH(BR_SIGNATURE)))
    {
      return KO;
    }

    return OK;
  }
  else
  { /* low level error */
    return KO;
  }
}

/*F**************************************************************************
* NAME: fat_dseek
*----------------------------------------------------------------------------
* PARAMS:
*   offset: offset to current position in signed word value
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Seek from the current position to a new offset computing relative 
*   poisition +/- scan size limited to a 16 bit offset
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   We consider here that the seek size is minor to the cluster size !!!
*   if you want to do a more than a cluster seek, issue two successive 
*   dseek commands
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/ 
Byte fat_dseek (Int16 offset)
{
Byte     nb_sect;                     /* number of sectors to seek */
Uint16   nb_byte;                     /* number of bytes to seek */
Uint16   target_cluster;              /* the cluster to reach */
Uint16   i;

  fat_dir_current_offs += offset;           /* Calculate the absolute byte pos */
  nb_sect = (Byte)((fat_dir_current_offs) / SECTOR_SIZE);
  fat_dir_current_sect = fat_dir_start_sect + nb_sect;
  nb_byte = (Uint16)((fat_dir_current_offs) % (SECTOR_SIZE * fat_cluster_size));
  fat_dclust_byte_count = nb_byte;
  nb_byte %= SECTOR_SIZE; 
  
  if (dir_is_root == FALSE)                 /* Sub-directory ? */
  {                                         /* Find the # cluster */
    target_cluster = (nb_sect / fat_cluster_size);
    fat_dchain_index = 0;
    fat_dchain_nb_clust = 0;
    for (i = 0; i <= target_cluster; i++)
    {
      if (dclusters[fat_dchain_index].number == fat_dchain_nb_clust)
      {
        fat_dchain_index++;                 /* next fragment */
        fat_dchain_nb_clust = 1;            /* reset the nb cluster in this new fragment */
      }
      else
      {
        fat_dchain_nb_clust++;              /* next contiguous cluster */
      }
    }
    /* update fat_dir_current_sect value */
    fat_dir_current_sect = (((Uint32)(dclusters[fat_dchain_index].cluster + fat_dchain_nb_clust - 1) * fat_cluster_size)
                           + fat_ptr_data + (nb_sect % fat_cluster_size));

    if (!fat_dclust_byte_count)
    {
      if ((target_cluster == 0) || (dclusters[fat_dchain_index].number == 1))  /* If seek is first directory byte, reset */
      {                                                           /* fat_dchain_nb_clust (see fat_dgetc())  */
        fat_dchain_nb_clust = 0;     
      } 
	}

  }

  Hard_read_close();

  if (Hard_read_open(fat_dir_current_sect) == OK)
  { /* seek in current sector */
    for (i = 0;  i < nb_byte; i += 2)
    {
      Hard_read_byte();                     /* dummy reads */
      Hard_read_byte();
    }


    return OK;
  }
  else
  {
    return KO;                              /* low level error */
  }
}

/*F**************************************************************************
* NAME: fat_dgetc
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Return the directory data byte at the current position
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/ 
Byte fat_dgetc (void)
{
  /* check if we are at the end of a cluster */
  if(   ((Byte)(fat_dclust_byte_count) == 0x00) && 
      ((((Byte)(fat_dclust_byte_count >> 8)) & fat_cluster_mask) == 0x00) )
  
  //if ((((Byte*)&fat_dclust_byte_count)[1] == 0x00) &&
  //     ((((Byte*)&fat_dclust_byte_count)[0] & fat_cluster_mask) == 0x00))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品私房写真福利视频| 精品国产123| 日韩欧美高清一区| 国产精品亚洲一区二区三区在线| 一区二区三区中文在线| 欧美成人福利视频| 欧美日韩和欧美的一区二区| 岛国av在线一区| 蜜臀av性久久久久蜜臀aⅴ| 亚洲欧美日韩综合aⅴ视频| 久久蜜臀中文字幕| 7777精品伊人久久久大香线蕉超级流畅 | 精品国产99国产精品| 欧美无砖砖区免费| 波多野结衣亚洲| 国产精品一区二区不卡| 激情五月婷婷综合| 毛片一区二区三区| 天天操天天色综合| 午夜在线成人av| 亚洲精品免费在线| 亚洲欧洲三级电影| 久久免费午夜影院| 亚洲精品一区在线观看| 精品久久久久久最新网址| 91麻豆精品国产91久久久久久久久| 在线观看一区不卡| 在线观看网站黄不卡| 色94色欧美sute亚洲线路一久 | 成人免费看黄yyy456| 日韩高清欧美激情| 婷婷一区二区三区| 五月天激情综合| 亚洲电影在线播放| 亚洲成人免费视频| 午夜久久久久久久久| 日本中文字幕不卡| 久久99久久99| 国产精品影音先锋| 成人夜色视频网站在线观看| 成人国产一区二区三区精品| av在线不卡网| 色哟哟精品一区| 欧美日韩情趣电影| 91精品国产综合久久小美女| 欧美一二三四在线| 久久亚洲免费视频| 中文幕一区二区三区久久蜜桃| 中文字幕日本不卡| 亚洲综合一区二区三区| 婷婷成人激情在线网| 美女网站一区二区| 国产麻豆视频精品| 成人av在线影院| 欧美日韩五月天| 日韩一区二区三区在线观看| 久久久一区二区三区| 亚洲婷婷综合久久一本伊一区| 亚洲欧美日韩久久精品| 污片在线观看一区二区| 久久国产精品区| 成人免费视频播放| 欧美日韩国产一级片| 欧美成人精品3d动漫h| 国产精品毛片大码女人| 亚洲国产综合在线| 久久精品噜噜噜成人av农村| 成人激情动漫在线观看| 欧美性做爰猛烈叫床潮| 26uuu欧美日本| 日韩一区在线播放| 日韩国产精品大片| 不卡av在线网| 欧美一区二区视频在线观看2020| 国产欧美日韩不卡免费| 亚洲自拍欧美精品| 国产一区二区电影| 欧美午夜影院一区| 国产日韩精品一区二区浪潮av| 一级做a爱片久久| 激情久久五月天| 日本道在线观看一区二区| 精品国产伦一区二区三区观看体验| 国产精品视频一二| 日韩在线观看一区二区| 99综合影院在线| 精品美女在线播放| 亚洲国产日日夜夜| 成人黄色一级视频| 日韩欧美国产电影| 一区二区三区色| 国产99久久久国产精品潘金| 欧美视频在线观看一区二区| xnxx国产精品| 丝袜美腿亚洲综合| 91欧美激情一区二区三区成人| 欧美大片一区二区三区| 亚洲成人福利片| 成人免费看片app下载| 欧美xxxx老人做受| 香蕉影视欧美成人| 一本大道久久a久久综合| 精品国产麻豆免费人成网站| 婷婷中文字幕综合| 在线免费观看日本一区| 亚洲欧洲一区二区在线播放| 国产精品一区二区在线看| 56国语精品自产拍在线观看| 亚洲精品高清在线| 99精品欧美一区| 国产精品女同互慰在线看| 美美哒免费高清在线观看视频一区二区| 91福利在线免费观看| 亚洲人成电影网站色mp4| 成人av在线电影| 国产日韩欧美在线一区| 国产一区二区三区在线观看精品 | 久久精品国产精品亚洲红杏| 欧美人妇做爰xxxⅹ性高电影| 亚洲欧美aⅴ...| 91丨porny丨户外露出| 国产精品网曝门| 国产成人小视频| 国产亚洲欧美一级| 国产精品自拍网站| 久久奇米777| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 国产伦精品一区二区三区视频青涩| 日韩一区二区三区视频在线| 男女男精品网站| 日韩欧美一区二区免费| 久久精品久久99精品久久| 日韩欧美久久久| 狠狠色狠狠色综合系列| 久久精品亚洲麻豆av一区二区| 国产乱对白刺激视频不卡| 国产亲近乱来精品视频| 成人中文字幕电影| 亚洲视频在线观看三级| 在线观看日韩一区| 亚洲国产一区二区在线播放| 欧美精品九九99久久| 六月婷婷色综合| 26uuu欧美日本| 成人激情文学综合网| 亚洲精品高清在线| 69堂精品视频| 国产一区二区三区视频在线播放| 欧美激情一区二区三区不卡| 91在线播放网址| 亚洲国产精品久久艾草纯爱| 日韩一区二区免费在线观看| 国产一区二区调教| 中文字幕一区二区日韩精品绯色| 一本大道久久a久久精二百| 亚洲电影在线免费观看| 欧美一级黄色片| 成人精品小蝌蚪| 一级女性全黄久久生活片免费| 日韩一区二区视频| 成人av综合在线| 亚洲一区在线看| 26uuu欧美| 一本大道久久a久久精二百| 日韩av一区二区在线影视| 久久精品在线免费观看| 色偷偷久久人人79超碰人人澡| 奇米精品一区二区三区在线观看 | 粉嫩一区二区三区性色av| 亚洲区小说区图片区qvod| 9191成人精品久久| 丁香激情综合国产| 婷婷国产在线综合| 国产女同性恋一区二区| 欧美日韩性生活| 成人综合婷婷国产精品久久蜜臀 | 亚洲欧美激情小说另类| 欧美一级片在线观看| 成人动漫一区二区三区| 日日欢夜夜爽一区| 成人免费一区二区三区在线观看| 在线成人免费视频| 成人看片黄a免费看在线| 天堂影院一区二区| 亚洲欧美在线aaa| ww亚洲ww在线观看国产| 欧美午夜寂寞影院| 成人一区在线观看| 久久精品理论片| 亚洲成人激情社区| 中文无字幕一区二区三区| 91精品国产综合久久久久久久| 成人国产亚洲欧美成人综合网| 麻豆极品一区二区三区| 亚洲国产精品一区二区www在线 | 久久国产精品99精品国产| 亚洲激情图片qvod| 欧美国产精品一区| ww久久中文字幕| 日韩欧美国产三级电影视频|