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

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

?? fat.c

?? GAT文件系統
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*C**************************************************************************
* NAME:         fat.c
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-refd-nf-4_0_3      
* REVISION:     1.41     
*----------------------------------------------------------------------------
* PURPOSE:
* FAT16/FAT12 file-system basics functions
* 
* NOTES:
* Supports only the first partition
* Supports only 512 bytes sector size
* Supports only file fragmentation < MAX_FILE_FRAGMENT_NUMBER
* Supports only one file openned at a time
*
* Global Variables:
*   - gl_buffer: array of bytes in pdata space
*****************************************************************************/

/*_____ I N C L U D E S ____________________________________________________*/

#include "config.h"                         /* system configuration */
#include "..\mem\hard.h"                    /* low level function definition */
#include "file.h"                           /* file function definition */
#include "fat.h"                            /* fat file-system definition */


/*_____ M A C R O S ________________________________________________________*/


/*_____ D E F I N I T I O N ________________________________________________*/

extern        bit     reserved_disk_space;
extern  pdata Byte    gl_buffer[];
extern  xdata Byte    fat_buf_sector[];  /* 512 bytes buffer */

extern  char  pdata *lfn_name; /* long filename limited to MAX_FILENAME_LEN chars */

/* disk management */
extern  data  Uint32  fat_ptr_fats;         /* address of the first byte of FAT */
extern  data  Uint32  fat_ptr_rdir;         /* address of the first byte of root dir */
extern  data  Uint32  fat_ptr_data;         /* address of the first byte of data */
extern  data  Byte    fat_cluster_size;     /* cluster size (sector count) */
extern  idata Byte    fat_cluster_mask;     /* mask for end of cluster test */

extern  bdata bit     dir_is_root;          /* TRUE: point the root directory  */
extern  bdata bit     fat_is_fat16;         /* TRUE: FAT16 - FALSE: FAT12 */
extern  bdata bit     fat_open_mode;        /* READ or WRITE */
extern  bdata bit     fat_2_is_present;     /* TRUE: 2 FATs - FALSE: 1 FAT */
extern  bdata bit     flag_end_disk_file;


extern  xdata Uint32  fat_count_of_clusters;/* number of cluster - 2 */
extern  xdata Uint16  fat_root_entry;       /* position in root dir */
extern  xdata Union32 fat_file_size;
extern  xdata Uint16  fat_fat_size;         /* FAT size in sector count */


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


/* file management */
extern  data  Uint16  fat_fclust_byte_count;/* byte counter in file cluster */
extern  idata Byte    fat_last_clust_index; /* index of the last cluster in file chain */
extern  idata Byte    fat_fchain_index;     /* the number of the fragment of the file, in fact
                                               the index of the table in the cluster chain */
extern  idata Uint16  fat_fchain_nb_clust;  /* the offset of the cluster from the first cluster
                                               of the file fragment */

extern  xdata fat_st_clust_chain fclusters[MAX_FILE_FRAGMENT_NUMBER];
                                            /* cluster chain for the current file */


/* Mode repeat A/B variables */
extern xdata  Byte    fat_fchain_index_save;         
extern xdata  Byte    fat_fchain_nb_clust_save;
extern xdata  Uint16  fat_fclust_byte_count_save;

static xdata fat_st_free_space free_space;

/*_____ D E C L A R A T I O N ______________________________________________*/

static  void    fat_get_dir_entry (fat_st_dir_entry xdata *);
static  void    fat_get_dir_file_list (Byte);
static  bit     fat_get_clusters (fat_st_clust_chain xdata *, Byte);
static  bit     fat_set_clusters (void);
static  bit     fat_dopen (void);
static  bit     fat_dseek (Int16);
static  Byte    fat_dgetc (void);

