CN108763371B - Exfat file system power-off protection and file detection recovery method - Google Patents

Exfat file system power-off protection and file detection recovery method Download PDF

Info

Publication number
CN108763371B
CN108763371B CN201810475518.9A CN201810475518A CN108763371B CN 108763371 B CN108763371 B CN 108763371B CN 201810475518 A CN201810475518 A CN 201810475518A CN 108763371 B CN108763371 B CN 108763371B
Authority
CN
China
Prior art keywords
file
directory entry
value
checksum
size
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.)
Active
Application number
CN201810475518.9A
Other languages
Chinese (zh)
Other versions
CN108763371A (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.)
Shanghai V&g Information Technology Co ltd
Original Assignee
Shanghai V&g Information Technology 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 Shanghai V&g Information Technology Co ltd filed Critical Shanghai V&g Information Technology Co ltd
Priority to CN201810475518.9A priority Critical patent/CN108763371B/en
Publication of CN108763371A publication Critical patent/CN108763371A/en
Application granted granted Critical
Publication of CN108763371B publication Critical patent/CN108763371B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention provides a method for power-off protection and file detection recovery of an Exfat file system, which comprises the following steps: determining a file directory entry to be subjected to write operation; writing data into a data area of a file; setting the operating state as unfinished; modifying the type characteristic value of any one item of the file attribute directory item or the stream extended directory item or the file name extended directory item into other values; sequentially updating the values of file size 1 and file size 2 fields in the stream extension directory entry; updating the corresponding cluster bitmap file and the FAT table entry; calculating the checksum of the file directory entry, and updating the value of the checksum to a checksum field in the attribute directory entry; changing the value modified in the step 4 back to the original correct value; the operational state is set to complete. Meanwhile, a recovery method of the corresponding file is provided. The invention solves the problem that the file system is damaged due to the accidental power failure of the Exfat file system in the writing operation process, and can realize the quick recovery function of the unwritten file data.

Description

