CN1776640A - FAT file system error treating method and device - Google Patents

FAT file system error treating method and device Download PDF

Info

Publication number
CN1776640A
CN1776640A CN 200510130648 CN200510130648A CN1776640A CN 1776640 A CN1776640 A CN 1776640A CN 200510130648 CN200510130648 CN 200510130648 CN 200510130648 A CN200510130648 A CN 200510130648A CN 1776640 A CN1776640 A CN 1776640A
Authority
CN
China
Prior art keywords
fat
file
file system
allocation table
disposal route
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
CN 200510130648
Other languages
Chinese (zh)
Other versions
CN100389396C (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.)
Vimicro Corp
Original Assignee
Vimicro Corp
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 Vimicro Corp filed Critical Vimicro Corp
Priority to CNB2005101306481A priority Critical patent/CN100389396C/en
Publication of CN1776640A publication Critical patent/CN1776640A/en
Application granted granted Critical
Publication of CN100389396C publication Critical patent/CN100389396C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

There are three file allocation tables in FAT area. The three tables are updated in sequence. When error occurs, specific error condition can be determined. Using correct tables restore the table with error so as to ensure normal running of system. The invention can safely restore FAT table to correct state quickly and effectively.

Description

A kind of FAT file system mistake disposal route and device thereof
Technical field
The present invention relates to the Computer Organization Principles field, be specifically related to the mistake disposal route in the FAT file system and make in this way device.
Background technology
Data on the hard disk are broadly divided into 5 parts according to its different characteristics and effect: MBR district, DBR district, FAT district, DIR district and DATA district.
MBR Main Boot Record district (Main Boot Record) is usually located at 0 magnetic track, 0 cylinder, 1 sector of DISK to Image.
Main Boot Record has comprised series of parameters and one section boot of hard disk.The main effect of hard disk boot wherein is to check whether partition table correctly and at system hardware finishes the later operating system that guides on the subregion with activation marker of self check, and gives start-up routine with control.MBR is produced by partition programs (as Fdisk.com), and it does not rely on any operating system.
DBR booting operating system recording areas (Dos Boot Record), it is usually located at 0 magnetic track, 1 cylinder, 1 sector of hard disk, be first sector that operating system can directly be visited, it comprises a boot and this subregion reference record table that is called as BPB (Bios Parameter Block).The main task of boot is when MBR gives it with system's control, judges the boot files (with DOS is example, promptly is Io.sys and Msdos.sys) that this subregion is an operating system with preceding two files of catalogue.If determine to exist, just it read in internal memory, and give this document control.The BPB parameter block is writing down initial sector, end sector, file memory format, hard disk media descriptor, root directory size, the FAT number of this subregion, important parameters such as the size of allocation units.
FAT file allocation table (File Allocation Table) is positioned at after the DBR, since 0 magnetic track, 1 cylinder, 33 sectors.
File allocation table is duplicate, and after a disk was formatted, it was arranged in several sectors of back, logical zero sector (being boot sector), occupies how much being decided by disk type and size of sector.File allocation table is the assignment information that is used for representing disk space.It does not represent the information of boot section, file directory, yet inreal storage file content.
Owing in the continuous zone leaving disk in that the data of a file might not be complete, and tend to be divided into plurality of sections, deposit as a chain.This storage mode is called the chain type storage of file.Operations such as the file on the hard disk usually will be created, deletes, increases, shortening.What operation was done like this is many more, and the file on the dish just may be got scrappy more (every section is 1 bunch at least).But, since on the hard disk in store section with section between link information (being FAT), operating system always can find the position of each section also correctly to read when reading file exactly.
In order to realize the chain type storage of file, must write down which bunch exactly on the hard disk is taken by file, the next one that bunch indicates the follow-up content of storage that is necessary for also that each has taken bunch bunch number, to the last cluster of a file, then to indicate no follow-up bunch of this bunch.These are all preserved by FAT (file allocation table), and a lot of list items (entry) are arranged in the table, every information that writes down one bunch.
Because FAT (file allocation table) so it has a backup, promptly builds a same FAT in the back of former FAT for the importance of file management again, is called FAT1 and FAT2 usually.
DIR root directory area (Directory), and then the 2nd FAT table (i.e. the FAT of backup table) afterwards, is writing down the start element of each file (catalogue) under the root directory, the attribute of file etc.During the locating file position, operating system just can have been known the particular location of file in hard disk and size according to the start element among the DIR in conjunction with the FAT table.
The data field is the place of data storage truly, is positioned at after the DIR district, occupies the most data spaces on the hard disk
This paper will mainly pay close attention in the FAT file system, the problem of file allocation table (FAT).Since the FAT table record storage chained list of data in magnetic disk file, for the reading of data, be extremely important, to such an extent as to Microsoft has created a backup for the table of the FAT in the FAT file system of its exploitation, be exactly FAT2.The content of FAT2 and FAT1 is normally instant synchronous, that is to say that FAT2 is updated too so if by normal system read-write FAT1 is changed.If from this view point, this function of system is a natural disaster when data are recovered.
When disk runs into wrong generation or is subjected to the destruction of virus, can recover FAT operation carrying out file.More satisfactory situation is, know that FAT1 is damaged, and FAT2 is intact, at this moment can cover FAT1 with FAT2, thereby reach the result of reparation.But, under a lot of situations, be not such situation.Because the content of 2 FAT is normally instant synchronous, therefore, often 2 tables all are ruined.Though brought convenience to a certain extent, still there is hidden danger in the design of such 2 file allocation table in the prior art, especially when mistake is handled.
Summary of the invention
The objective of the invention is to overcome the defective of present prior art, propose a kind of safe, simple, can effectively carry out the method that the disk mistake is handled, make can be returned to normal condition because of illegal interruption damages file allocation table.
The present invention proposes a kind of FAT file system mistake disposal route, and a plurality of file allocation table are wherein arranged in the file system, when file is carried out write operation, a plurality of file allocation table is upgraded; When these table appearance are inconsistent, inconsistent table is carried out overlapping operation with one or more table.
Above-mentioned FAT file system mistake disposal route, the number that a kind of preferred scheme is a file allocation table is 3.
Above-mentioned FAT file system mistake disposal route, a kind of preferred scheme is that a plurality of file allocation table are to write successively.
Above-mentioned FAT file system mistake disposal route, a kind of preferred scheme is to occur when inconsistent when a plurality of file allocation table, which FAT table is system revising when judging illegal the interruption with the time point in moment of illegal interruption, with other one or more tables inconsistent table carried out overlapping operation.
Above-mentioned FAT file system mistake disposal route, a kind of preferred scheme is that a plurality of file allocation table are to deposit continuously.
Above-mentioned FAT file system mistake disposal route, a kind of preferred scheme is that file allocation table is arranged on after the DBR.
The present invention also proposes a kind of device, the FAT file system mistake disposal route that this device has used the present invention to propose, and this device comprises CPU and storer, wherein, comprises a FAT file system in the reservoir, and a plurality of file allocation table are arranged in this file system; When file is carried out write operation, a plurality of file allocation table are upgraded; When these table appearance are inconsistent, inconsistent table is carried out overlapping operation with one or more table.
Above-mentioned device, a kind of preferred scheme is also to comprise the USB module, is used for this device is linked to each other with computing machine.
Above-mentioned device, a kind of preferred scheme are that CPU, the communication between the storer of device adopts dma mode to carry out data transmission.
Use FAT file system mistake disposal route of the present invention and device thereof,, when therefore going wrong, can judge situation about going wrong fast, effectively system is recovered from mistake in system owing to have a plurality of file allocation table.
Description of drawings
Fig. 1 is a file system structure synoptic diagram of the present invention;
Fig. 2 is the process flow diagram of file system operation of the present invention;
Fig. 3 is the module map of embodiments of the invention.
Embodiment
The FAT file system mistake disposal route that the present invention proposes, and make in this way device, be described as follows in conjunction with the accompanying drawings and embodiments.Following embodiment only is used to illustrate the present invention; and be not limitation of the present invention; the those of ordinary skill in relevant technologies field; under the situation that does not break away from the spirit and scope of the present invention; can also make various variations and modification; therefore all technical schemes that are equal to also belong to category of the present invention, and scope of patent protection of the present invention should be limited by every claim.
With reference to Fig. 3, in the present embodiment, whole FAT file system is placed in a slice Audio Processing chip, and this Audio Processing chip comprises CPU and memory portion, and wherein the data transmission between CPU and the storer adopts DMA (direct memory access (DMA)) transmission mode commonly used in the prior art.Specifically saying, in the storer of this sheet audio chip, be provided with a FAT file system.Because this FAT file system, therefore can finish management to exterior storage medium by it, for example read outside SD, MMC, the data in the NandFlash memory card by it.Thisly undertaken the management of exterior storage medium is belonged to prior art, be similar to and on multi-purpose computer, finish the management of USB storage equally, do not give unnecessary details at this by operating system by a file system.
In this MCU (microprogram control unit) system 1, the communication mode of data adopts dma mode.This device adopts audio processing modules commonly used in the prior art, supports the music playback function of midi, mp3, many kinds of forms of wave, also supports the broadcast of midi+wave, midi+mp3.These music datas can pass through the audio mixing module, output to EQ (intelligence) module, 3D module then, output to loudspeaker 2 then.
Also comprise the USB module in this MCU system, this Audio Processing chip can be by carrying out data transmission between this module and the multi-purpose computer (PC).
For the file system in being stored in storer, the structural representation of this file system as shown in Figure 1.This FAT file system comprises reserved area, FAT district, root directory area, file and catalogue data district.Wherein, the reserved area adopts the scheme the same with prior art, have systematic parameters such as MBR, DBR, the mistake disposal route that being provided with of FAT district used the present invention to propose, promptly in this FAT file system, total having is provided with 3 file allocation table (FAT) after DBR, and these FAT upgrade successively.
This document system also defines some function interfaces, is used for these FAT of reading and writing table, and searches, locatees, deletes relevant bunch etc.For example:
unsigned?char?f_getfatsector(unsigned?long?sector)
This function is finished the work of reading the FAT table from disk, and after device power, system can automatically perform this function usually, then,
unsigned?char?f_writefatsector(void)
This function is used to check whether the FAT table is consistent, and corresponding FAT table is write disk.System can read this function of FAT table back execution after the device power, confirms the situation of system.
According to the present invention, with the system that comprises 3 FAT table is example, cause file system corruption when abnormal conditions occurring, FAT table wherein is damaged, because the FAT table writes successively, that is to say that one of them FAT table duplicates other 2 FAT table after having revised again accordingly successively, when illegal the interruption taken place so 3 kinds of situations are arranged, the FAT table that unusual condition occurs only can be in 3 tables, only occurs in the time point because interrupt.Therefore, as long as judge it specifically is which kind of situation, promptly which FAT table makes a mistake on earth, just might recover system from mistake.Owing to have only 3 kinds of possible error situations, recovery operation in 3 that 3 kinds of situations have been distinguished correspondence:
System is upgrading FAT table 0 when (1) the illegal interruption being taken place.In this case, table 1 is identical with table 2, and recovery operation is with one of them covering table 0.
System is upgrading FAT table 1 when (2) the illegal interruption being taken place.In this case, three tables are different, and recovery operation is with table 0 covering table 1 and table 2.
System is upgrading FAT table 2 when (3) the illegal interruption being taken place.In this case, table 0 is identical with table 1, and recovery operation is with one of them table covering table 2.
The workflow of present embodiment as shown in Figure 2.After device power was finished self check, the workflow of FAT file system was:
System provides an initialization interface unsigned char fn_initvolume (unsignedlong bgn_sector, unsigned long end_sector), two parameters in this interface are represented initial, termination block (piece) number of the disk space that the FAT file system is managed respectively.System can resolve from initial block (bgn_sector) beginning reading of data.
Usually, the BPB parameter of FAT file system is first block that it can read, and all necessary parameter informations of system have been deposited in this data division the inside.In some cases, first block that system read not is BPB, but a MBR partition table, for such situation, the FAT system can resolve this partition table, finds the position of residing first block of FAT file system, carries out the parsing of BPB piece then equally.
After the BPB piece was resolved and to be finished, the FAT file system can obtain all required systematic parameters, for example size, number, the position of FAT table, position of root directory or the like.
Carry out the verification work of FAT table then.According to the present invention, system detects the situation of 3 file allocation table earlier, promptly adopts above-mentioned 2 functions: unsigned char f_getfatsector (unsigned long sector) and unsigned char f_writefatsector (void).If do not occur unusually, promptly 3 tables are consistent, carry out normal subsequent step; If run into mistake, adopt above-mentioned method to judge which table is mistake specifically appear at, and carries out recovery operation then.
Carry out the conventional processing operation of FAT file system then.
As seen, the FAT file system mistake disposal route that adopts the present invention to propose, because there are 3 FAT tables in file system, when therefore running into the mistake processing, just there are 3 kinds with different situation for 3 tables, which table is system can judge according to different situations easily is correct, thereby effectively system is recovered from mistake.Avoided in the prior art, can't determine which table of the end because having only 2 FAT table and mistake occur, also just can't judicious situation, cause problems such as system crash.
Similarly, for the situation that adopts more FAT table, 4 tables for example, 4 tables can present 4 kinds of situations when then going wrong, and system can be easy to judge correct situation from 4 kinds of situations, carry out recovery operation.Adopt the scheme of more FAT table, the scheme with adopting 3 FAT tables in the present embodiment duplicates.
This FAT file system that has adopted the FAT file system mistake disposal route of the present invention's proposition, those skilled in the art can apply it in other occasions, for example is applied in multi-purpose computer or other embedded developments.Present embodiment only is used to support the present invention, and protection scope of the present invention should be defined by the claims.