code Byte PBR_record_part1[] =
{
  0xEB, 0x3C, 0x90, /* JMP instruction to boot code */
  'O', 'E', 'M', ' ', 'N', 'A', 'M', 'E', /* OEM name */
  SECTOR_SIZE, SECTOR_SIZE >> 8, /* number of bytes per sector */
  0x00, /* number of sector per cluster */
  NB_RESERVED, NB_RESERVED >> 8, /* number of reserved sector */
  NB_FATS, /* number of FAT */
  NB_ROOT_ENTRY, NB_ROOT_ENTRY >> 8, /* number of root directory entries */
  0x00, 0x00, /* total sectors if less than 65535 */
  HARD_DISK, /* media byte */
};

code Byte PBR_record_part2[] =
{
  FAT_DRIVE_NUMBER, /* Drive number */
  0x00, /* not used */
  FAT_EXT_SIGN, /* extended boot signature */
  0x00, 0x00, 0x00, 0x00, /* volume ID */
  'N', 'O', ' ', 'N', 'A', 'M', 'E', ' ', ' ', ' ', ' ', /* volume label */
  'F', 'A', 'T', '1', 0x00, ' ', ' ', ' ', /* File system type in ASCII */

};

/*F**************************************************************************
* NAME: fat_load_sector
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   This function load a sector in fat_buf_sector
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*   
*****************************************************************************/
bit fat_load_sector(Uint32 sector)
{
Uint16 i;
  if (Hard_read_open(sector) == OK)
  {
    for (i = 0; i < (SECTOR_SIZE); i++)
    {
      fat_buf_sector[i++] = Hard_read_byte();
      fat_buf_sector[i++] = Hard_read_byte();
      fat_buf_sector[i++] = Hard_read_byte();
      fat_buf_sector[i]   = Hard_read_byte();
    }
    Hard_read_close();
    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:
*****************************************************************************/
bit 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 */
        ((Byte*)&fat_ptr_fats)[3] = fat_buf_sector[454];
        ((Byte*)&fat_ptr_fats)[2] = fat_buf_sector[455];
        ((Byte*)&fat_ptr_fats)[1] = fat_buf_sector[456];
        ((Byte*)&fat_ptr_fats)[0] = fat_buf_sector[457];
        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 */
    ((Byte*)&fat_ptr_data)[3] = fat_buf_sector[17];
    ((Byte*)&fat_ptr_data)[2] = fat_buf_sector[18];
    ((Byte*)&fat_ptr_data)[1] = 0;
    ((Byte*)&fat_ptr_data)[0] = 0;
    fat_ptr_data = (fat_ptr_data * DIR_SIZE) / SECTOR_SIZE;
    /* read number of sector in partition (<32Mb) */
    ((Byte*)&fat_nb_sector)[3] = fat_buf_sector[19];
    ((Byte*)&fat_nb_sector)[2] = fat_buf_sector[20];
    ((Byte*)&fat_nb_sector)[1] = 0x00;
    ((Byte*)&fat_nb_sector)[0] = 0x00;
    /* compute root directory sector address */
    ((Byte*)&fat_fat_size)[1] = fat_buf_sector[22];
    ((Byte*)&fat_fat_size)[0] = fat_buf_sector[23];
    
    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)
    {
      ((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];
    }

    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;
    else
      if (fat_count_of_clusters <= MAX_CLUSTERS16)
        fat_is_fat16 = 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_get_dir_entry
*----------------------------------------------------------------------------
* PARAMS:
*   entry: directory entry structure
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Get from directory all information about a directory or file entry
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   This function reads directly datas from sectors
*   It automaticaly computes difference between LFN and normal entries
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void fat_get_dir_entry (fat_st_dir_entry xdata *entry)
{
bit     exit_flag = FALSE;
bit     lfn_entry_found = FALSE;
Byte    i;

  /* clear the name buffer */
  for (i = MAX_FILENAME_LEN; i != 0; lfn_name[--i] = '\0');

  while (!exit_flag)
  /* loop while the entry is not a normal one. */
  {
    /* read the directory entry */
    if (dir_is_root == TRUE)
    { /* root dir is linear -> Hard_read_byte() */
      for (i = 0; i < DIR_SIZE; i++)
        gl_buffer[i] = Hard_read_byte();
    }
    else
    { /* subdir can be fragmented -> dgetc() */
      for (i = 0; i < DIR_SIZE; i++)
        gl_buffer[i] = fat_dgetc();
    }

    /*computes gathered data
    /* check if we have a LFN entry */
    if (gl_buffer[11] != ATTR_LFN_ENTRY)
    {
      if (!lfn_entry_found)
      {
        /* true DOS 8.3 entry format */
        for (i = 0; i < 8; i++)
        {
          lfn_name[i] = gl_buffer[i];
          
          if (lfn_name[i] == ' ')
          { /* space is end of name */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲男人天堂av| 风流少妇一区二区| 国产精品香蕉一区二区三区| 色婷婷综合激情| 久久婷婷色综合| 天堂久久一区二区三区| 成人黄色av电影| 精品久久久三级丝袜| 一区二区三区精品久久久| 狠狠色狠狠色综合系列| 欧美日韩极品在线观看一区| 最新国产精品久久精品| 久久91精品国产91久久小草 | 日本乱人伦aⅴ精品| 精品国产乱码久久久久久影片| 亚洲综合视频在线| av在线播放一区二区三区| 国产日韩精品一区二区三区在线| 男女男精品网站| 777午夜精品视频在线播放| 亚洲欧美日韩国产成人精品影院| 成人免费看黄yyy456| 久久久av毛片精品| 国精产品一区一区三区mba视频| 6080午夜不卡| 亚洲第一二三四区| 欧美性欧美巨大黑白大战| 亚洲美女淫视频| 色先锋资源久久综合| 亚洲男人的天堂在线观看| caoporen国产精品视频| 中文久久乱码一区二区| 不卡一区二区中文字幕| 中文成人综合网| 成人av在线播放网站| 亚洲欧美一区二区不卡| 色天天综合色天天久久| 亚洲综合一区二区三区| 欧美二区乱c少妇| 麻豆久久久久久久| 精品国产91亚洲一区二区三区婷婷| 蜜臀久久99精品久久久久宅男| 欧美一区二区在线免费播放| 秋霞成人午夜伦在线观看| 欧美成人艳星乳罩| 国产精品中文字幕日韩精品| 国产精品剧情在线亚洲| 色偷偷久久一区二区三区| 亚洲va在线va天堂| 精品人伦一区二区色婷婷| 国精品**一区二区三区在线蜜桃| 中文字幕精品一区二区精品绿巨人| 波多野结衣在线aⅴ中文字幕不卡| 亚洲天堂久久久久久久| 欧美日韩高清不卡| 久久精品国产成人一区二区三区 | 国产女人aaa级久久久级| 成人毛片在线观看| 亚洲在线视频一区| 日韩亚洲电影在线| 成人晚上爱看视频| 午夜伊人狠狠久久| 国产日韩欧美精品综合| 欧美在线不卡一区| 欧美午夜免费电影| 狠狠色丁香婷婷综合| 综合分类小说区另类春色亚洲小说欧美| 在线区一区二视频| 国精产品一区一区三区mba视频| 国产精品不卡一区| 日韩三级.com| 97久久超碰国产精品电影| 男男视频亚洲欧美| 亚洲欧美电影院| 26uuu亚洲综合色| 在线视频你懂得一区二区三区| 精品一区二区免费| 亚洲女与黑人做爰| 久久久精品综合| 欧美巨大另类极品videosbest | 亚洲欧美日韩成人高清在线一区| 欧美精品tushy高清| 成人免费视频caoporn| 日韩国产一二三区| 亚洲精品老司机| 2024国产精品| 欧美一区二区三区喷汁尤物| 91麻豆免费在线观看| 国产乱国产乱300精品| 亚洲午夜电影在线观看| 亚洲国产成人一区二区三区| 日韩一卡二卡三卡四卡| 欧美亚洲一区二区在线观看| 99精品国产一区二区三区不卡| 激情五月婷婷综合网| 日本在线观看不卡视频| 亚洲午夜久久久久久久久电影院| 国产精品美女一区二区| 久久久久免费观看| 日韩午夜三级在线| 欧美嫩在线观看| 欧美性猛交xxxx乱大交退制版| 99视频一区二区| 成人白浆超碰人人人人| 国产精品一卡二卡| 国产一区二区精品在线观看| 久久国产精品第一页| 免费观看91视频大全| 日韩电影免费在线观看网站| 日日夜夜精品视频免费| 亚洲v日本v欧美v久久精品| 亚洲第一二三四区| 亚洲国产精品久久久男人的天堂| 亚洲男人的天堂av| 亚洲激情六月丁香| 亚洲国产一区二区三区青草影视| 亚洲精品伦理在线| 亚洲综合清纯丝袜自拍| 亚洲一级在线观看| 日韩高清不卡在线| 久久激情五月激情| 国产一区视频网站| 成人黄色在线网站| 在线看日本不卡| 51精品久久久久久久蜜臀| 欧美一区二区三区视频免费| 日韩欧美一级二级三级久久久| 日韩美女视频一区二区在线观看| 精品日韩99亚洲| 欧美国产一区二区| 亚洲美女视频一区| 日韩中文字幕麻豆| 奇米精品一区二区三区在线观看| 极品少妇xxxx精品少妇| 国产精品亚洲人在线观看| 92国产精品观看| 欧美精品久久天天躁| www久久精品| 亚洲人成伊人成综合网小说| 婷婷六月综合亚洲| 国产伦精品一区二区三区视频青涩| 成人午夜在线播放| 91精品办公室少妇高潮对白| 日韩亚洲欧美一区| 国产精品视频看| 亚洲成a人v欧美综合天堂| 国产一区亚洲一区| 在线一区二区视频| 26uuu久久综合| 一区二区三区四区在线免费观看| 免费在线观看日韩欧美| 99久久777色| 欧美一区二区三区在线观看| 国产欧美一区二区在线观看| 亚洲午夜久久久久久久久电影网 | 欧美日韩激情一区| 亚洲精品一区二区三区蜜桃下载| 中文字幕在线不卡一区二区三区| 天天综合网天天综合色| 成人黄色国产精品网站大全在线免费观看| 色综合天天综合网天天看片| 欧美哺乳videos| 亚洲精选在线视频| 国产aⅴ综合色| 欧美片在线播放| 亚洲女人的天堂| 国产一级精品在线| 欧美精品九九99久久| 国产精品久久久一区麻豆最新章节| 日本最新不卡在线| 欧美无乱码久久久免费午夜一区 | 亚洲欧美日韩在线播放| 国产麻豆日韩欧美久久| 777色狠狠一区二区三区| 国产精品萝li| 国产精品1区2区| 日韩一区二区三区在线| 亚洲国产精品一区二区久久恐怖片| 成人三级伦理片| 久久久久久久久岛国免费| 日韩福利视频网| 欧美狂野另类xxxxoooo| 一区二区三区在线看| 91在线精品一区二区| 日本一区二区三区高清不卡| 极品瑜伽女神91| 欧美tk—视频vk| 捆绑调教美女网站视频一区| 欧美日韩性生活| 国产精品影视在线观看| 欧美成人在线直播| 无码av免费一区二区三区试看| 日本高清不卡一区| 亚洲精品一二三四区| 色综合久久久久久久| 亚洲精选视频在线| 日本韩国欧美国产| 亚洲一区二区三区四区在线 | 久久69国产一区二区蜜臀| 欧美一区二区三区精品|