File system design method and system suitable for power distribution terminal

By dividing the power distribution terminal file system into a main management area, a sub-management area, and a record rollback area, and combining MD5 checksum and logical unit scanning, the problems of high resource consumption and power failure crashes in existing power distribution terminal file systems are solved, achieving efficient operation and power failure safety, and improving system stability and boot speed.

CN120803340APending Publication Date: 2025-10-17NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510643728.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-19
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

The existing power distribution terminal file system has high resource utilization and complex structure, resulting in poor CPU performance and easy crash in the event of power failure, affecting system stability and boot speed.

Method used

The system adopts a file system design approach, which divides the FLASH device into independent physical storage spaces, namely the main management area, sub-management area, file data area and record rollback area. Each file is composed of logical units, which include the file write pointer position, file erase sector address, file status, file size, logical unit sequence number, MD5 checksum and validity identifier, and supports a power-loss safe file recovery mechanism.

Benefits of technology

It achieves low CPU resource consumption, fast startup, and power-loss safety, improving system stability and reliability, preventing the loss of important information, and extending the lifespan of FLASH.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803340A_ABST
    Figure CN120803340A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of power distribution terminals, and provides a file system design method and system suitable for a power distribution terminal, and the method comprises the steps: dividing a storage space for storing a file according to a file type and a file name; each file is composed of a main management area, a sub management area, a file data area and a record rollback area, and each of the main management area and the sub management area is composed of a logic unit; after file data writing is completed, the current latest file state is updated to the logic unit and stored in the main management area and the sub management area; after the file system is powered on, mounting operation is carried out, and whether file system abnormal operation occurs before the system is powered off is judged according to the validity of the logic units of the main management area and the sub management area. And if the file is abnormal, recovering to the last normal state before the file is powered off according to the logic unit content of the main management area and the sub management area and the record rollback area content of the file. According to the method, the CPU resource occupancy rate is low, and the starting and mounting speed is high.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of power distribution terminals, and in particular to a file system design method and system suitable for power distribution terminals. BACKGROUND

[0002] At present, distributed new energy is widely accessed in the power system, which promotes the development of new power systems on the one hand, and puts forward higher requirements for the functions of secondary terminal devices under the system on the other hand. As an important part of the entire power system, whether the power distribution terminal devices contained in the power distribution system can safely and reliably operate plays a decisive role in the stability of the power distribution system. As a kind of power distribution terminal, the application function of the power distribution terminal device cannot operate without the support of the file system. At present, the file system supported by the embedded device is various, but it is difficult to avoid the two problems of "efficient operation" and "power failure safety".

[0003] The Chinese patent document with the application publication number CN114546680A describes the recording method of the log file mentioned in the patent. A dual-core processor is used to record log memory data in the protection real-time core and does not perform FLASH operation, but transmits the log memory data to the management core through shared memory. The management core runs the file system Tpsfs supporting power failure safety. This method meets the requirements of the power failure safety file system, but the system is too large, the architecture is complex, and it is difficult to implement. In addition, there are problems of abnormal data interaction between the dual-core shared memory during operation.

[0004] The article "Design and Implementation of an Embedded Flash File System" also describes the FLASH file system power failure safety. When writing a file block, an invalid flag is first set. However, there is a problem that when power failure occurs when writing this flag area, the flag cannot be obtained, and the validity of the data block cannot be obtained.

[0005] Therefore, the existing file system has the following problems:

[0006] 1. Large file system, high CPU resource occupation rate, complex structure, cumbersome log recording process, and difficult to troubleshoot problems.

[0007] 2. Current large file systems mostly use directory management information methods, i.e. complex directory management mechanisms, directory and file content are managed separately, and large capacity FLASH operations are in block units,

[0008] A database can contain a large amount of file information, and before updating the data block information, the content in the block must be read out, the database must be erased, and then the information is updated and written to the database, so there are processes of reading, erasing, and writing.

[0009] 3. Current file system in order to balance the load of erasing shoes, improve the operation efficiency of FLASH, are all using periodic writing, or data area reaches the upper limit of writing.

[0010] 4. The above operation, whether in the erasing process, balancing the load of erasing process, if power failure occurs, the file data or important directory information is lost, causing the file system to crash.