Exfat file system power-off protection and file detection recovery method
Technical Field
The invention relates to the technical field of computers, in particular to a method for power-off protection and file detection recovery of an Exfat file system in the aspect of file system storage.
Background
In the technical field of computers, a large amount of file storage work is related to, a file needs to be written, if a file system is subjected to unexpected power failure in the process of writing the file, partial key data in the file system is incomplete, the file system is damaged, and the operating system cannot normally operate the file system.
The existing file system power-off protection method is a method of carrying out double backup on data and logs or adopting a method of modifying hardware and supplying power by a backup power supply when power is unexpectedly cut off. The data backup method can achieve the power-off protection function of the file system, but the backup data can occupy the space of the disk, so that the utilization rate of the disk is reduced. The method of hardware modification cannot be realized in the environment that some hardware is fixed.
Disclosure of Invention
Aiming at the defects of the conventional file system power-off protection method, the invention provides an Exfat file system power-off protection and file detection recovery method, which can avoid the problem that the file system is damaged due to accidental power-off in the writing operation process of the file system and can recover files which are not operated completely in the power-off process. The method solves the problem that the file system is damaged due to accidental power failure of the Exfat file system in the writing operation process, and can realize the quick recovery function of the unwritten file data. The technical scheme of the invention is explained as follows:
when writing to the Exfat file system, one very important item of data is a file directory item. The file directory entry is composed of three parts, which are called an attribute directory entry, a stream extension directory entry, and a file name extension directory entry, respectively. The key information contained in the attribute directory entry is: type characteristic value (0x85) of attribute directory entry, attached directory entry number, file directory entry checksum, file attribute, file creation time, last modification time, last access time. The key information contained in the stream extension directory entry is: a type characteristic value (0xC0) of the stream extension directory entry, a file fragment flag, a file name character number, a file name Hash value, a file size 1, a file size 2, and a start cluster number. The key information contained in the file name extension directory entry is: the file name extends the type characteristic value (0xC1) of the directory entry, the file name.
The write operation of the Exfat file system power-off protection method provided by the invention on the file system comprises the following steps:
1. determining a file directory entry corresponding to a file to be operated, and recording the starting address of the file directory entry.
2. And writing a piece of data with a specified length into the data area of the file.
3. The operating state is set to incomplete.
4. And modifying the type characteristic value of any one item of the attribute directory item or the stream extended directory item or the file name extended directory item into other values.
5. And updating the values of the fields of the file size 1 and the file size 2 in the stream extension directory entry in sequence.
6. And updating the corresponding cluster bitmap file and the FAT table entry.
7. And calculating the checksum of the file directory entry and updating the value of the checksum into the checksum field in the attribute directory entry.
8. The value modified in step 4 is changed back to the original correct value.
9. The operational state is set to complete.
10. And repeating the steps 2-9 until the file writing operation is finished.
The operation state is saved in a reserved area of a file system; the start address of the file directory entry corresponding to the operated file is recorded in the reserved area of the file system.
After the file system is powered on again due to unexpected power failure, the file system needs to be detected, and the detection steps comprise:
1. the value of the operating state is read.
2. If the operation state is complete, no file recovery is required.
3. If the value of the operation state is not completed, the file with incomplete operation is indicated when the power is off.
4. And reading the initial address of the file directory entry of the file which is operated during power-off to acquire the information of the file directory entry.
5. And judging whether the file directory entry information is correct or not.
6. If the file directory entry information is correct, the power is cut off when the operation state is just set as 'unfinished' and the file directory entry is not modified, and the operation state is only modified to 'finished'.
7. If the file directory entry information is incorrect, the file corresponding to the file directory entry is the file which is operated when the power is cut off, and the file needs to be recovered.
The file recovery comprises the following steps:
1. it is determined whether the values of the file size 1 and file size 2 fields in the streaming extension directory entry are consistent.
2. If the values of the fields of the file size 1 and the file size 2 are not consistent, copying the value of the field of the file size 1 to the field of the file size 2, and continuing the following steps; if the values of the fields of the file size 1 and the file size 2 are consistent, directly continuing the following steps;
3. and calculating the checksum of the file directory entry and updating the value of the checksum into the checksum field in the attribute directory entry.
4. The characteristic value of the modified directory entry type is modified to a correct value.
5. The operating state is modified to "complete".
The invention has the beneficial effects that: according to the Exfat file system power-off protection method provided by the invention, the power-off protection of the file system can be realized without excessive data backup, files which are not operated and completed before power failure can be quickly recovered, and even if only one part of the file is written, the written part can be ensured to be read.
Drawings
FIG. 1 is a flow chart of a file system power-off protection file write operation of the present invention;
FIG. 2 is a flowchart illustrating the detection of a file system being powered back on in case of an unexpected power outage according to the present invention;
FIG. 3 is a flowchart of file recovery according to the present invention.
Detailed Description
The present invention will be described in further detail below by way of specific embodiments:
on the Windows operating system, for the Exfat file system, if the type characteristic value of any one of the attribute directory entry, the stream extension directory entry or the file name extension directory entry of a file directory entry of a certain file is incorrect, the Windows system cannot recognize the attribute directory entry, the stream extension directory entry or the file name extension directory entry as a file, but can still perform other operations on the file system. If the type characteristic values of the attribute directory entry, the stream extension directory entry and the file name extension directory entry in the file directory entry are correct, the values of the file size 1 field and the file size 2 field in the stream extension directory entry are not consistent, or the checksum of the attribute directory entry is incorrect, the file system is damaged at the moment, and the Windows system cannot perform other operations on the file system.
Therefore, the power-off protection method for the Exfat file system provided by the invention utilizes the principle. When a file writing operation is performed to the file system, a file directory entry of a file to be written is first determined. If a new file is to be created, a file directory entry needs to be created first, and when the file directory entry is created, the type characteristic value of any one of the attribute directory entry, the stream extension directory entry and the file name extension directory entry of the file directory entry is modified to other values. The invention takes the attribute directory entry as an example, the type characteristic value of the attribute directory entry is set to be 0x75, and after other fields of the file directory entry are successfully written, the type characteristic value of the attribute directory entry is modified back to be 0x 85. The method comprises the following specific steps:
1. determining a file directory entry corresponding to a file to be operated, and recording the initial address of the file directory entry in a reserved area of a file system;
2. writing a piece of data with a specified length into the file;
3. setting the operation state as incomplete, and storing the operation state in a reserved area of a file system;
4. changing the type characteristic value of the attribute directory entry to 0x 75;
5. updating the values of the fields of the file size 1 and the file size 2 in the stream extension directory entry;
6. updating the corresponding cluster bitmap file and the FAT table entry;
7. calculating the checksum of the file directory entry, and updating the value of the checksum to a checksum field in the attribute directory entry;
8. the type characteristic value of the attribute directory entry modified in step 4 is modified back to the original value 0x 85.
9. The operating state is set to complete and the operating state is saved in a reserved area of the file system.
10. And repeating the steps 2-9 until the file writing operation is finished.
After the file system is powered on again in case of unexpected power failure, whether a file with unfinished operation exists in the power failure needs to be detected, and the detection step comprises the following steps:
1. reading the operation state information and judging whether the operation state is unfinished;
2. if the operation state is completion, file recovery is not needed;
3. if the operation state is unfinished, reading the initial address of the recorded operation file directory entry;
4. reading the file directory entry information of the unfinished operation file according to the recorded initial address of the directory entry of the operation file, and judging whether the directory entry of the file is complete;
5. if the file directory entry information is correct, the operation state is set to be incomplete, the power is cut off when the file directory entry is not modified, and the operation state is only modified to be complete;
6. if the file directory entry information is incorrect, the file corresponding to the file directory entry is the file which is operated when the power is cut off, and the file needs to be recovered.
The file recovery step comprises:
1. judging whether the values of the file size 1 field and the file size 2 field in the streaming extension directory entry are consistent or not;
2. if the values of the fields of the file size 1 and the file size 2 are not consistent, copying the value of the field of the file size 1 to the field of the file size 2, and continuing the following steps; if the values of the fields of the file size 1 and the file size 2 are consistent, directly continuing the following steps;
3. calculating the checksum of the file directory entry, wherein the type characteristic value of the attribute directory entry is calculated according to 0x85, and then updating the value of the checksum into the checksum field of the attribute directory entry;
4. changing the type characteristic value of the modified attribute directory entry to the correct value of 0x 85;
5. the operating state is modified to "complete".