Claims (9)

1, a kind of FAT file system mistake disposal route is characterized in that a plurality of file allocation table are arranged in the file system, when file is carried out write operation, a plurality of file allocation table is upgraded; When these table appearance are inconsistent, inconsistent table is carried out overlapping operation with one or more table.
2, FAT file system mistake disposal route as claimed in claim 1, the number that it is characterized in that file allocation table is 3.
3, FAT file system mistake disposal route as claimed in claim 1 is characterized in that a plurality of file allocation table write successively.
4, FAT file system mistake disposal route as claimed in claim 1, it is characterized in that occurring when inconsistent when a plurality of file allocation table, which FAT table is system revising when judging illegal the interruption with the time point in moment of illegal interruption, with other one or more tables inconsistent table carried out overlapping operation.
5, FAT file system mistake disposal route as claimed in claim 1 is characterized in that a plurality of file allocation table deposit continuously.
6, FAT file system mistake disposal route as claimed in claim 1 is characterized in that it is after the booting operating system recording areas that file allocation table is arranged on DBR.
7, a kind of device that uses the method for claim 1 comprises CPU and storer, it is characterized in that comprising in the storer FAT file system, and a plurality of file allocation table are arranged in this file system; When file is carried out write operation, a plurality of file allocation table are upgraded; When these table appearance are inconsistent, inconsistent table is carried out overlapping operation with one or more table.
8, device as claimed in claim 7 is characterized in that also comprising the USB module, is used for this device is linked to each other with computing machine.
9, device as claimed in claim 7 is characterized in that CPU, the communication between the storer of device adopts dma mode to carry out data transmission.
CNB2005101306481A 2005-12-16 2005-12-16 FAT file system error treating method and device Expired - Fee Related CN100389396C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005101306481A CN100389396C (en) 2005-12-16 2005-12-16 FAT file system error treating method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005101306481A CN100389396C (en) 2005-12-16 2005-12-16 FAT file system error treating method and device