[0011] 5. In addition, some jffs file systems have log rollback function, record the last operation information in the log, but its file system is large, the performance of CPU is required, and in the actual running process, the CPU load is high,

[0012] Therefore, it is generally used in large embedded systems such as Linux, and when the power terminal has high real-time requirements for protection performance, the file system is too large to occupy a certain CPU load, which reduces the execution efficiency of CPU.

[0013] 6. Due to the large file system, the mounting is slow, which seriously affects the starting speed of the device, and if an important event needs to be recorded during the booting process, it will be missed. SUMMARY

[0014] The purpose of the present application is to solve at least one technical problem in the background art, and provide a file system design method and system suitable for power distribution terminal.

[0015] To achieve the above purpose, the present application provides a file system design method suitable for power distribution terminal, comprising:

[0016] According to the file type and file name, an independent physical storage space is divided in the FLASH device to store each file;

[0017] Each file is composed of a main management area, a sub-management area, a file data area and a record rollback area, the main management area and the sub-management area have consistent storage structure, and the main management area and the sub-management area are both composed of logical units;

[0018] After the file writing data is completed, the current latest file state is updated to the logical unit, and stored in the main management area and the sub-management area;

[0019] After the file system is powered on, the mounting operation is performed, the system is powered off before the file system abnormal operation is judged according to the validity of the logical unit of the main management area and the sub-management area, if the abnormality occurs, the last normal state before the file is powered off is restored according to the content of the logical unit of the main management area and the sub-management area and the content of the record rollback area of the file.

[0020] According to an aspect of the present application, the main management area and the sub management area are each composed of 32 logical units, each of which has a size of 128 bytes.

[0021] The logical unit is composed of a file write pointer position, a file erase sector address, a file state, a file size, a logical unit serial number, an MD5 check code and a validity identifier.

[0022] According to an aspect of the present application, the write operation of the logical unit includes even-time write and odd-time write, the destination address of the odd-time write being the main management area and the destination address of the even-time write being the sub management area.

[0023] According to an aspect of the present application, the mounting operation includes scanning and judging the logical units of the main management area and the sub management area of the file, if the main management area is empty and the sub management area is not empty, scanning and checking whether the MD5 check code in the logical units of the sub management area is correct, whether the serial number of the logical units of the sub management area is continuous and whether the validity identifier in the logical units of the sub management area is valid, and after the checking is completed and it is determined that the MD5 check code of the logical units of the sub management area is correct, the serial number is continuous and the validity identifier is valid, the information content of the sub management area is restored to the main management area.

[0024] According to an aspect of the present application, the mounting operation includes scanning and judging the logical units of the main management area and the sub management area of the file, if the main management area is not empty and the sub management area is empty, scanning and checking whether the MD5 check code in the logical units of the main management area is correct, whether the serial number of the logical units of the main management area is continuous and whether the validity identifier in the logical units of the main management area is valid, and after the checking is completed and it is determined that the MD5 check code of the logical units of the main management area is correct, the serial number is continuous and the validity identifier is valid, the information content of the main management area is restored to the sub management area.

[0025] According to one aspect of the present application, the mounting operation comprises scanning and judging logical units of the main management area and the sub management area of the file, if the main management area and the sub management area are not empty, then scanning the logical units of the main management area and the sub management area in turn, scanning out the logical unit with the latest serial number according to the serial numbers of the logical units of the main management area and the sub management area, and then judging whether the validity identifier in the logical unit with the latest serial number is valid and whether the MD5 check code is correct; if the validity identifier is valid and the MD5 check code is correct, then the logical unit with the latest serial number is valid, and the logical unit is taken as the file reference, and the subsequent file writing operation is based on the logical unit; if the validity identifier is invalid or the MD5 check code is abnormal, then the logical unit with the latest serial number is invalid, at this time, the scanning queue is rolled back, the last new logical unit is rolled back to and taken as the file reference, the data of the record rollback area at the end of the file area is read, and the data is written back to the file writing pointer position in the logical unit with the latest serial number confirmed this time, so as to restore the result of the last normal file writing operation.

[0026] To achieve the above object, the present application further provides a file system design system suitable for power distribution terminals, comprising:

[0027] A storage space division module divides independent physical storage spaces for storing each file according to the file type and file name in the FLASH device.

[0028] A file structure division module, each file is composed of a main management area, a sub management area, a file data area and a record rollback area, the main management area and the sub management area have consistent storage structures, and the main management area and the sub management area are both composed of logical units.

[0029] A file update storage module, after the file writing data is completed, the current latest file state is updated into the logical unit and stored into the main management area and the sub management area.

[0030] A file mounting operation module, after the file system is powered on, the mounting operation is performed, the system is judged whether abnormal operation of the file system occurs before power off according to the validity of the logical units of the main management area and the sub management area, if abnormal operation occurs, the last normal state before power off of the file is restored according to the content of the logical units of the main management area and the sub management area and the content of the record rollback area of the file.

[0031] To achieve the above object, the present application further provides an electronic device, comprising a processor, a memory and a computer program stored in the memory and executable on the processor, when the computer program is executed by the processor, the file system design method suitable for power distribution terminals is realized.

[0032] To achieve the above object, the application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the file system design method for power distribution terminals.

[0033] According to the scheme of the application, the application is suitable for efficient operation of power distribution terminals and supports power-off safety, has low CPU resource occupancy, fast startup mounting speed, and avoids losing important event record information at the moment of starting up due to slow file system mounting. The use life of FLASH is improved by using the balanced erasing and writing file management area, the problem of file system damage when power-off anomaly occurs is solved by scanning and judging the logical units of the main management area and the sub management area, and the stability and reliability of system operation are improved. BRIEF DESCRIPTION OF DRAWINGS

[0034] Figure 1 The file storage schematic diagram of embodiment 1;

[0035] Figure 2 The file system mounting flowchart of embodiment 1. DETAILED DESCRIPTION

[0036] The content of the application will now be discussed with reference to exemplary embodiments. It should be understood that the discussed embodiments are only to enable those of ordinary skill in the art to better understand and thus implement the content of the application, and are not intended to imply any limitation on the scope of the application.

[0037] As used herein, the term "comprising" and variations thereof are to be construed as meaning "including but not limited to". The term "based on" is to be construed as "based at least in part on". The terms "one embodiment" and "an embodiment" are to be construed as "at least one embodiment".

[0038] According to an embodiment of the application, the file system design method for power distribution terminals comprises:

[0039] According to the file type and the file name, independent physical storage spaces are divided in the FLASH device to store each file;

[0040] Each file is composed of a main management area, a sub management area, a file data area and a record rollback area, the main management area and the sub management area have consistent storage structures, and the main management area and the sub management area are both composed of logical units;

[0041] After the file data writing is completed, the current latest file state is updated into the logical unit and stored into the main management area and the sub management area;

[0042] The file system is mounted after power-on, and whether abnormal operation of the file system occurred before power-off is determined according to the logical unit validity of the main management area and the sub management area; if abnormal operation occurred, the last normal state before power-off is restored according to the logical unit content of the main management area and the sub management area and the content of the rollback area of the file.

[0043] According to an embodiment of the present application, the independent physical storage space is divided in the FLASH device according to the file type and the file name, and each file is stored in the independent physical storage space.

[0044] All the files in the application program are classified, and the classified files are partitioned according to the physical address on the FLASH device, and each file occupies a physical interval (physical storage space), and the physical interval is indexed by the file name.

[0045] Further, according to an embodiment of the present application, due to the special nature of the FLASH device that it must be erased before writing and the erase unit is 4 KB, the internal structure of each file (i.e. the management area) is designed, including the main management area (4 KB), the sub management area (4 KB), the file data area (N*4 KB) and the block area (i.e. the rollback area for data check) at the end of the file (4 KB) for data check.

[0046] In the embodiment, the main management area and the sub management area are consistent in structure. After writing the file, the file state information is first updated to the main management area, and then the file state information is written to the sub management area again. The file content is written to the file data area. After writing the file, the rollback area is also updated.

[0047] In the embodiment, the file directory partition is created, and the physical storage address of each file is saved in the partition, the file address is indexed through the directory, and the management area address of the file is indexed according to the file address. The current state information of the file can be obtained by obtaining the management area address information of the file.