Claims (2)

1. An Exfat file system power-off protection method is characterized by comprising the following steps:
1) determining a file directory entry corresponding to a file to be subjected to write operation, and recording the initial address of the file directory entry in a reserved area of a file system;
2) writing a piece of data with a specified length into a data area of the file;
3) setting the operation state as 'unfinished' and saving the operation state in a reserved area of a file system;
4) modifying the type characteristic value of any one item of the file attribute directory item, the stream extension directory item or the file name extension directory item into other values;
5) updating the values of the fields of file size 1 and file size 2 in the stream extension directory entry in sequence;
6) updating the corresponding cluster bitmap file and the FAT table entry;
7) calculating the checksum of the file directory entry, and updating the value of the checksum to a checksum field in the attribute directory entry;
8) changing the value modified in the step 4 back to the original correct value;
9) setting the operation state as 'finished' and saving the operation state in a reserved area of the file system;
10) and repeating the steps 2 to 9 until the file writing operation is completed.
2. A method for restoring an Exfat file system power-off protection file is characterized by comprising the following steps:
firstly, whether a file with unfinished operation exists during power failure is detected, and the method specifically comprises the following steps:
1) reading a value of the operating state;
2) if the operation state is 'complete', file recovery is not required;
3) if the value of the operation state is 'unfinished', indicating that the file is unfinished when the power is off, continuing the following steps;
4) reading a file directory entry initial address of a file which is being operated during power failure, and acquiring file directory entry information;
5) judging whether the file directory entry information is correct or not;
6) if the file directory entry information is correct, the operation state is set to be incomplete, the power is cut off when the file directory entry is not modified, and the operation state is only modified to be complete;
7) if the file directory entry information is incorrect, the file corresponding to the file directory entry is a file which is operated when the power is off, the file needs to be recovered, and the file recovery step is continued, wherein the specific steps comprise:
8) judging whether the values of the file size 1 field and the file size 2 field in the streaming extension directory entry are consistent or not;
9) if the values of the fields of the file size 1 and the file size 2 are not consistent, copying the value of the field of the file size 1 to the field of the file size 2, and continuing the following steps; if the values of the fields of the file size 1 and the file size 2 are consistent, directly continuing the following steps;
10) calculating the checksum of the file directory entry, and updating the value of the checksum to a checksum field in the attribute directory entry;
11) modifying the characteristic value of the modified directory entry type into a correct value;
12) the operating state is modified to "complete".
CN201810475518.9A 2018-05-17 2018-05-17 Exfat file system power-off protection and file detection recovery method Active CN108763371B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810475518.9A CN108763371B (en) 2018-05-17 2018-05-17 Exfat file system power-off protection and file detection recovery method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810475518.9A CN108763371B (en) 2018-05-17 2018-05-17 Exfat file system power-off protection and file detection recovery method

Publications (2)

Publication Number Publication Date
CN108763371A CN108763371A (en) 2018-11-06
CN108763371B true CN108763371B (en) 2021-06-18

Family

ID=64008176

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810475518.9A Active CN108763371B (en) 2018-05-17 2018-05-17 Exfat file system power-off protection and file detection recovery method