Publications (2)

Publication Number Publication Date
CN1776640A true CN1776640A (en) 2006-05-24
CN100389396C CN100389396C (en) 2008-05-21

Family

ID=36766159

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005101306481A Expired - Fee Related CN100389396C (en) 2005-12-16 2005-12-16 FAT file system error treating method and device

Country Status (1)

Country Link
CN (1) CN100389396C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110795281A (en) * 2019-10-14 2020-02-14 杭州迪普科技股份有限公司 File recovery method, device, equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1561166B1 (en) * 2002-10-17 2008-01-02 Matsushita Electric Industrial Co., Ltd. File-update apparatus
US7174420B2 (en) * 2002-10-22 2007-02-06 Microsoft Corporation Transaction-safe FAT file system
CN100359592C (en) * 2002-12-13 2008-01-02 康佳集团股份有限公司 Data storage method for hard disk for camera-shooting and recording device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110795281A (en) * 2019-10-14 2020-02-14 杭州迪普科技股份有限公司 File recovery method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN100389396C (en) 2008-05-21

Similar Documents

Publication Publication Date Title
JP4371771B2 (en) Power management block used in non-volatile memory system
US9880759B2 (en) Metadata for data storage array
US6173291B1 (en) Method and apparatus for recovering data from damaged or corrupted file storage media
US8412752B2 (en) File system having transaction record coalescing
US7519806B2 (en) Virtual partition for recording and restoring computer data files
US8095577B1 (en) Managing metadata
US8856469B2 (en) Apparatus and method for logging optimization using non-volatile memory
US9467294B2 (en) Methods and systems for storing and retrieving data
US7809777B2 (en) File system having deferred verification of data integrity
US7174420B2 (en) Transaction-safe FAT file system
US8959125B2 (en) File system having inverted hierarchical structure
CA2550974C (en) Optimized start-up verification of file system integrity
CN1313941C (en) Method for data exchange between data handling equipment and operating system
CN100573480C (en) A kind of hard disk data protection method and system
CN1317650C (en) Method for automatically recovering BIOS based on hard disk protective space
CN100389396C (en) FAT file system error treating method and device
CN1776687A (en) File segmenting method and device for FAT file system
US7024493B1 (en) Bootable CD for transferring files independently of computer operating systems
CN1216329C (en) Method for establishing guidable partition
KR101077500B1 (en) Log Data Storage Method for Journaling FAT File System
CN1776648A (en) Method and device for getting residual space for FAT file system
CN1776686A (en) Position-based interface access method and device for FAT file system
KR20060135248A (en) File system recovery method and system for portable terminal with hard disk drive

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20080521

Termination date: 20111216