[0048] Further, according to an embodiment of the present application, the main management area and the sub management area each consist of 32 logical units, and the size of each logical unit is 128 bytes.

[0049] The logical unit consists of the file write pointer position, the file erase sector address, the file state, the file size, the logical unit serial number, the MD5 check code and the validity identification. The logical unit serial number is self-increased after each writing.

[0050] Further, according to an embodiment of the present application, the rollback area is used to write the last sector content (4 KB) of the file data to the rollback area after writing the file, and is used to record the data content at the end of the file.

[0051] In the embodiment, the file reading process is: scanning directory information on software, indexing to file address according to file name, reading the addresses of the main management area and the sub management area of the file stored in the file directory according to the indexed file address, and reading out the main management area and the sub management area data content according to the two addresses. Thus, the file size and the file end position are extracted, and there is no special requirement for the reading process, because reading does not need to perform complex erasing and calculation write-back processes.

[0052] The file writing process is: indexing to the file main management area and the sub management area address according to the file name, and determining to use one of the main management area and the sub management area information as the subsequent management information update target by judging the validity of the main management area and the sub management area on software.

[0053] According to the length of the data to be written transmitted by the upper API interface and the current file data area write pointer, it is calculated whether the remaining space of the sector where the current file write pointer is located meets the length of the data to be written. If not, the erasing sector address is updated, and the next sector space to be written is erased. If the next sector is the end of the specified allocated file data area, the erasing is performed on the head sector of the file data area.

[0054] The data transmitted by the upper API is written into the file data area.

[0055] After the file data is written, the entire content of the sector where the file write pointer is located is written into the record rollback area of the file.

[0056] The latest file state information is updated into the file handle memory, including the file offset pointer, the erased sector number, the file size and other belonging information.

[0057] The file handle memory data is written into the logical unit of the main management area, the logical unit serial number, the MD5 check code, the validity flag, each main management area is composed of 32 logical units, and the logical unit implements the cyclic writing mechanism.

[0058] Further, according to an embodiment of the application, the writing operation of the logical unit includes even-time writing and odd-time writing, the destination address of the odd-time writing is the main management area, and the destination address of the even-time writing is the sub management area.

[0059] In the embodiment, the write process of the logical unit: the logical unit write is a write process with 128 bytes as the operation unit, and is divided into main area (main management area) write and sub-area (sub management area) write. The write operation on the logical unit is performed immediately after the file write operation. Here, the operation times are distinguished according to the parity. The odd operation times write the data of the main area of the logical unit, and the even operation times write the sub-area of the logical unit. Since the size of the logical unit is smaller than the size of the sector block (the length of the logical unit is 128 bytes, which is smaller than the size of the sector of the FLASH (4 KB)), one main or sub management area can cyclically write 32 logical units. Therefore, the logical unit adopts the cyclically appended write mode. The serial number of the logical unit is incremented.

[0060] Further, according to an embodiment of the present application, after the device software is started, the mounting operation is first performed on the file. The mounting operation includes: indexing from the file system directory area to the management area of the file, and first checking whether the contents of the main management area and the sub management area are all empty. If they are all empty, it indicates that the file is an empty file, and no write operation is performed. Then, the normal flow is entered.

[0061] Further, according to an embodiment of the present application, the mounting operation further includes: scanning and judging the logical units of the main management area and the sub management area of the file. If the main management area is empty and the sub management area is not empty, the MD5 check code in the logical unit of the sub management area is scanned and checked for correctness, the serial number of the logical unit of the sub management area is scanned and checked for continuity, and the validity identification in the logical unit of the sub management area is scanned and checked for validity. If the serial number is continuous, the MD5 is correct, and the validity identification is valid, it is determined that the power-off situation occurs when the file is closed. Specifically, the power-off behavior occurs when the main area needs to be erased due to being full during the write of the main management area information. Here, the contents of the sub management area are restored to the main management area.

[0062] Further, according to an embodiment of the present application, the mounting operation further includes: scanning and judging the logical units of the main management area and the sub management area of the file. If the main management area is not empty and the sub management area is empty, the MD5 check code in the logical unit of the main management area is scanned and checked for correctness, the serial number of the logical unit of the main management area is scanned and checked for continuity, and the validity identification in the logical unit of the main management area is scanned and checked for validity. If the serial number is continuous, the MD5 is correct, and the validity identification is valid, it is determined that the power-off situation occurs when the file is closed. Specifically, the power-off behavior occurs when the main management area information is updated. Here, the contents of the main management area are restored to the sub management area.