Country Status (1)

Country Link
CN (1) CN108763371B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515276A (en) * 2008-12-29 2009-08-26 北京握奇数据系统有限公司 Method for write operation of file data, and recovery method and recovery system for file data
CN101876927A (en) * 2009-11-30 2010-11-03 北京握奇数据系统有限公司 Power-off protection method for realizing FAT32 file system, and device thereof
CN102226893A (en) * 2011-05-21 2011-10-26 浙江工业大学 FAT (file allocation table) file system repairing method in embedded system
CN102254048A (en) * 2011-08-24 2011-11-23 深圳市万兴软件有限公司 Data recovering method and system
CN104794025A (en) * 2015-04-27 2015-07-22 四川效率源信息安全技术有限责任公司 Method for quick verification on storage device
CN105512056A (en) * 2014-09-24 2016-04-20 中兴通讯股份有限公司 Method and device for data storage, and terminal
CN107908967A (en) * 2017-10-30 2018-04-13 上海威固信息技术股份有限公司 A kind of file hiding and restoration methods of Exfat file system
CN107992763A (en) * 2017-11-06 2018-05-04 北京东土科技股份有限公司 The power-off protection method and device of a kind of file system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030028765A1 (en) * 2001-07-31 2003-02-06 Cromer Daryl Carvis Protecting information on a computer readable medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515276A (en) * 2008-12-29 2009-08-26 北京握奇数据系统有限公司 Method for write operation of file data, and recovery method and recovery system for file data
CN101876927A (en) * 2009-11-30 2010-11-03 北京握奇数据系统有限公司 Power-off protection method for realizing FAT32 file system, and device thereof
CN102226893A (en) * 2011-05-21 2011-10-26 浙江工业大学 FAT (file allocation table) file system repairing method in embedded system
CN102254048A (en) * 2011-08-24 2011-11-23 深圳市万兴软件有限公司 Data recovering method and system
CN105512056A (en) * 2014-09-24 2016-04-20 中兴通讯股份有限公司 Method and device for data storage, and terminal
CN104794025A (en) * 2015-04-27 2015-07-22 四川效率源信息安全技术有限责任公司 Method for quick verification on storage device
CN107908967A (en) * 2017-10-30 2018-04-13 上海威固信息技术股份有限公司 A kind of file hiding and restoration methods of Exfat file system
CN107992763A (en) * 2017-11-06 2018-05-04 北京东土科技股份有限公司 The power-off protection method and device of a kind of file system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
exFAT文件系统的解析和数据恢复;钱镜洁;《电信科学》;20101120;全文 *
Reverse engineering the Microsoft exFAT file system;Robert Shullich;《the SANS Institute》;20101231;全文 *

Also Published As

Publication number Publication date
CN108763371A (en) 2018-11-06

Similar Documents

Publication Publication Date Title
US8856469B2 (en) Apparatus and method for logging optimization using non-volatile memory
US9524212B2 (en) Method, device and operating system for processing and using burn data of NAND flash
CN109542682B (en) Data backup method, device, equipment and storage medium
CN107943414A (en) The file partition of built-in Linux and data read-write method
CN104050056A (en) File system backup of multi-storage-medium device
CN103034592B (en) Data processing method and device
CN105468544B (en) Method and device for realizing power-down prevention file system and power-down prevention file system
CN108062262A (en) Operating system backup-and-restore method and its system based on storage sector data
CN105320576A (en) Device and method for database backup
CN100437504C (en) Hard disc data backup system and method
WO2023116346A1 (en) Method and system for recovering trim data under abnormal power failure, and solid-state drive
US20130110785A1 (en) System and method for backing up test data
CN104461773A (en) Backup deduplication method of virtual machine
CN104866388B (en) Data processing method and device
JP2005050073A (en) Data restoration method, and data recorder
TW201516655A (en) System and method for recovering distributed file system
KR101258589B1 (en) Information storage medium recording data according to journaling file system, method and apparatus of writing/recovering data using journaling file system
CN108763371B (en) Exfat file system power-off protection and file detection recovery method
WO2017067397A1 (en) Data recovery method and device
CN111858159A (en) Backup method and system based on chain clone characteristic
CN109325005B (en) Data processing method and electronic equipment
US7865472B1 (en) Methods and systems for restoring file systems
CN103902227A (en) Appending write and sharing read supporting file storage method
JP2005352535A (en) Method of protecting data
CN111563006B (en) Data processing method, intelligent terminal and storage medium

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