uuu
uuu (Universal Update Utility), mfgtools 3.0
 
Loading...
Searching...
No Matches
fat.h
Go to the documentation of this file.
1/*
2* Copyright 2018 NXP.
3*
4* Redistribution and use in source and binary forms, with or without modification,
5* are permitted provided that the following conditions are met:
6*
7* Redistributions of source code must retain the above copyright notice, this
8* list of conditions and the following disclaimer.
9*
10* Redistributions in binary form must reproduce the above copyright notice, this
11* list of conditions and the following disclaimer in the documentation and/or
12* other materials provided with the distribution.
13*
14* Neither the name of the NXP Semiconductor nor the names of its
15* contributors may be used to endorse or promote products derived from this
16* software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28* POSSIBILITY OF SUCH DAMAGE.
29*
30*/
31
32#pragma once
33
34#include "backfile.h"
35#include "buffer.h"
36
37#include <map>
38
39#pragma pack(1)
41{
42 uint8_t status;
43 uint8_t start_head;
44 uint8_t start_sector;
46 uint8_t type;
47 uint8_t end_head;
48 uint8_t end_sector;
49 uint8_t end_cylinder;
50 uint32_t lba_start;
51 uint32_t lba_num;
52};
53
55{
56 uint8_t filename[8];
57 uint8_t ext[3];
58 uint8_t attr;
59 uint8_t user_attr;
60 uint8_t delete_char;
61 uint16_t create_time;
62 uint16_t create_date;
63 uint16_t userid;
64 uint16_t access;
65 uint16_t modify_time;
66 uint16_t modify_date;
67 uint16_t start_cluster;
68 uint32_t file_size;
69};
70
71struct FatLFN
72{
73 uint8_t seq;
74 uint8_t name1[10];
75 uint8_t attr;
76 uint8_t type;
77 uint8_t sum;
78 uint8_t name2[12];
79 uint16_t start_cluster;
80 uint8_t name3[4];
81};
82
83#pragma pack()
84
85class Fat : public Backfile
86{
87public:
88 void *get_data_buff(shared_ptr<FileBuffer> p, int cluster);
89 int get_file_buff(string filename, shared_ptr<FileBuffer>p);
90 int get_next_cluster(shared_ptr<FileBuffer> p, int cluster);
91 string lfn2string(FatLFN *p);
92 int Open(string filename);
93
94 map<string, FatDirEntry> m_filemap;
95
96private:
97 uint64_t m_cluster;
103};
Definition backfile.h:37
Definition fat.h:86
string lfn2string(FatLFN *p)
Definition fat.cpp:185
uint64_t m_cluster
Definition fat.h:97
int get_file_buff(string filename, shared_ptr< FileBuffer >p)
Definition fat.cpp:146
int m_num_of_rootdir
Definition fat.h:101
int get_next_cluster(shared_ptr< FileBuffer > p, int cluster)
Definition fat.cpp:134
uint64_t m_fat_part_start
Definition fat.h:98
int Open(string filename)
Definition fat.cpp:41
map< string, FatDirEntry > m_filemap
Definition fat.h:94
uint64_t m_root_dir_offset
Definition fat.h:102
uint64_t m_logical_sector_perfat
Definition fat.h:100
void * get_data_buff(shared_ptr< FileBuffer > p, int cluster)
Definition fat.cpp:140
uint64_t m_fat_table_offset
Definition fat.h:99
Definition fat.h:55
uint16_t modify_date
Definition fat.h:66
uint8_t attr
Definition fat.h:58
uint8_t filename[8]
Definition fat.h:56
uint16_t create_time
Definition fat.h:61
uint16_t create_date
Definition fat.h:62
uint16_t access
Definition fat.h:64
uint8_t user_attr
Definition fat.h:59
uint16_t modify_time
Definition fat.h:65
uint16_t start_cluster
Definition fat.h:67
uint32_t file_size
Definition fat.h:68
uint8_t ext[3]
Definition fat.h:57
uint16_t userid
Definition fat.h:63
uint8_t delete_char
Definition fat.h:60
Definition fat.h:72
uint16_t start_cluster
Definition fat.h:79
uint8_t type
Definition fat.h:76
uint8_t name2[12]
Definition fat.h:78
uint8_t name1[10]
Definition fat.h:74
uint8_t sum
Definition fat.h:77
uint8_t seq
Definition fat.h:73
uint8_t name3[4]
Definition fat.h:80
uint8_t attr
Definition fat.h:75
Definition fat.h:41
uint8_t end_head
Definition fat.h:47
uint8_t type
Definition fat.h:46
uint8_t end_sector
Definition fat.h:48
uint8_t start_sector
Definition fat.h:44
uint32_t lba_start
Definition fat.h:50
uint8_t start_head
Definition fat.h:43
uint32_t lba_num
Definition fat.h:51
uint8_t end_cylinder
Definition fat.h:49
uint8_t status
Definition fat.h:42
uint8_t start_cylinder
Definition fat.h:45