[0063] Further, according to an embodiment of the present application, the mounting operation further comprises: scanning and judging the logical units of the main management area and the sub management area of the file, if the main management area and the sub management area are both not empty, then scanning the logical units of the main management area and the sub management area in turn, scanning out the logical unit with the latest serial number according to the serial numbers of the logical units of the main management area and the sub management area (i.e. scanning out the latest serial numbers L_i and L_j of the logical units of the main management area and the sub management area respectively, and then comparing the latest serial numbers of the two logical units, and taking the one with the latest serial number as the logical unit with the latest serial number), and then judging whether the validity identifier in the logical unit with the latest serial number is valid and whether the MD5 check code is correct; if the validity identifier is valid and the MD5 check code is correct, then the logical unit with the latest serial number is valid, and the logical unit is taken as the file reference, and subsequent file writing operations are all based on the logical unit; if the validity identifier is invalid or the MD5 check code is abnormal, then the logical unit with the latest serial number is invalid (representing that a power-off behavior occurs when writing the logical unit, and at this time the file data area has normally written data, and if the FLASH writing operation is performed based on the logical unit with the latest serial number as the operation address, a writing failure will occur), at this time a rollback operation is performed on the scanning queue, the last new logical unit is rolled back, and the last new logical unit is taken as the file reference, the data of the record rollback area at the end of the file is read, and the data of the record rollback area is written back to the file writing pointer position in the logical unit with the latest serial number confirmed this time, for restoring the result of the last normal file writing operation.

[0064] According to the above scheme of the present application, the file system designed by the file system design method suitable for the power distribution terminal of the present application is suitable for the efficient operation of the power distribution terminal, supports power-off safety, has low CPU resource occupancy, has fast mounting speed, and avoids losing important event record information at the moment of starting up due to slow file system mounting. The method of evenly erasing and writing the file management area improves the service life of the FLASH, the scanning and judging of the logical units of the main management area and the sub management area solve the problem of file system damage when a power-off abnormality occurs, and improve the stability and reliability of system operation.

[0065] Further, in order to achieve the above-mentioned purpose, the present application further provides a file system design system suitable for a power distribution terminal, comprising:

[0066] a storage space division module, which divides independent physical storage spaces for storing each file in the FLASH device according to the file type and the file name;

[0067] a file structure division module, each file is composed of a main management area, a sub management area, a file data area and a record rollback area, the main management area and the sub management area have consistent storage structures, and the main management area and the sub management area are both composed of logical units;

[0068] The file update storage module updates the current latest file state to the logical unit after the file write data is completed, and stores the current latest file state into the main management area and the sub management area.

[0069] The file mounting operation module performs a mounting operation after the file system is powered on, judges whether abnormal operation of the file system occurs before the system is powered off according to the logical unit validity of the main management area and the sub management area, and if abnormal operation occurs, restores to the last normal state before the file system is powered off according to the logical unit content of the main management area and the sub management area and the rollback area content of the file.

[0070] The file system design system for power distribution terminals according to the present application can implement the file system design method for power distribution terminals, and the specific method steps are as described above, and will not be described again.

[0071] Further, in order to achieve the above-mentioned purpose, the present application also provides an electronic device, which comprises a processor, a memory and a computer program stored on the memory and executable on the processor, and the computer program implements the file system design method for power distribution terminals when executed by the processor.

[0072] Further, in order to achieve the above-mentioned purpose, the present application also provides a computer readable storage medium, which stores a computer program, and the computer program implements the file system design method for power distribution terminals when executed by the processor.

[0073] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with specific embodiments combined with the drawings. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0074] Embodiment 1

