CN107239526A - File system implementation method, scrap cleaning method, operating position localization method - Google Patents

File system implementation method, scrap cleaning method, operating position localization method Download PDF

Info

Publication number
CN107239526A
CN107239526A CN201710392808.2A CN201710392808A CN107239526A CN 107239526 A CN107239526 A CN 107239526A CN 201710392808 A CN201710392808 A CN 201710392808A CN 107239526 A CN107239526 A CN 107239526A
Authority
CN
China
Prior art keywords
fdt
fat
area
areas
cluster
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710392808.2A
Other languages
Chinese (zh)
Other versions
CN107239526B (en
Inventor
赵霄
杨清祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Henan Thought Rail Traffic Technology Research Institute Co Ltd
Original Assignee
Henan Thought Rail Traffic Technology Research Institute Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Henan Thought Rail Traffic Technology Research Institute Co Ltd filed Critical Henan Thought Rail Traffic Technology Research Institute Co Ltd
Priority to CN201710392808.2A priority Critical patent/CN107239526B/en
Publication of CN107239526A publication Critical patent/CN107239526A/en
Application granted granted Critical
Publication of CN107239526B publication Critical patent/CN107239526B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1724Details of de-fragmentation performed by the file system

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention provides a kind of file system implementation method, and distribution is stored in block Zhong FST areas, FDT areas, FAT area and aggregate of data area in memory block;FST areas represent file system information area;FDT areas represent file description information area;FAT area represents file allocation information area, aggregate of data area storage file content;FST areas store the initial address in FDT areas and the initial address of FAT area simultaneously;FDT areas set FDT tables;FAT area sets FAT table;FDT areas and FAT area are indexed by the initial address in FST areas, while passing through FDT table index file starting clusters, by the linking relationship of each cluster of FAT table index file, the whole file content stored by the annexation index data cluster area of each cluster.Block position where the FDT areas of the present invention, FAT area can update rotation with file, the corresponding area's initial address updated in FST is added while FDT areas, FAT area transfer, it is achieved thereby that FDT areas, FAT area, aggregate of data area are in the balanced rotation of whole memory space and erasable balance.

Description

File system implementation method, scrap cleaning method, operating position localization method
Technical field
The present invention relates to embedded file system field, and in particular to a kind of realization side of file system suitable for IC-card Method, the scope of application of the invention includes but is not limited to IC-card, is equally applicable to the file system of other memories similar with IC-card The realization of system.
Background technology
As electronic technology, computer technology are developed rapidly, either PC systems or embedded system, storage and The application demand for managing mass data is further extensive.IC cards are the flash cards designed exclusively for massive store, with cost Low, compatible good the advantages of.In some sector applications, in order to which IC cards can be with PC systems, embedded system according to spy Fixed form easily carries out data exchange, it is necessary to design document system, to shield the ins and outs of physical storage, being managed The information of reason is organized into document form, so as to increase the portable and maintainability of application, is easy to user effectively to manage largely Data, meanwhile, some special industries have certain confidentiality and privately owned customized demand to file content and form, thus build one The dedicated file system planted suitable for IC cards has certain practical significance.
Current many ripe file system existing on a general-purpose computer, such as FAT, NTFS file system and Unix, Linux file system, but above-mentioned file system be not suitable for IC cards directly use, subject matter has:First, IC cards are applied to Operated during PC systems by read write line, application environment is more severe, there is unstable supply voltage, burst power-off, frequently plug etc. Problem, universal document system considers not enough for the design of reliability;Secondly, when IC cards are applied to embedded device read-write, lead to With file system disc driver based on resourceful PC platforms and at a slow speed, it is necessary to expend ample resources, and it is embedded System often resource-constrained;Again, the Flash memory chip build-in attributes of IC cards determine that universal document system is uncomfortable With it is generally constituted by some pieces, and block is made up of some page/sectors, and page then includes the memory cell of certain amount byte. The read operation of Flash memories is consistent with disk, but write operation is different from disk, and universal document system is not corresponding to this Special design.Memory space base unit shared by Flash memory files is block, and data write operation must be in clear area Carried out after block or erasing in block, erasing requires to carry out in units of block Block(OxFF is write to memory to be erased Block), write operation is carried out by page/sector Page modes(It once must be written into a Page), and the erasing of Flash memories Number of times is limited, and Flash memories these inherent characteristics are must take into consideration when file system is set up on Flash memories, certain A little block over-erasures can cause the service life for substantially reducing flash storage.In view of general FAT file system is in IC-card The disadvantages mentioned above of upper application, needs a kind of file system implementation method suitable for IC-card of proposition badly.
The content of the invention
The present invention provides a kind of implementation method of file system, to solve the problem of prior art is present.
The present invention uses following technical scheme:
Distribution is stored in block Zhong FST areas, FDT areas, FAT area and aggregate of data area in file system implementation method, memory block;
The FST areas represent file system information area, for storage file system essential information;FDT areas represent file description letter Area is ceased, the essential information for storing description file, the essential information of the file at least includes file name, starting cluster, big Small, creation time;FAT area represents file allocation information area, for the distribution information of storage file, in aggregate of data area storage file Hold;
FST areas store the initial address in FDT areas and the initial address of FAT area simultaneously;
FDT areas set the file description information of storage file in FDT tables, FDT tables;When the operation to file causes file description letter When breath changes, FDT areas generate new FDT tables and stored;
FAT area sets cluster distribution condition and cluster annexation of the storage file in aggregate of data area in FAT table, FAT table;When to file Operation cause when changing of file allocation information, FAT area generates new FAT table and simultaneously stored;
When the operation to file causes file description information and/or file allocation information to change, FDT areas generate new FDT tables are simultaneously stored, and FAT area generates new FAT table and stored;
FDT areas and FAT area are indexed by the initial address in FST areas, while by FDT table index file starting clusters, passing through FAT The linking relationship of each cluster of table index file, the whole file content stored by the annexation index data cluster area of each cluster.
FST areas fixed storage is stored in different masses in block i, FDT areas and FAT area, and aggregate of data area is stored in remaining block; Wherein 0≤i≤N-1, N represent the number of block in memory block, and i represents i-th piece of memory block;
The FDT divides into FDT tables area and FDT table index areas, and FDT tables are stored in FDT tables area, can by FDT table index areas Index FDT tables;
FAT area is divided into FAT table area and FAT table index area, and FAT table is stored in FAT table area, can be indexed by FAT table index area To FAT table;
When the operation to file causes file description information to be changed with file allocation information, FDT areas and FAT area are carried out Operate below:
FDT areas:New FDT tables are regenerated, and are incrementally appended to next position of a FDT table, while in FDT table ropes Draw and be incremented by new effective call number in area, effective call number can index new FDT tables;When FDT table index areas are write completely, then The new Kuai Gei FDT areas of distribution, and the block where current FDT areas is wiped, while the initial address in Xin FDT areas is updated into FST Qu Zhong;
FAT area:New FAT table is regenerated, and is incrementally appended to next position of a FAT table, while in FAT table rope Draw and be incremented by new effective call number in area, effective call number can index new FAT table;When FAT table index area is write completely, then The new block of distribution wipes the block where current FAT area to FAT area, while the initial address of new FAT area is updated into FST Qu Zhong;
The initial address in FDT areas and the initial address of FAT area of FST areas storage are with block where block where FDT areas and FAT area Transfer is updated, and the update mode is the incremental additional mode write;After the block i that FST areas are stored adds full, whole block is triggered I erasing and rewriting.
The file system essential information of the FST areas storage includes system sector, cluster, block message, and the memory block is IC The flash storage of card.
The FDT tables, FAT table set mapping copy in internal memory, when the operation to file causes file description information With file allocation information when changing, the FDT tables and FAT table in internal memory are regenerated first, after the completion of generation, FDT tables and FAT table in internal memory is respectively written into memory block Zhong FDT areas and FAT area, by the FDT in FDT areas and FAT area Table and FAT table are updated to currently valid FDT tables and FAT table;
The FDT tables, the mapping copy of FAT table set dirty mark, the dirty FDT tables being marked in internal memory, FAT table hair respectively During changing, setting should be labeled as true, after FDT tables, FAT table are written back into memory block, and the dirty mark is eliminated;
When FDT tables in internal memory are synchronously written into the FDT areas of memory block:If the dirty mark of FDT tables has been removed and current memory In FDT tables it is consistent with the currently active FDT tables content in the FDT areas of memory block, then without being synchronously written;When any one is discontented When sufficient, the FDT tables in internal memory are synchronously written to the FDT tables in FDT areas, as the currently active FDT tables of memory block, simultaneously will The dirty mark of FDT tables in internal memory is removed;
When FAT table in internal memory is synchronously written into the FAT area of memory block:If the dirty mark of FAT table has been removed and current memory In FAT table it is consistent with the currently active FAT table content in the FAT area of memory block, then without being synchronously written;When any one is discontented When sufficient, the FAT table in internal memory is synchronously written to the FAT table in FAT area, as the currently active FAT table of memory block, simultaneously will The dirty mark of FAT table in internal memory is removed.
When specifying file write data in the area to aggregate of data, Write post area is set up in internal memory first, works as Write post After area is write completely, the tail cluster of currently assigned file is retrieved from FAT table first, while the residue for calculating cluster where the tail cluster is empty Between, if remaining space is not less than the size in Write post area, write-in length is the data of Write post area size;Otherwise tail is write The data of cluster remaining space size, while the new cluster write-in remaining data of continuation application.
The FAT table is made up of the tufted state of multiple 2 bytes, the tufted state include it is unallocated, distributed, it is dirty, terminate 4 kinds of states.
Scrap cleaning method:
Memory block is scanned in units of block, the ratio shared by the dirty cluster in each block is calculated, when the ratio is beyond setting Arrangement threshold value when, to file system carry out defragmentation;The dirty cluster is:Deletion action to file makes cluster shared by this document As dirty cluster;
When carrying out defragmentation to file system, FAT table is first checked for, effective cluster in block to be arranged is retrieved, finds effective cluster Afterwards, free cluster is applied now, by effective cluster copy content into the free cluster newly applied;If effective cluster is end-of-file cluster, Only effective length in copy cluster, otherwise copies whole cluster content;
While copying cluster content, new FAT table is generated, while writing new cluster chain in new FAT table;Current cluster has been shifted Put dirty into rear whole cluster;
Operated more than repeating, until being dirty cluster entirely in whole block, wipe monoblock, and discharge correspondence FAT table, complete a fragment whole Reason.
Operating position localization method:
Fast Lookup Table is created in internal memory, one section of successive clusters is referred to as a cluster piece by multiple clusters for storing identical file Section, all cluster fragments are concentrated and are mapped in Fast Lookup Table, corresponding successive clusters sequence number is calculated by file operation position, are led to Cross Fast Lookup Table and obtain correspondence cluster number;
The step of realizing quickly searched is:
Travel through FAT table;Defining operation position successive clusters number=reading location/cluster size;All cluster fragments of Fast Lookup Table are traveled through, Successive clusters number subtracts the continuous number of clusters in current clip every time, until successive clusters number is less than the successive clusters in current clip Number, return the starting cluster number of this fragment and residue successive clusters number and the as corresponding cluster number of operating position.
Beneficial effects of the present invention:The present invention distributes four class regions, respectively file system in the memory block of memory Information data cluster area(FST)Area, file description information(FDT)Area, file allocation information(FAT)Area, aggregate of data area.FST areas consolidate Surely it is stored in some block, block position where FDT areas, FAT area can update rotation with file, FDT areas, FAT area are shifted While the additional corresponding area's initial address updated in FST, it is achieved thereby that FDT areas, FAT area, aggregate of data area are in whole storage sky Between balanced rotation and erasable balance.
Brief description of the drawings
Fig. 1 is IC-card file system management subregion schematic diagram.
Internal memory write-back schematic diagram of the Tu2Shi FDT areas when FDT tables change.
Fig. 3 is IC-card file system initialization schematic diagram.
Fig. 4 is the quick positioning schematic diagram of cluster where file operation position.
Embodiment
Below in conjunction with the accompanying drawings 1 ~ 4 and embodiment the present invention is described in further detail.
The present invention provides a kind of implementation method of file system, is especially adapted for use in IC-card and its storage similar with IC-card The file system implementation method of device, this method is accomplished by the following way.
Distribution is stored in block Zhong FST areas, FDT areas, FAT area and aggregate of data area first in the memory block of memory;Its Middle FST areas represent file system information area, and the area is used for storage file system essential information, the information such as sector, block, cluster; FDT areas represent file description information area, and the area is used for the essential information for storing description file, and the essential information of file at least includes File name, starting cluster, size, creation time, state of file etc.;FAT area represents file allocation information area, for storing text The distribution information of part, aggregate of data area storage file content.FST areas fixed storage is stored in difference in block i, FDT areas and FAT area Block, aggregate of data area is stored in remaining block;Wherein 0≤i≤N-1, N represent the number of block in memory block, and i represents the i-th of memory block Block;Block position where FDT areas, FAT area update rotation with file.
FST areas store the initial address in FDT areas and the initial address of FAT area simultaneously, and these addresses with FDT areas and The transfer of block is updated where FAT areas, and its address updates can be using WriteMode be incrementally added, so that existing in FST areas many Group FDT areas and the initial address in FAT areas, but only one group of latest update is currently valid, and then whenever all to ensure Neng Cong FST index FDT areas and FAT areas in area.
FDT areas and FAT area are indexed by the initial address in FST areas, while by FDT table index file starting clusters, passing through The linking relationship of each cluster of FAT table index files, the whole file of index data cluster area storage is capable of by the annexation of each cluster Content.
FDT areas set the file description information of storage file in FDT tables, FDT tables;When the operation to file causes file to retouch When stating information and changing, FDT areas generate new FDT tables and simultaneously stored.
It is of the invention preferential using the renewal that WriteMode carries out FDT tables is incrementally added, now, FDT divide into FDT tables area and FDT table index areas, FDT tables are stored in FDT tables area, and FDT tables can be indexed by FDT table index areas;The storage of FDT tables area is more Individual FDT tables, and it is effective that any time, which only has a FDT table, the effective table is usually the table of latest update.It is used as one kind The description information of most 256 files can be stored in embodiment, FDT tables, the description information includes the state of file, risen The information such as beginning cluster, title, size, creation time.The operation such as read-write, additions and deletions, renaming of file would generally cause above- mentioned information Change, so as to need the FDT tables that upgrade in time.
, it is necessary to regenerate new FDT tables first when updating FDT tables, and incrementally it is appended to a upper FDT in FDT tables area Next position of table, while being incremented by new effective call number in FDT table index areas, effective call number can be indexed newly FDT tables;When FDT table index areas write full, the block where representing FDT areas has write full, now distributes new Kuai Gei FDT areas, and The block where current FDT areas is wiped, while the initial address in Xin FDT areas is updated in FST areas.
FAT area sets cluster distribution condition and cluster annexation of the storage file in aggregate of data area in FAT table, FAT table;When right The operation of file causes when changing of file allocation information, and FAT area generates new FAT table and stored.
When using the renewal for incrementally adding WriteMode progress FAT table, FAT area is divided into FAT table area and FAT table index area, FAT table is stored in FAT table area, and FAT table can be indexed by FAT table index area.FAT table area stores multiple FAT tables, and arbitrarily It is effective that moment, which only has a FAT table, and the effective table is usually the table of latest update.FAT table is used for characterizing All Files Cluster distribution condition and cluster linking relation in whole aggregate of data area, it is made up of the tufted state of multiple 2 bytes, and tufted state includes It is unallocated, distributed, it is dirty, terminate 4 kinds of states, done state represents that current cluster is end of file cluster.Read-write, the additions and deletions of file And the operation such as defragmentation would generally cause the new distribution of document cluster, the state change such as dirty be put, so as to need the FAT that upgrades in time Table.
When updating FAT table, new FAT table is regenerated first, and be incrementally appended to a upper FAT table in FAT table area Next position, while being incremented by new effective call number in FAT table index area, effective call number can index new FAT table;When FAT table index area writes full, the block where representing FAT area has write full, then distributes new block to FAT area, and wipe Block where current FAT area, while the initial address of new FAT area is updated in FST areas.
In above process, the initial address in FDT areas and the initial address of FAT area of FST areas storage are with where FDT areas The transfer of block is updated where block and FAT area, and also address incrementally adds the mode write, the storage of Ji FST areas to the update mode The initial address in a upper FDT area and next position of initial address of a upper FAT area increase new initial address, should Initial address can index currently valid FDT areas and FAT area;After the block i that FST areas are stored adds full, because FST areas are solid Surely it is stored in a certain piece, therefore, no longer carries out position fast where rotation updates, but directly trigger whole block i erasing And the rewriting in block i.Based on foregoing, realize FDT areas, FAT areas, aggregate of data area whole memory space equilibrium rotation With erasable balance.
Because each operation to file is required to update FAT table and/or FDT tables, therefore in order to avoid in memory block The frequent rewriting of FDT tables and FAT table, causes some pieces in memory block of reading-writing life-span to shorten.The present invention is by the FDT in memory block Table, FAT table set the identical mapping copy of form in internal memory, when the operation to file cause file description information with When changing of file allocation information, regenerates to the FDT tables and FAT table in internal memory first, after the completion of generation, will FDT tables and FAT table in internal memory are respectively written into memory block Zhong FDT areas and FAT area, by the FDT tables in FDT areas and FAT area Currently valid FDT tables and FAT table are updated to FAT table.
Need to set dirty mark respectively in FDT tables, the mapping copy of FAT table, dirty FDT tables, the FAT being marked in internal memory When table changes, setting should be labeled as true, after FDT tables, FAT table are written back into memory block, and the dirty mark is eliminated.
When FDT tables in internal memory are synchronously written into the FDT areas of memory block:If the dirty mark of FDT tables has been removed and currently FDT tables in internal memory are consistent with the currently active FDT tables content in the FDT areas of memory block, then without being synchronously written;When above-mentioned FDT tables in internal memory when being unsatisfactory for, are synchronously written the FDT tables in FDT areas, are used as the currently active FDT of memory block by one Table, while the dirty mark of the FDT tables in internal memory is removed.
When FAT table in internal memory is synchronously written into the FAT area of memory block:If the dirty mark of FAT table has been removed and currently FAT table in internal memory is consistent with the currently active FAT table content in the FAT area of memory block, then without being synchronously written;Work as any one When being unsatisfactory for, the FAT table in internal memory is synchronously written to the FAT table in FAT area, as the currently active FAT table of memory block, together When the dirty mark of the FAT table in internal memory is removed.
When specifying file write data into file system data cluster area, in order to avoid too frequent writes, it is limited to simultaneously The minimum writing unit of current flash storage, this invention takes the mode for being previously written buffering area.Built first in internal memory Vertical Write post area, after Write post area is write completely, retrieves the tail cluster of currently assigned file from FAT table first, should while calculating The remaining space of cluster where tail cluster, if remaining space is not less than the size in Write post area, write-in length is that Write post area is big Small data;Otherwise the data of tail cluster remaining space size are write, while the new cluster write-in remaining data of continuation application.
When reading specified file from file system, it is necessary first to the first cluster content of file, Ran Hougen are found in FDT areas Cluster where reading original position along the cluster chain search in FAT table according to incoming reading skew, then reads this cluster inclined out of cluster Move on to the data of cluster tail, if compare reading length it is still inadequate when, continue other clusters on across cluster readings cluster chain data until reading Length needed for enough.
Cluster shared by this document is caused to turn into dirty cluster due to carrying out deletion action to file, therefore file system needs to provide broken Piece arrangement function, to rearrange file, is stored in continuous cluster block, while discharging dirty cluster space by file as far as possible.
When carrying out defragmentation, memory block is scanned in units of block first, calculated shared by the dirty cluster in each block Ratio, when the ratio beyond setting arrangement threshold value when, carry out defragmentation.During arrangement, FAT table is first checked for, retrieval is treated Effective cluster in block is arranged, finds after effective cluster, applies for free cluster in non-block to be arranged immediately, by effective cluster copy content Into the free cluster newly applied;If effective cluster is end-of-file cluster, the effective length in effective cluster is only copied, is otherwise copied whole Cluster content;While copying cluster content, new FAT table is generated, while writing new cluster chain in new FAT table;Current cluster turns Whole cluster puts dirty after the completion of shifting;Operated more than repeating, until being dirty cluster entirely in whole block, wipe monoblock, and discharge correspondence FAT table, Complete a defragmentation.Block to be arranged refers to block of the ratio shared by dirty cluster beyond the arrangement threshold value of setting.
As shown in figure 4, the chain type of file disperses to need to travel through cluster chain when storage causes the positioning of file operation position, and very When many, some clusters of identical file are adjacent, and one section of successive clusters is referred to as into a cluster fragment, one is now set in internal memory Individual Fast Lookup Table, all cluster fragments of identical file are concentrated and are mapped in a Fast Lookup Table, by file operation position Corresponding successive clusters sequence number is calculated, correspondence cluster number can be obtained by Fast Lookup Table.Quick finding step:FAT is traveled through, is created Fast Lookup Table;Operating position successive clusters number=reading location/cluster size;Travel through all fragments of Fast Lookup Table, successive clusters number The continuous number of clusters in current clip is subtracted every time, until successive clusters number is less than the continuous number of clusters in current clip, returns to this The starting cluster number of fragment and remaining successive clusters number and the as corresponding cluster number of operating position.
It is, as FST fixed memory block, file system to be used to the IC-card using Flash using block 0 as shown in Fig. 1 ~ 3 The method of system.
Used in the Flash memories of IC-card before file system, it is necessary to carry out newly-built i.e. form to file system Change.The formatting of file system includes two steps of hard format and soft formatization, is to carry out hard format to IC chip first, So that all bytes set to 0 xFF, then need to carry out soft format according to File system design form.
The soft format of file system includes:
As shown in Figure 1,3, corresponding document system Global Information is filled according to flash storage block, cluster, sector auxiliary information, is assigned to FST The corresponding informance in area, then, the address of block 1 is assigned to the FDT areas initial address message (IAM) in FST areas, the address of block 2 is assigned into FST The FAT area initial address message (IAM) in area, Bing Jiang FST areas write-in block 0.So far, the initialization in FST areas is completed.
According to Zhong FDT areas of FST areas initial address message (IAM), FDT tables are indexed, its table content is all set to 0 into xFF and by rope Draw byte and be set to 0x55550000, so far, complete FDT initialization.
Mentioned above, system FST takes block 0, and FDT takes block 1, meanwhile, design FAT takes block 2.So, FAT table Preceding 3 pieces of FAT bytes are set to particular value 0xFFF1,0xFFF2,0xFFF3 respectively, are taken with characterizing it by special, remaining FAT table Byte put full 0, to characterize it as still unappropriated cluster.Then, index byte is set to 0xAAAA0000, so far, completes FAT Initialization.
Need to carry out carry before file system operation., it is necessary to by currently valid FDT during the carry of file system Table, FAT tables are moved into internal memory from Flash to adapt to possible frequent modification, meanwhile, to ensure in internal memory and Flash The uniformity of appearance, designing FDT in the dirty mark of respective table, internal memory, the change of FAT table can cause the dirty mark to be, and to Flash Write-back can remove dirty mark.
File write operations can cause the change of file size, change of cluster chain etc., generally require to update FDT tables, FAT Table.Because FDT tables, FAT table all have mapping copy in internal memory, then corresponding renewal operation is directly depositing into row, internal memory inside After FDT tables, the change of FAT tables, Flash is written back into synchronize by two kinds of mechanism, a kind of is fixed, critical Running node, such as write-back FAT will be forced to prevent that FAT is asynchronous after data write-in failure by writing before data, and another is certain A little operations, such as file close operation.
The synchronous write FDT tables into Flash:Check that dirty mark has been removed, and compare internal memory FDT tables content and reading Whether the currently active FDT tables contents of Flash are consistent, and write-in need not be synchronized if meet simultaneously.Otherwise, having FDT areas Effect table index number Jia 1, sequentially writes newest call number in index area, performed simultaneously, sequentially renewal table area is write in location, by current memory Newest index of the FDT table copy contents into Flash points to position, and clear dirty mark.When incrementally writing call number, if currently Index area has write full, then block where characterizing current FDT areas has been write full, it is necessary to move, that is, distributes new Kuai Gei FDT areas, simultaneously Initial address message (IAM) of the FDT areas in FST is updated, and because new block distributes the FAT table caused change, then by original piece Erasing.
The synchronous write FAT table into Flash:Check that dirty mark has been removed, and compare internal memory FAT table content and reading Whether the currently active FAT table contents of Flash are consistent, and write-in need not be synchronized if meet simultaneously.Otherwise, by FAT directorial areas Effective table index number Jia 1, sequentially write newest call number in index area, performed simultaneously, sequentially renewal table area is write in location, will be current Newest index of the internal memory FAT table copy content into Flash points to position, and clear dirty mark.When incrementally writing call number, if Current index area has write full, then block where characterizing current FAT directorial areas has been write full, it is necessary to move, that is, distributes new block and managed to FAT Area is managed, while to update initial address message (IAM) of the FAT directorial areas in FST, and is become because new block distributes the FAT table caused Change, then by original piece of erasing.
Above-described is only the preferred embodiment of the present invention, it is noted that for those skilled in the art, Under the premise of general idea of the present invention is not departed from, some changes and improvements can also be made, these should also be considered as the present invention's Protection domain.

Claims (8)

1. file system implementation method, it is characterised in that:In memory block distribution be stored in block Zhong FST areas, FDT areas, FAT area and Aggregate of data area;
The FST areas represent file system information area, for storage file system essential information;FDT areas represent file description letter Area is ceased, the essential information for storing description file, the essential information of the file at least includes file name, starting cluster, big Small, creation time;FAT area represents file allocation information area, for the distribution information of storage file, in aggregate of data area storage file Hold;
FST areas store the initial address in FDT areas and the initial address of FAT area simultaneously;
FDT areas set the file description information of storage file in FDT tables, FDT tables;When the operation to file causes file description letter When breath changes, FDT areas generate new FDT tables and stored;
FAT area sets cluster distribution condition and cluster annexation of the storage file in aggregate of data area in FAT table, FAT table;When to file Operation cause when changing of file allocation information, FAT area generates new FAT table and simultaneously stored;
When the operation to file causes file description information and/or file allocation information to change, FDT areas generate new FDT tables are simultaneously stored, and FAT area generates new FAT table and stored;
FDT areas and FAT area are indexed by the initial address in FST areas, while by FDT table index file starting clusters, passing through FAT The linking relationship of each cluster of table index file, the whole file content stored by the annexation index data cluster area of each cluster.
2. file system implementation method according to claim 1, it is characterised in that:
FST areas fixed storage is stored in different masses in block i, FDT areas and FAT area, and aggregate of data area is stored in remaining block;Wherein 0≤i≤N-1, N represent the number of block in memory block, and i represents i-th piece of memory block;
The FDT divides into FDT tables area and FDT table index areas, and FDT tables are stored in FDT tables area, can by FDT table index areas Index FDT tables;
FAT area is divided into FAT table area and FAT table index area, and FAT table is stored in FAT table area, can be indexed by FAT table index area To FAT table;
When the operation to file causes file description information to be changed with file allocation information, FDT areas and FAT area are carried out Operate below:
FDT areas:New FDT tables are regenerated, and are incrementally appended to next position of a FDT table, while in FDT table ropes Draw and be incremented by new effective call number in area, effective call number can index new FDT tables;When FDT table index areas are write completely, then The new Kuai Gei FDT areas of distribution, and the block where current FDT areas is wiped, while the initial address in Xin FDT areas is updated into FST Qu Zhong;
FAT area:New FAT table is regenerated, and is incrementally appended to next position of a FAT table, while in FAT table rope Draw and be incremented by new effective call number in area, effective call number can index new FAT table;When FAT table index area is write completely, then The new block of distribution wipes the block where current FAT area to FAT area, while the initial address of new FAT area is updated into FST Qu Zhong;
The initial address in FDT areas and the initial address of FAT area of FST areas storage are with block where block where FDT areas and FAT area Transfer is updated, and the update mode is the incremental additional mode write;After the block i that FST areas are stored adds full, whole block is triggered I erasing and rewriting.
3. file system implementation method according to claim 1, it is characterised in that:The file system of the FST areas storage Essential information includes system sector, cluster, block message, and the memory block is the flash storage of IC-card.
4. file system implementation method according to claim 1, it is characterised in that:The FDT tables, FAT table are in internal memory It is middle that mapping copy is set, when the operation to file causes file description information and when changing of file allocation information, first FDT tables and FAT table in internal memory is regenerated, after the completion of generation, the FDT tables and FAT table in internal memory are respectively written into To memory block Zhong FDT areas and FAT area, the FDT tables and FAT table in FDT areas and FAT area are updated to currently valid FDT tables And FAT table;
The FDT tables, the mapping copy of FAT table set dirty mark, the dirty FDT tables being marked in internal memory, FAT table hair respectively During changing, setting should be labeled as true, after FDT tables, FAT table are written back into memory block, and the dirty mark is eliminated;
File system implementation method according to claim 4, it is characterised in that:
When FDT tables in internal memory are synchronously written into the FDT areas of memory block:If the dirty mark of FDT tables has been removed and current memory In FDT tables it is consistent with the currently active FDT tables content in the FDT areas of memory block, then without being synchronously written;When any one is discontented When sufficient, the FDT tables in internal memory are synchronously written to the FDT tables in FDT areas, as the currently active FDT tables of memory block, simultaneously will The dirty mark of FDT tables in internal memory is removed;
When FAT table in internal memory is synchronously written into the FAT area of memory block:If the dirty mark of FAT table has been removed and current memory In FAT table it is consistent with the currently active FAT table content in the FAT area of memory block, then without being synchronously written;When any one is discontented When sufficient, the FAT table in internal memory is synchronously written to the FAT table in FAT area, as the currently active FAT table of memory block, simultaneously will The dirty mark of FAT table in internal memory is removed.
5. file system implementation method according to claim 1, it is characterised in that:
When specifying file write data in the area to aggregate of data, Write post area is set up in internal memory first, when Write post area is write After full, the tail cluster of currently assigned file is retrieved from FAT table first, while calculating the remaining space of cluster where the tail cluster, such as Fruit remaining space is not less than the size in Write post area, then writes the data that length is Write post area size;Otherwise write-in tail cluster is remained The data of complementary space size, while the new cluster write-in remaining data of continuation application.
6. file system implementation method according to claim 1, it is characterised in that:
The FAT table is made up of the tufted state of multiple 2 bytes, the tufted state include it is unallocated, distributed, it is dirty, terminate 4 kinds State.
7. the scrap cleaning method based on the file system described in claim 1, it is characterised in that:
Memory block is scanned in units of block, the ratio shared by the dirty cluster in each block is calculated, when the ratio is beyond setting Arrangement threshold value when, to file system carry out defragmentation;The dirty cluster is:Deletion action to file makes cluster shared by this document As dirty cluster;
When carrying out defragmentation to file system, FAT table is first checked for, effective cluster in block to be arranged is retrieved, finds effective cluster Afterwards, free cluster is applied now, by effective cluster copy content into the free cluster newly applied;If effective cluster is end-of-file cluster, Only effective length in copy cluster, otherwise copies whole cluster content;
While copying cluster content, new FAT table is generated, while writing new cluster chain in new FAT table;Current cluster has been shifted Put dirty into rear whole cluster;
Operated more than repeating, until being dirty cluster entirely in whole block, wipe monoblock, and discharge correspondence FAT table, complete a fragment whole Reason.
8. the operating position localization method based on the file system described in claim 1, it is characterised in that:
Fast Lookup Table is created in internal memory, one section of successive clusters is referred to as a cluster piece by multiple clusters for storing identical file Section, all cluster fragments are concentrated and are mapped in Fast Lookup Table, corresponding successive clusters sequence number is calculated by file operation position, are led to Cross Fast Lookup Table and obtain correspondence cluster number;
The step of realizing quickly searched is:
Travel through FAT table;Defining operation position successive clusters number=reading location/cluster size;All cluster fragments of Fast Lookup Table are traveled through, Successive clusters number subtracts the continuous number of clusters in current clip every time, until successive clusters number is less than the successive clusters in current clip Number, return the starting cluster number of this fragment and residue successive clusters number and the as corresponding cluster number of operating position.
CN201710392808.2A 2017-05-27 2017-05-27 File system implementation method, defragmentation method and operation position positioning method Active CN107239526B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710392808.2A CN107239526B (en) 2017-05-27 2017-05-27 File system implementation method, defragmentation method and operation position positioning method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710392808.2A CN107239526B (en) 2017-05-27 2017-05-27 File system implementation method, defragmentation method and operation position positioning method

Publications (2)

Publication Number Publication Date
CN107239526A true CN107239526A (en) 2017-10-10
CN107239526B CN107239526B (en) 2020-11-13

Family

ID=59984705

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710392808.2A Active CN107239526B (en) 2017-05-27 2017-05-27 File system implementation method, defragmentation method and operation position positioning method

Country Status (1)

Country Link
CN (1) CN107239526B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108491402A (en) * 2018-01-17 2018-09-04 艾体威尔电子技术(北京)有限公司 A kind of implementation method of lightweight file system
CN108647278A (en) * 2018-05-03 2018-10-12 中北大学 A kind of file management method and system
CN108664577A (en) * 2018-05-03 2018-10-16 中北大学 A kind of file management method and system based on the free areas FLASH
CN109597793A (en) * 2018-12-04 2019-04-09 中国航空工业集团公司西安航空计算技术研究所 A method of promoting file system IO performance
CN109739683A (en) * 2018-12-31 2019-05-10 河南思维自动化设备股份有限公司 LKJ file wiring method, storage medium based on power down protective media
CN112764689A (en) * 2021-02-02 2021-05-07 湖南师范大学 Airborne radar-oriented data storage file management method and management system
CN113806803A (en) * 2021-09-17 2021-12-17 厦门服云信息科技有限公司 Data storage method, system, terminal equipment and storage medium
CN113934371A (en) * 2021-10-08 2022-01-14 福建星网视易信息系统有限公司 Memory, data management method thereof and computer storage medium
CN114237513A (en) * 2021-12-17 2022-03-25 四川九洲空管科技有限责任公司 File data memory, writing method, reading method and storage system
CN115129244A (en) * 2022-05-20 2022-09-30 杭州高特电子设备股份有限公司 FLASH chip-based battery management system data storage management method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030105918A1 (en) * 2001-12-05 2003-06-05 Plourde Harold J. Disk driver cluster management of time shift buffer with file allocation table structure
CN1632765A (en) * 2004-12-31 2005-06-29 大唐微电子技术有限公司 A flash memory file system management method
CN101441634A (en) * 2007-11-19 2009-05-27 凤凰微电子(中国)有限公司 Embedded type file system suitable for smart card application environment
CN101853417A (en) * 2010-05-24 2010-10-06 北京飞天诚信科技有限公司 Working method and system of CF (Compact Flash) interface information safety equipment
CN102110145A (en) * 2011-02-15 2011-06-29 中国科学院计算技术研究所 Micro FAT file system and quick data access method thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030105918A1 (en) * 2001-12-05 2003-06-05 Plourde Harold J. Disk driver cluster management of time shift buffer with file allocation table structure
CN1632765A (en) * 2004-12-31 2005-06-29 大唐微电子技术有限公司 A flash memory file system management method
CN101441634A (en) * 2007-11-19 2009-05-27 凤凰微电子(中国)有限公司 Embedded type file system suitable for smart card application environment
CN101853417A (en) * 2010-05-24 2010-10-06 北京飞天诚信科技有限公司 Working method and system of CF (Compact Flash) interface information safety equipment
CN102110145A (en) * 2011-02-15 2011-06-29 中国科学院计算技术研究所 Micro FAT file system and quick data access method thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孙亚娟: ""基于S3C2410航迹标绘控制系统设计与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108491402B (en) * 2018-01-17 2021-09-21 艾体威尔电子技术(北京)有限公司 Method for implementing lightweight file system
CN108491402A (en) * 2018-01-17 2018-09-04 艾体威尔电子技术(北京)有限公司 A kind of implementation method of lightweight file system
CN108647278A (en) * 2018-05-03 2018-10-12 中北大学 A kind of file management method and system
CN108664577A (en) * 2018-05-03 2018-10-16 中北大学 A kind of file management method and system based on the free areas FLASH
CN108647278B (en) * 2018-05-03 2021-07-02 中北大学 File management method and system
CN109597793A (en) * 2018-12-04 2019-04-09 中国航空工业集团公司西安航空计算技术研究所 A method of promoting file system IO performance
CN109739683B (en) * 2018-12-31 2022-08-05 河南思维自动化设备股份有限公司 LKJ file writing method based on power failure protection medium and storage medium
CN109739683A (en) * 2018-12-31 2019-05-10 河南思维自动化设备股份有限公司 LKJ file wiring method, storage medium based on power down protective media
CN112764689A (en) * 2021-02-02 2021-05-07 湖南师范大学 Airborne radar-oriented data storage file management method and management system
CN113806803A (en) * 2021-09-17 2021-12-17 厦门服云信息科技有限公司 Data storage method, system, terminal equipment and storage medium
CN113806803B (en) * 2021-09-17 2023-06-02 厦门服云信息科技有限公司 Data storage method, system, terminal equipment and storage medium
CN113934371A (en) * 2021-10-08 2022-01-14 福建星网视易信息系统有限公司 Memory, data management method thereof and computer storage medium
CN113934371B (en) * 2021-10-08 2024-04-12 福建星网视易信息系统有限公司 Memory, data management method thereof and computer storage medium
CN114237513A (en) * 2021-12-17 2022-03-25 四川九洲空管科技有限责任公司 File data memory, writing method, reading method and storage system
CN115129244A (en) * 2022-05-20 2022-09-30 杭州高特电子设备股份有限公司 FLASH chip-based battery management system data storage management method
CN115129244B (en) * 2022-05-20 2024-04-26 杭州高特电子设备股份有限公司 FLASH chip-based battery management system data storage management method

Also Published As

Publication number Publication date
CN107239526B (en) 2020-11-13

Similar Documents

Publication Publication Date Title
US11640353B2 (en) Memory system, data storage device, user device and data management method thereof
CN107239526A (en) File system implementation method, scrap cleaning method, operating position localization method
US10649910B2 (en) Persistent memory for key-value storage
US6587915B1 (en) Flash memory having data blocks, spare blocks, a map block and a header block and a method for controlling the same
US8156165B2 (en) Transaction-safe FAT files system
US8024507B2 (en) Transaction-safe FAT file system improvements
US7761655B2 (en) Storage system and method of preventing deterioration of write performance in storage system
US20080109589A1 (en) Nonvolatile Storage Device And Data Write Method
CN102779096B (en) Page, block and face-based three-dimensional flash memory address mapping method
CN100426259C (en) Virtual access method of storage document data
CN101189584B (en) Managing memory pages
EP2286341A1 (en) Method and system for storage address re-mapping for a multi-bank memory device
CN106326229B (en) File storage method and device of embedded system
KR20070060070A (en) Fat analysis for optimized sequential cluster management
CN108733306A (en) A kind of Piece file mergence method and device
CN103996412A (en) Power-fail protection method applied to intelligent-card nonvolatile memories
CN101876927A (en) Power-off protection method for realizing FAT32 file system, and device thereof
US8239427B2 (en) Disk layout method for object-based storage devices
CN102541753B (en) A kind of read-write optimization method of in-line memory
CN114610228A (en) File management system and file management method and device thereof
US7533225B1 (en) Method and apparatus for enabling adaptive endianness
US20220164135A1 (en) Apparatus, method and computer program for managing memory page updates within non-volatile memory
CN107608636A (en) A kind of data acquisition device of design method and its application based on FAT file system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant