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

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

?? fat16.c

?? MMC/SD操作
?? C
?? 第 1 頁 / 共 4 頁
字號:
#include "partition.h"#include "fat16.h"#include "fat16_config.h"#include <stdlib.h>#include <string.h>/** * \addtogroup fat16 FAT16 support * * This module implements FAT16 read and write access. *  * The following features are supported: * - File names up to 31 characters long. * - Unlimited depth of subdirectories. * - Short 8.3 and long filenames. * - Creating and deleting files. * - Reading and writing from and to files. * - File resizing. * - File sizes of up to 4 gigabytes. *  * @{ *//** * \file * FAT16 implementation. * * \author Roland Riegel *//** * \addtogroup fat16_config FAT16 configuration * Preprocessor defines to configure the FAT16 implementation. *//** * \addtogroup fat16_fs FAT16 access * Basic functions for handling a FAT16 filesystem. *//** * \addtogroup fat16_file FAT16 file functions * Functions for managing files. *//** * \addtogroup fat16_dir FAT16 directory functions * Functions for managing directories. *//** * @} */#define FAT16_CLUSTER_FREE 0x0000#define FAT16_CLUSTER_RESERVED_MIN 0xfff0#define FAT16_CLUSTER_RESERVED_MAX 0xfff6#define FAT16_CLUSTER_BAD 0xfff7#define FAT16_CLUSTER_LAST_MIN 0xfff8#define FAT16_CLUSTER_LAST_MAX 0xffff#define FAT16_DIRENTRY_DELETED 0xe5#define FAT16_DIRENTRY_LFNLAST (1 << 6)#define FAT16_DIRENTRY_LFNSEQMASK ((1 << 6) - 1)/* Each entry within the directory table has a size of 32 bytes * and either contains a 8.3 DOS-style file name or a part of a * long file name, which may consist of several directory table * entries at once. * * multi-byte integer values are stored little-endian! * * 8.3 file name entry: * ==================== * offset  length  description *      0       8  name (space padded) *      8       3  extension (space padded) *     11       1  attributes (FAT16_ATTRIB_*) * * long file name (lfn) entry ordering for a single file name: * =========================================================== * LFN entry n *     ... * LFN entry 2 * LFN entry 1 * 8.3 entry (see above) *  * lfn entry: * ========== * offset  length  description *      0       1  ordinal field *      1       2  unicode character 1 *      3       3  unicode character 2 *      5       3  unicode character 3 *      7       3  unicode character 4 *      9       3  unicode character 5 *     11       1  attribute (always 0x0f) *     12       1  type (reserved, always 0) *     13       1  checksum *     14       2  unicode character 6 *     16       2  unicode character 7 *     18       2  unicode character 8 *     20       2  unicode character 9 *     22       2  unicode character 10 *     24       2  unicode character 11 *     26       2  cluster (unused, always 0) *     28       2  unicode character 12 *     30       2  unicode character 13 *  * The ordinal field contains a descending number, from n to 1. * For the n'th lfn entry the ordinal field is or'ed with 0x40. * For deleted lfn entries, the ordinal field is set to 0xe5. */struct fat16_header_struct{    uint32_t size;    uint32_t fat_offset;    uint32_t fat_size;    uint16_t sector_size;    uint16_t cluster_size;    uint32_t root_dir_offset;    uint32_t cluster_zero_offset;};struct fat16_fs_struct{    struct partition_struct* partition;    struct fat16_header_struct header;};struct fat16_file_struct{    struct fat16_fs_struct* fs;    struct fat16_dir_entry_struct dir_entry;    uint32_t pos;};struct fat16_dir_struct{    struct fat16_fs_struct* fs;    struct fat16_dir_entry_struct dir_entry;    uint16_t entry_next;};struct fat16_read_callback_arg{    uint16_t entry_cur;    uint16_t entry_num;    uint32_t entry_offset;    uint8_t byte_count;};static uint8_t fat16_read_header(struct fat16_fs_struct* fs);static uint8_t fat16_read_root_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, struct fat16_dir_entry_struct* dir_entry);static uint8_t fat16_read_sub_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, const struct fat16_dir_entry_struct* parent, struct fat16_dir_entry_struct* dir_entry);static uint8_t fat16_dir_entry_seek_callback(uint8_t* buffer, uint32_t offset, void* p);static uint8_t fat16_dir_entry_read_callback(uint8_t* buffer, uint32_t offset, void* p);static uint8_t fat16_interpret_dir_entry(struct fat16_dir_entry_struct* dir_entry, const uint8_t* raw_entry);static uint16_t fat16_get_next_cluster(const struct fat16_fs_struct* fs, uint16_t cluster_num);static uint16_t fat16_append_cluster(const struct fat16_fs_struct* fs, uint16_t cluster_num);static uint8_t fat16_free_cluster(struct fat16_fs_struct* fs, uint16_t cluster_num);static uint8_t fat16_write_dir_entry(struct fat16_fs_struct* fs, const struct fat16_dir_entry_struct* dir_entry);/** * \ingroup fat16_fs * Opens a FAT16 filesystem. * * \param[in] partition Discriptor of partition on which the filesystem resides. * \returns 0 on error, a FAT16 filesystem descriptor on success. * \see fat16_open */struct fat16_fs_struct* fat16_open(struct partition_struct* partition){    if(!partition ||#if FAT16_WRITE_SUPPORT       !partition->device_write#else       0#endif      )        return 0;    struct fat16_fs_struct* fs = malloc(sizeof(*fs));    if(!fs)        return 0;    memset(fs, 0, sizeof(*fs));    fs->partition = partition;    if(!fat16_read_header(fs))    {        free(fs);        return 0;    }        return fs;}/** * \ingroup fat16_fs * Closes a FAT16 filesystem. * * When this function returns, the given filesystem descriptor * will be invalid. * * \param[in] fs The filesystem to close. * \see fat16_open */void fat16_close(struct fat16_fs_struct* fs){    if(!fs)        return;    free(fs);}/** * \ingroup fat16_fs * Reads and parses the header of a FAT16 filesystem. * * \param[inout] fs The filesystem for which to parse the header. * \returns 0 on failure, 1 on success. */uint8_t fat16_read_header(struct fat16_fs_struct* fs){    uint8_t buffer[25];    struct partition_struct* partition;    struct fat16_header_struct* header;        if(!fs || !fs->partition)        return 0;    partition = fs->partition;    header = &fs->header;        if(partition->type != PARTITION_TYPE_FAT16 &&       partition->type != PARTITION_TYPE_FAT16_LBA)        return 0;    uint32_t partition_offset = partition->offset * 512;    if(!partition->device_read(partition_offset + 0x0b, buffer, sizeof(buffer)))        return 0;    memset(header, 0, sizeof(*header));        uint16_t bytes_per_sector = ((uint16_t) buffer[0x00]) |                                ((uint16_t) buffer[0x01] << 8);    uint8_t sectors_per_cluster = buffer[0x02];    uint16_t reserved_sectors = ((uint16_t) buffer[0x03]) |                                ((uint16_t) buffer[0x04] << 8);    uint8_t fat_copies = buffer[0x05];    uint16_t max_root_entries = ((uint16_t) buffer[0x06]) |                                ((uint16_t) buffer[0x07] << 8);    uint16_t sectors_per_fat = ((uint16_t) buffer[0x0b]) |                               ((uint16_t) buffer[0x0c] << 8);    uint32_t sector_count = ((uint32_t) buffer[0x15]) |                            ((uint32_t) buffer[0x16] << 8) |                            ((uint32_t) buffer[0x17] << 16) |                            ((uint32_t) buffer[0x18] << 24);        header->size = sector_count * bytes_per_sector;    header->fat_offset = /* jump to partition */                         partition_offset +                         /* jump to fat */                         (uint32_t) reserved_sectors * bytes_per_sector;    header->fat_size = (uint32_t) sectors_per_fat * bytes_per_sector;    header->sector_size = bytes_per_sector;    header->cluster_size = (uint32_t) bytes_per_sector * sectors_per_cluster;    header->root_dir_offset = /* jump to fats */                              header->fat_offset +                              /* jump to root directory entries */                              (uint32_t) fat_copies * sectors_per_fat * bytes_per_sector;    header->cluster_zero_offset = /* jump to root directory entries */                                  header->root_dir_offset +                                  /* skip root directory entries */                                  (uint32_t) max_root_entries * 32;    return 1;}/** * \ingroup fat16_fs * Reads a directory entry of the root directory. * * \param[in] fs Descriptor of file system to use. * \param[in] entry_num The index of the directory entry to read. * \param[out] dir_entry Directory entry descriptor which will get filled. * \returns 0 on failure, 1 on success * \see fat16_read_sub_dir_entry, fat16_read_dir_entry_by_path */uint8_t fat16_read_root_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, struct fat16_dir_entry_struct* dir_entry){    if(!fs || !dir_entry)        return 0;    /* we read from the root directory entry */    const struct fat16_header_struct* header = &fs->header;    device_read_interval_t device_read_interval = fs->partition->device_read_interval;    uint8_t buffer[32];    /* seek to the n-th entry */    struct fat16_read_callback_arg arg;    memset(&arg, 0, sizeof(arg));    arg.entry_num = entry_num;    if(!device_read_interval(header->root_dir_offset,                             buffer,                             sizeof(buffer),                             header->cluster_zero_offset - header->root_dir_offset,                             fat16_dir_entry_seek_callback,                             &arg) ||       arg.entry_offset == 0      )        return 0;    /* read entry */    memset(dir_entry, 0, sizeof(*dir_entry));    if(!device_read_interval(arg.entry_offset,                             buffer,                             sizeof(buffer),                             arg.byte_count,                             fat16_dir_entry_read_callback,                             dir_entry))        return 0;    return dir_entry->long_name[0] != '\0' ? 1 : 0;}/** * \ingroup fat16_fs * Reads a directory entry of a given parent directory. * * \param[in] fs Descriptor of file system to use. * \param[in] entry_num The index of the directory entry to read. * \param[in] parent Directory entry descriptor in which to read directory entry. * \param[out] dir_entry Directory entry descriptor which will get filled. * \returns 0 on failure, 1 on success * \see fat16_read_root_dir_entry, fat16_read_dir_entry_by_path */uint8_t fat16_read_sub_dir_entry(const struct fat16_fs_struct* fs, uint16_t entry_num, const struct fat16_dir_entry_struct* parent, struct fat16_dir_entry_struct* dir_entry){    if(!fs || !parent || !dir_entry)        return 0;    /* we are in a parent directory and want to search within its directory entry table */    if(!(parent->attributes & FAT16_ATTRIB_DIR))        return 0;    /* loop through all clusters of the directory */    uint8_t buffer[32];    uint32_t cluster_offset;    uint16_t cluster_size = fs->header.cluster_size;    uint16_t cluster_num = parent->cluster;    struct fat16_read_callback_arg arg;    while(1)    {        /* calculate new cluster offset */        cluster_offset = fs->header.cluster_zero_offset + (uint32_t) (cluster_num - 2) * cluster_size;        /* seek to the n-th entry */        memset(&arg, 0, sizeof(arg));        arg.entry_num = entry_num;        if(!fs->partition->device_read_interval(cluster_offset,                                                buffer,                                                sizeof(buffer),                                                cluster_size,                                                fat16_dir_entry_seek_callback,                                                &arg)          )            return 0;        /* check if we found the entry */        if(arg.entry_offset)            break;        /* get number of next cluster */        if(!(cluster_num = fat16_get_next_cluster(fs, cluster_num)))            return 0; /* directory entry not found */    }    memset(dir_entry, 0, sizeof(*dir_entry));    /* read entry */    if(!fs->partition->device_read_interval(arg.entry_offset,                                            buffer,                                            sizeof(buffer),                                            arg.byte_count,                                            fat16_dir_entry_read_callback,                                            dir_entry))        return 0;    return dir_entry->long_name[0] != '\0' ? 1 : 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀久久99精品久久久画质超高清| 北条麻妃一区二区三区| 久久精品99国产精品| 老司机午夜精品| 国产精品一品二品| 91在线丨porny丨国产| 国产91精品久久久久久久网曝门| 136国产福利精品导航| 久久久www成人免费毛片麻豆| 久久这里只有精品视频网| 精品国产一区二区亚洲人成毛片 | 成人国产免费视频| 95精品视频在线| 欧美精品黑人性xxxx| 精品国产乱码91久久久久久网站| 日本一区二区在线不卡| 亚洲美女区一区| 日韩av午夜在线观看| 国产精品夜夜嗨| 欧美三级欧美一级| 国产午夜精品久久久久久免费视| 欧美国产国产综合| 日本美女一区二区三区视频| 国产一区二区成人久久免费影院| 一本色道久久综合亚洲aⅴ蜜桃| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 欧美欧美欧美欧美首页| 久久精品无码一区二区三区| 亚洲国产成人av好男人在线观看| 韩国av一区二区三区四区| 99热这里都是精品| 国产日产欧美一区二区三区| 天堂蜜桃91精品| 欧美亚洲综合色| **性色生活片久久毛片| 精品一区精品二区高清| 欧美三级视频在线观看| 亚洲人午夜精品天堂一二香蕉| 久久av资源站| 日韩欧美国产电影| 日本午夜精品视频在线观看| 精品视频色一区| 亚洲午夜视频在线观看| 在线日韩一区二区| 日韩综合一区二区| 7777精品伊人久久久大香线蕉完整版 | 国产喷白浆一区二区三区| 极品美女销魂一区二区三区| 91在线一区二区三区| 日韩精品一区二区三区视频在线观看| 亚洲一区在线免费观看| 色欧美88888久久久久久影院| 亚洲欧美激情插| 欧美性xxxxxx少妇| 日韩不卡一二三区| 精品国产乱码久久久久久免费| 秋霞电影网一区二区| 日韩一区二区免费在线电影| 日本欧美在线观看| 久久精品人人做人人综合| 国产福利不卡视频| 自拍偷拍亚洲综合| 欧美亚洲综合久久| 激情欧美一区二区三区在线观看| 日韩欧美精品三级| 国产a久久麻豆| 久久久天堂av| 视频一区视频二区在线观看| 色综合 综合色| 男女男精品网站| 国产精品国产a级| 欧美精品一级二级三级| 成人免费视频app| 亚州成人在线电影| 国产精品福利一区| 欧美一二三区精品| 94色蜜桃网一区二区三区| 蜜桃视频在线观看一区二区| 亚洲成人免费看| 国产亚洲一区二区三区四区| 色香蕉成人二区免费| 精品一区中文字幕| 亚洲一区二区三区爽爽爽爽爽 | 亚洲欧美激情小说另类| 精品av久久707| 欧美日韩精品一二三区| 国产盗摄女厕一区二区三区| 婷婷成人激情在线网| 亚洲欧美日韩久久| 国产精品色哟哟| 国产亚洲综合色| 日韩女优制服丝袜电影| 欧美日韩三级一区二区| 色哟哟亚洲精品| 高清久久久久久| 国产美女一区二区| 激情偷乱视频一区二区三区| 免费在线观看成人| 日韩国产欧美在线视频| 日韩av一区二区在线影视| 亚洲综合色区另类av| 一区二区三区在线视频观看58| 亚洲视频精选在线| 亚洲人成影院在线观看| 亚洲天堂av一区| 亚洲免费观看高清完整版在线| 国产欧美综合色| 国产精品三级久久久久三级| 国产精品久久久久久久第一福利 | www.亚洲免费av| av综合在线播放| 欧美在线观看视频一区二区| 欧美日韩一级片网站| 日韩欧美国产精品| 国产日韩欧美不卡| 亚洲品质自拍视频| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲福利视频三区| 国内精品伊人久久久久av影院 | 亚洲一区二区三区四区在线免费观看 | 99免费精品视频| 欧美精品丝袜中出| 久久久亚洲综合| 亚洲精品视频一区二区| 日av在线不卡| 亚洲成av人在线观看| 一区二区高清在线| 久久不见久久见免费视频7| 成人一区在线观看| 欧美精品粉嫩高潮一区二区| 久久九九国产精品| 午夜欧美大尺度福利影院在线看| 九九视频精品免费| 欧美午夜免费电影| 国产精品久久午夜夜伦鲁鲁| 三级亚洲高清视频| 色天天综合久久久久综合片| 久久久精品综合| 午夜电影久久久| 在线观看www91| 国产精品久线观看视频| 奇米色777欧美一区二区| 99精品视频免费在线观看| 精品国产网站在线观看| 亚洲大片免费看| 色天天综合久久久久综合片| 国产精品素人视频| 国产不卡视频一区| 欧美精品一区在线观看| 免播放器亚洲一区| 欧美高清一级片在线| 亚洲一二三区视频在线观看| www.亚洲国产| 国产精品超碰97尤物18| 成人爽a毛片一区二区免费| 久久久久久亚洲综合影院红桃| 秋霞成人午夜伦在线观看| 欧美精选在线播放| 蜜桃av一区二区三区电影| 91精品国产黑色紧身裤美女| 日日夜夜精品视频天天综合网| 欧日韩精品视频| 天堂在线一区二区| 欧美一级在线视频| 免费成人美女在线观看.| 精品福利二区三区| 国产成人在线网站| 亚洲日本电影在线| 91麻豆精品国产91久久久更新时间 | 欧美日韩一区视频| 免费观看一级欧美片| 久久你懂得1024| 91蜜桃网址入口| 亚洲h精品动漫在线观看| 日韩欧美中文字幕公布| 国产69精品久久99不卡| 一区二区三区在线高清| 日韩你懂的在线观看| 国产+成+人+亚洲欧洲自线| 亚洲美女视频在线观看| 欧美一区二区日韩| 91在线你懂得| 轻轻草成人在线| 亚洲婷婷综合久久一本伊一区| 欧美揉bbbbb揉bbbbb| 国产精品资源在线| 亚洲国产精品久久久久婷婷884 | 日韩一区二区三区高清免费看看| 国产美女精品人人做人人爽| 亚洲黄网站在线观看| 欧美精品一区二区在线观看| 色av一区二区| 成人av资源网站| 国产一区二区毛片| 免费高清在线一区| 亚洲超碰精品一区二区| 成人欧美一区二区三区小说| 日韩精品一区二区三区三区免费| 日本精品视频一区二区三区| 国产精品伊人色|