[0075] Figure 1 The file storage schematic diagram is shown in FIG. 1. Figure 1As shown, according to the file required by the device application function for type classification, independent physical space is divided in the FLASH to store each file, and each file is composed of a main management area, a sub management area, a file data area, and a record rollback area. The file directory stores the physical starting address of the file in the FLASH. Each file has a main management area and a sub management area, and the storage structure and storage content of the main management area and the sub management area are consistent. The main management area information is composed of M logical units, and the size of each logical unit is fixed at 128 bytes. The logical unit stores the write pointer position, file size, file state, sector number, file erase sector address, logical unit serial number, validity flag, and MD5 check code of the file. The storage content and partition structure in the sub management area are consistent with those in the main management area. The record rollback area is used to write the last sector content (4 KB) of the file data to the rollback record area after the file is written, for recording the data content at the end of the file. After the file is opened, the latest logical unit data is obtained according to the file name, the target data is written to the file data area according to the file description information therein, the logical unit memory area is updated after the file is written, the logical unit serial number is incremented, the MD5 check code of the unit is calculated, and the validity flag is written. Finally, the logical unit is written to the main management area or the sub management area. If the current write operation is an odd number of times, the main management area is written, otherwise the sub management area is written. If the partition is full, the content of the entire partition is erased, and the write operation is performed from the beginning. For file read operation, the file management area is indexed according to the file name, the latest logical unit is read from the management area, and the current state of the file can be obtained.

[0076] Figure 2The file system mounting process is as follows: firstly, the file directory is scanned, and the target file physical starting address is located according to the file name; firstly, it is judged whether the main and sub management areas are all empty; if yes, it represents that the file is an empty file, the scanning is ended, and the scanning process of the next file is directly entered. If the main management area is empty and the sub management area is not empty, the logical units of the sub management area are scanned, and the latest information of the sub management area is recovered to the main management area. If the main management area is not empty and the sub management area is empty, the logical units of the main management area are scanned, and the latest information of the main management area is recovered to the sub management area. If the main management area and the sub management area are not empty, the logical units of the main management area and the sub management area are scanned respectively, and the latest logical unit content is located according to the serial number of the scanned logical unit. Then, according to the validity flag of the latest logical unit and the MD5 check code, it is judged whether the logical unit is a valid logical unit; if it is a non-valid unit, the last scanning normal logical unit is returned, and the logical unit is taken as the current operation basis of the file. At the same time, the data of the record rollback area of the file is recovered to the starting position of the last write operation of the file data area, and the data before the abnormality of the file system is recovered. When the scanning of the main management area and the sub management area logical units of all the files in the file directory is ended, the file system mounting is ended.

[0077] Those skilled in the art can understand that the modules and algorithm steps described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software mode depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0078] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the above-described device and equipment can refer to the corresponding process in the foregoing method embodiments, which will not be described here.

[0079] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interfaces, devices or modules, and can be electrical, mechanical or other forms.

[0080] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, i.e., may be located in one place or distributed over multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0081] In addition, each functional module in the embodiments of the present application can be integrated into one processing module, or each module can exist physically independently, or two or more modules can be integrated into one module.

[0082] If the functions are implemented in the form of software functional modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the part of the present application that essentially contributes to the prior art or the part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the energy-saving signal transmission / reception method of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk, and various program code storage media.

[0083] The above description is only the preferred embodiments of the present application and the explanation of the applied technical principles. Those skilled in the art should understand that the scope of the application involved in the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and also covers other technical solutions formed by any combination of the above technical features or equivalent features without departing from the inventive concept. For example, the above features are replaced with the technical features disclosed in the present application (but not limited to) having similar functions to form technical solutions.

[0084] It should be understood that the sequence of the steps in the summary and embodiments of the present application does not absolutely mean the order of execution, and the execution order of the processes should be determined according to their functions and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

Claims

1. A file system design method suitable for power distribution terminals, characterized in that: include: According to the file type and file name, separate physical storage space is divided in the FLASH device to store each file; Each file consists of a main management area, a sub-management area, a file data area and a record rollback area. The main management area and the sub-management area have the same storage structure and are both composed of logical units. After the file data is written, the current latest file status is updated to the logical unit and stored in the main management area and the sub-management area; After the file system is powered on, the mount operation is performed. The validity of the logical units of the main management area and the sub-management area is used to determine whether any abnormal file system operation occurred before the system was powered off. If an abnormality occurs, the file is restored to its last normal state before the power outage based on the contents of the logical units of the main management area and the sub-management area and the contents of the file's record rollback area.

2. The file system design method for power distribution terminals according to claim 1, characterized in that: The main management area and the sub-management area are each composed of 32 logical units, and the size of each logical unit is 128 bytes; The logic unit is composed of a file write pointer position, a file erase sector address, a file status, a file size, a logic unit sequence number, an MD5 check code and a validity identifier.

3. The file system design method for power distribution terminals according to claim 1, characterized in that: The write operation of the logic unit includes even write and odd write, the destination address of the odd write is the main management area, and the destination address of the even write is the sub-management area.

4. The file system design method for power distribution terminals according to claim 2, characterized in that: The mounting operation includes scanning and judging the logical units of the main management area and the sub-management area of ​​the file. If the main management area is empty and the sub-management area is not empty, the MD5 check code in the logical unit of the sub-management area is scanned to check whether it is correct, whether the serial number of the logical unit of the sub-management area is continuous, and whether the validity identifier in the logical unit of the sub-management area is valid. After the inspection is completed and it is determined that the MD5 check code of the logical unit of the sub-management area is correct, the serial number is continuous, and the validity identifier is valid, the information content of the sub-management area is restored to the main management area.

5. The file system design method for power distribution terminals according to claim 2, characterized in that: The mounting operation includes scanning and judging the logical units of the main management area and the sub-management area of ​​the file. If the main management area is not empty and the sub-management area is empty, the MD5 check code in the logical unit of the main management area is scanned and checked to see whether it is correct, whether the serial number of the logical unit of the main management area is continuous, and whether the validity identifier in the logical unit of the main management area is valid. After the inspection is completed and it is determined that the MD5 check code of the logical unit of the main management area is correct, the serial number is continuous, and the validity identifier is valid, the information content of the main management area is restored to the sub-management area.

6. The file system design method for power distribution terminals according to claim 2, characterized in that: The mounting operation includes scanning and judging the logical units of the main management area and the sub-management area of ​​the file. If both the main management area and the sub-management area are not empty, the logical units of the main management area and the sub-management area are scanned in turn, and the logical unit with the latest serial number is scanned out according to the serial numbers of the logical units of the main management area and the sub-management area. Then, it is judged whether the validity identifier in the logical unit with the latest serial number is valid and whether the MD5 check code is correct; if the validity identifier is valid and the MD5 check code is correct, the logical unit with the latest serial number is valid, and this logical unit is used as the file benchmark, and subsequent file write operations are based on this logical unit; if the validity identifier is invalid or the MD5 check code is abnormal, the logical unit with the latest serial number is invalid, and the scanning queue is rolled back at this time, rolling back to the last next-to-last logical unit and using this logical unit as the file benchmark, reading the record rollback area data at the end of the file, and writing the record rollback area data back to the file write pointer position in the logical unit with the latest serial number confirmed this time, to restore the result of the last normal file write operation.

7. A file system design system suitable for power distribution terminals, characterized in that: include: The storage space division module divides the FLASH device into independent physical storage spaces to store each file according to the file type and file name; A file structure division module, wherein each file consists of a main management area, a sub-management area, a file data area, and a record rollback area. The main management area and the sub-management area have the same storage structure, and both the main management area and the sub-management area are composed of logical units; A file update storage module updates the current latest file status to the logical unit after the file data is written, and stores it in the main management area and the sub-management area; The file mounting operation module performs the mounting operation after the file system is powered on. It determines whether an abnormal file system operation occurred before the system was powered off based on the validity of the logical units of the main management area and the sub-management area. If an abnormality occurs, it restores the file to its last normal state before the power outage based on the logical unit contents of the main management area and the sub-management area and the record rollback area contents of the file.

8. An electronic device, characterized in that The invention comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the method for designing a file system applicable to a power distribution terminal as claimed in any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the file system design method applicable to a power distribution terminal according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • File system, file system access method, electronic equipment and storage medium

    CN111444152A

  • Parameter storage mechanism of embedded system

    CN112596808A

  • FLASH file management system with service life management function

    CN112631516A

  • High-reliability file system design method based on NAND flash

    CN115981560A

  • Log storage method, device and equipment and nonvolatile storage medium

    CN119739350A