File system design method and system suitable for power distribution terminal

CN120803340BActive Publication Date: 2026-10-27NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510643728.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-19
Publication Date
2026-10-27
Estimated Expiration
2045-05-19

AI Technical Summary

Technical Problem

[0006]1.大型的文件系统,对CPU资源占用率较高,且结构复杂,日志记录过程繁琐,出问题排查困难

Benefits of technology

[0033]根据本发明的方案,本发明适用于配电终端的高效运行,且支持掉电安全,其对CPU资源占用率低,启动挂载速度快,避免由于文件系统挂载慢导致开机时时刻丢失重要事件记录信息。采用均衡擦写文件管理区的方式提高了FLASH的使用寿命,对主管理区和子管理区的逻辑单元扫描判断解决了发生掉电异常时文件系统损坏的问题,提高了系统运行的稳定性和可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803340B_ABST
    Figure CN120803340B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of power distribution terminals, and provides a file system design method and system suitable for power distribution terminals, which comprises the following steps: dividing the storage space of storage files according to file types and file names; 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 are both composed of logical units; after file data writing is completed, the current latest file state is updated into the logical units and stored into the main management area and the sub-management area; after the file system is powered on, mounting operation is carried out; whether abnormal file system operation occurs before power-off is judged according to the logical unit validity of the main management area and the sub-management area; if abnormal operation occurs, 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 record rollback area content of the file. The application has low CPU resource occupancy and high starting mounting speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power distribution terminal technology, and in particular to a file system design method and system suitable for power distribution terminals. Background Technology

[0002] The widespread integration of distributed renewable energy into the current power system has, on the one hand, promoted the development of new power systems, and on the other hand, placed higher demands on the functionality of secondary terminal equipment within these systems. As a crucial link in the entire power system, the safe and reliable operation of the distribution terminal equipment within the system plays a decisive role in the stability of the distribution system. As a type of distribution terminal, the operation of its application functions relies on the support of a file system. Currently, embedded devices support a variety of file systems, but they all revolve around the issues of "efficient operation" and "power-off safety."

[0003] Chinese patent application CN114546680A describes a log file recording method using a dual-core processor. The real-time core only records log memory data without writing to FLASH; instead, the log memory data is transferred to the management core via shared memory. The management core runs a power-loss-safe file system, Tpsfs. While this method meets the requirements of a power-loss-safe file system, the system is too large and complex, making implementation difficult. Furthermore, issues arise during operation regarding abnormal data interaction between the two cores' shared memory.

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

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

[0006] 1. Large file systems consume a lot of CPU resources, have complex structures, cumbersome logging processes, and are difficult to troubleshoot.

[0007] 2. Current large file systems mostly adopt a directory-based information management approach, meaning they have complex directory management mechanisms, with directories and file content managed separately. However, large-capacity FLASH operations are performed in blocks.

[0008] A database can contain information from numerous files. Before updating data block information, the contents of the block must be read first, then the database must be erased, and then the information must be updated and written to the database. Therefore, there are processes of reading, erasing, and writing.

[0009] 3. In order to balance the workload of the flash memory and improve the efficiency of FLASH operation, current file systems use periodic writing or only write when the data area reaches its limit.

[0010] 4. In the above operations, whether during the erasure process or the load balancing process, if a sudden power failure occurs, file data or important directory information will be lost, causing the file system to crash.

[0011] 5. Some JFFS file systems also have journal rollback functionality, recording the previous operation information in the journal. However, these file systems are large, placing demands on CPU performance, and in actual operation, they consume a significant amount of CPU resources.

[0012] Therefore, it is generally used in large embedded systems such as Linux. However, when the power distribution terminal has high requirements for real-time protection performance, an excessively large file system will occupy a certain amount of CPU load and reduce the CPU's execution efficiency.

[0013] 6. Due to the large size of the file system, mounting is slow, which seriously affects the device's boot speed. If important events that need to be recorded occur during the boot process, they will be missed. Summary of the Invention

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

[0015] To achieve the above objectives, the present invention provides a file system design method suitable for power distribution terminals, comprising:

[0016] Based on file type and file name, separate physical storage space is allocated in the FLASH device to store each file;

[0017] 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.

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

[0019] After the file system is powered on, a mounting 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 occurred, the file is restored to its last normal state before the power failure based on the contents of the logical units of the main management area and the sub-management area, as well as the contents of the file's record rollback area.

[0020] According to one aspect of the present invention, both the main management area and the sub-management area are composed of 32 logical units, each logical unit being 128 bytes in size;

[0021] The logical unit consists of the file write pointer position, the file erase sector address, the file status, the file size, the logical unit number, the MD5 checksum, and the validity identifier.

[0022] According to one aspect of the present invention, the write operation of the logic unit includes even-numbered writes and odd-numbered writes, wherein the destination address of the odd-numbered writes is the main management area, and the destination address of the even-numbered writes is the sub-management area.

[0023] According to one aspect of the present invention, 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 checksum in the logical unit of the sub-management area is checked to see if it is correct, if the sequence number of the logical unit in the sub-management area is continuous, and if the validity identifier in the logical unit of the sub-management area is valid. After the checks are completed and it is determined that the MD5 checksum of the logical unit in the sub-management area is correct, the sequence 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 one aspect of the present invention, 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, then the MD5 checksum in the logical unit of the main management area is checked to see if it is correct, if the sequence number of the logical unit in the main management area is continuous, and if the validity identifier in the logical unit of the main management area is valid. After the checks are completed and it is determined that the MD5 checksum of the logical unit in the main management area is correct, the sequence 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 invention, 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 sequentially. The logical unit with the latest sequence number is scanned according to the sequence number of the logical units in the main management area and the sub-management area. Then, it is judged whether the validity identifier in the logical unit with the latest sequence number is valid and whether the MD5 checksum is correct. If the validity identifier is valid and the MD5 checksum is correct, the logical unit with the latest sequence number is valid, and this logical unit is used as the file reference. Subsequent file write operations are all based on this logical unit. If the validity identifier is invalid or the MD5 checksum is abnormal, the logical unit with the latest sequence number is invalid. At this time, a rollback operation is performed on the scan queue, rolling back to the previous second-newest logical unit and using this logical unit as the file reference. The record rollback area data at the end of the file area is read, and the record rollback area data is written back to the file write pointer position in the logical unit with the latest sequence number confirmed this time, so as to restore the result of the last normal file write operation.

[0026] To achieve the above objectives, the present invention also provides a file system design system suitable for power distribution terminals, comprising:

[0027] The storage space partitioning module allocates independent physical storage space in the FLASH device to store each file based on its file type and file name.

[0028] The file structure partitioning module consists of a main management area, a sub-management area, a file data area, and a record rollback area for each file. 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.

[0029] The file update storage module updates the current latest file status to the logical unit after the file data writing is completed, and stores it in the main management area and the sub-management area;

[0030] The file mount operation module performs the mount operation after the file system is powered on. It determines whether any 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 occurred, it restores the file to its last normal state before the power failure based on the contents of the logical units of the main management area and the sub-management area, as well as the contents of the file's record rollback area.

[0031] To achieve the above objectives, the present invention also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the file system design method for power distribution terminals as described above.

[0032] To achieve the above objectives, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the file system design method for power distribution terminals as described above.

[0033] According to the solution of this invention, the present invention is applicable to the efficient operation of power distribution terminals and supports power failure safety. It has low CPU resource consumption, fast startup and mounting speed, and avoids the loss of important event records during startup due to slow file system mounting. The use of balanced erasure and writing to the file management area improves the service life of FLASH, and the scanning and judgment of logical units in the main management area and sub-management area solves the problem of file system corruption during power failure, thereby improving the stability and reliability of system operation. Attached Figure Description

[0034] Figure 1 This is a schematic diagram of file storage in Example 1;

[0035] Figure 2 This is a flowchart of the file system mounting process in Example 1. Detailed Implementation

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

[0037] As used herein, the term "comprising" and its variations are to be interpreted as open-ended terms meaning "including but not limited to". The term "based on" is to be interpreted as "at least partially based on". The terms "one embodiment" and "an embodiment" are to be interpreted as "at least one embodiment".

[0038] According to one embodiment of the present invention, a file system design method applicable to power distribution terminals includes:

[0039] Based on file type and file name, separate physical storage space is allocated in the FLASH device to store each file;

[0040] 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.

[0041] After the file data writing is complete, update the latest file status in the logical unit and store it in the main management area and sub-management area;

[0042] After the file system is powered on, a mounting 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 occurred, the file is restored to its last normal state before the power failure based on the contents of the logical units of the main management area and the sub-management area, as well as the contents of the file's record rollback area.

[0043] According to one embodiment of the present invention, each file is stored in a separate physical storage space in the FLASH device based on its file type and file name:

[0044] All files in the application are categorized, and the categorized files are partitioned on the FLASH device according to their physical addresses. Each file occupies a physical range (physical storage space), and this physical range is indexed by its filename.

[0045] Furthermore, according to one embodiment of the present invention, due to the special characteristics of FLASH devices for reading and writing—that erasure is required before writing, and the erasure unit is 4KB—the internal structure (i.e., management area) of each file is designed, including a main management area (4KB), a sub-management area (4KB), a file data area (N*4KB), and a block area (i.e., a record rollback area for data verification) (4KB) at the end of the file for data verification.

[0046] In this implementation, the main management area and the sub-management area are structurally identical. After writing a file, the file status information is first updated in the main management area, and then the file status information is written back to the sub-management area. The file content is written to the file data area. After writing the file, the record rollback area is also updated.

[0047] In this embodiment, a file directory partition is created, which stores the physical storage addresses of each file. The file address is indexed through this directory, and then the file's management area address is indexed based on the file address. By obtaining the file's management area address information, the file's current status information can be obtained.

[0048] Furthermore, according to one embodiment of the present invention, both the main management area and the sub-management area are composed of 32 logical units, each logical unit being 128 bytes in size;

[0049] A logical unit consists of the file write pointer position, the file erase sector address, the file status, the file size, the logical unit number, the MD5 checksum, and a validity identifier. The logical unit number increments after each write operation.

[0050] Furthermore, according to one embodiment of the present invention, the rollback area is used to write the last sector content (4KB) of the file data to the rollback record area after the end of the file writing process, so as to record the data content at the end of the file.

[0051] In this embodiment, the file reading process involves scanning directory information in the software, indexing the file address based on the filename, and then reading the addresses of the main and sub-management areas of the file stored in the file directory based on the indexed file address. The data content of the main and sub-management areas is then read based on these two addresses. This allows the extraction of the file size and end-of-file position, etc. There are no special requirements for the reading process, as it does not require complex erasing, calculation, or write-back processes.

[0052] File writing process: The file name is indexed to the address of the main management area and sub-management area. The software determines which management area information to use as the target for subsequent management information updates by judging the validity of the main management area and sub-management area.

[0053] Based on the length of the data to be written passed in from the upper-layer API interface and combined with the current file data area write pointer, calculate 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 it does not meet the length, update the erase sector address and erase the next sector space to be written. If the next sector is already at the end of the specified allocated file data area, loop to the beginning sector of the file data area for erasure.

[0054] Write the data passed in from the upper-level API to the file data area;

[0055] After writing the file data, the entire contents of the sector where the file write pointer is located are written to the file's record rollback area.

[0056] Update the latest file status information to the file handle memory, including the file offset pointer, the erased sector number, the file size, and other ownership information;

[0057] The file handle memory data is written to the logical unit of the main management area, and the logical unit number, MD5 check code, and validity flag are recorded. Each main management area consists of 32 logical units, and the logical unit implements a circular write mechanism.

[0058] Furthermore, according to one embodiment of the present invention, the write operation of the logic unit includes even-numbered writes and odd-numbered writes, with the destination address of the odd-numbered writes being the main management area and the destination address of the even-numbered writes being the sub-management area.

[0059] In this implementation, the logical unit write process is as follows: logical unit writes are performed in 128-byte units, divided into main area (main management area) writes and sub-area (sub-management area) writes. After a file write operation, a logical unit write operation is performed immediately. The number of operations is distinguished by parity: odd-numbered operations write data to logical units in the main area, and even-numbered operations write data to logical units in the sub-area. Since the logical unit size is smaller than the sector block size (the logical unit length is 128 bytes, smaller than the FLASH sector size (4KB)), 32 logical units can be written cyclically to one main or sub-management area. Therefore, logical units are written using a cyclic append method. The logical unit sequence number is incremented.

[0060] Furthermore, according to one embodiment of the present invention, after the device software starts, it first performs a file mounting operation. The mounting operation includes: indexing from the file system directory area to the file management area, first checking whether the contents of the main management area and the sub-management area are completely empty. If they are completely empty, it indicates that the file is an empty file and no write operation has been performed, and then the normal process is entered.

[0061] Furthermore, according to one embodiment of the present invention, 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, then scanning and verifying whether the MD5 checksum in the logical unit of the sub-management area is correct, whether the sequence number of the logical unit in the sub-management area is continuous, and whether the validity identifier in the logical unit of the sub-management area is valid; if the sequence number is continuous, the MD5 is correct, and the validity identifier is valid, then it is determined that a power failure occurred when the file was closed, specifically when the main management area was filled and the main area needed to be erased, and a power failure occurred. Here, the content of the sub-management area is restored to the main management area.

[0062] Furthermore, according to one embodiment of the present invention, 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, then scanning and verifying whether the MD5 checksum in the logical unit of the main management area is correct, whether the sequence number of the logical unit in the main management area is continuous, and whether the validity identifier in the logical unit of the main management area is valid; if the sequence number is continuous, the MD5 is correct, and the validity identifier is valid, then it is determined that a power failure occurred when the file was closed, specifically a power failure occurred when updating the sub-management area information, and here the content of the main management area is restored to the sub-management area.

[0063] Furthermore, according to one embodiment of the present invention, 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 both 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 sequence, scanning out the logical unit with the latest sequence number according to the sequence number of the logical units of the main management area and the sub-management area (that is, scanning out the latest sequence 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 sequence numbers of the two logical units, and using the latest one as the logical unit with the latest sequence number), and then judging whether the validity identifier in the logical unit with the latest sequence number is valid and whether the MD5 checksum is correct; if the validity identifier is valid and the MD5 checksum is correct, then the logical unit with the latest sequence number is... If the validity flag is valid, this logical unit is used as the file reference, and all subsequent file write operations are based on this logical unit. If the validity flag is invalid or the MD5 checksum is abnormal, the logical unit with the latest sequence number is invalid (meaning that a power failure occurred while writing the logical unit, but the file data area has already been written normally. If the FLASH write operation is performed using the logical unit with the latest sequence number as the operation address, a write failure will occur). In this case, a rollback operation is performed on the scan queue, rolling back to the next newest logical unit and using this logical unit as the file reference. The record rollback area data at the end of the file is read, and this record rollback area data is written back to the file write pointer position in the logical unit with the latest sequence number confirmed this time, in order to restore the result of the last normal file write operation.

[0064] According to the above-described solution of the present invention, the file system designed by the file system design method for power distribution terminals is suitable for the efficient operation of power distribution terminals and supports power failure safety. It has low CPU resource consumption, fast startup and mounting speed, and avoids the loss of important event records during startup due to slow file system mounting. The use of balanced write / erase of the file management area improves the lifespan of the FLASH memory. The scanning and judgment of logical units in the main management area and sub-management area solves the problem of file system corruption during power failures, improving the stability and reliability of system operation.

[0065] Furthermore, to achieve the above objectives, the present invention also provides a file system design system suitable for power distribution terminals, comprising:

[0066] The storage space partitioning module allocates independent physical storage space in the FLASH device to store each file based on its file type and file name.

[0067] The file structure partitioning module consists of a main management area, a sub-management area, a file data area, and a record rollback area for each file. 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.

[0068] The file update storage module updates the current latest file status to the logical unit after the file data writing is completed, and stores it in the main management area and the sub-management area;

[0069] The file mount operation module performs the mount operation after the file system is powered on. It determines whether any 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 occurred, it restores the file to its last normal state before the power failure based on the contents of the logical units of the main management area and the sub-management area, as well as the contents of the file's record rollback area.

[0070] The file system design system for power distribution terminals according to the present invention can realize the file system design method for power distribution terminals. The specific method steps are as described above and will not be repeated here.

[0071] Furthermore, to achieve the above objectives, the present invention also provides an electronic device, including 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, it implements the file system design method for power distribution terminals as described above.

[0072] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the file system design method for power distribution terminals as described above.

[0073] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0074] Example 1

[0075] Figure 1 This is a diagram illustrating file storage. For example... Figure 1As shown, files are categorized according to their application functions, and independent physical spaces are allocated in the FLASH memory 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 file directory stores the physical starting address of the file in the FLASH memory. Each file has a main management area and a sub-management area, and the storage structure and content of the main and sub-management areas are consistent. The main management area consists of M logical units, each with a fixed size of 128 bytes. Each logical unit stores the file's write pointer position, file size, file status, number of sectors, file erase sector address, logical unit sequence number, validity flag, and MD5 checksum. The content and partition structure of the sub-management area are consistent with the main management area. The record rollback area is used to write the last sector (4KB) of file data to the rollback record area after the end of file writing, recording the end-of-file data. After opening a file, the system first retrieves the latest logical unit data based on the filename. Then, it writes the target data to the file data area according to the file description information. After the file writing is complete, it updates the logical unit memory area, increments the logical unit number, calculates the MD5 checksum of the unit, and writes it as a validity flag. Finally, the logical unit is written to either the main management area or the sub-management area. If the current write operation is an odd-numbered write, it is written to the main management area; otherwise, it is written to the sub-management area. If a partition is full, all partition contents are erased, and the write operation is repeated from the beginning. For file read operations, the system indexes the file's management area based on the filename, reads the latest logical unit from the management area, and thus obtains the current state of the file.

[0076] Figure 2The file system mounting process is as follows: First, scan the file directory. Based on the filename, locate the physical starting address of the target file. First, determine if both the primary and secondary management areas (primary and secondary management areas) are empty. If so, the file is empty, and the scan ends, proceeding directly to the next file. If the primary management area is empty but the secondary management area is not, scan the logical units of the secondary management area and restore the latest information from the secondary management area to the primary management area. If both the primary and secondary management areas are not empty, scan the logical units of the primary management area and restore the latest information from the primary management area to the secondary management area. If both the primary and secondary management areas are not empty, scan the logical units of both the primary and secondary management areas separately. Based on the sequence number of the scanned logical unit, locate the latest logical unit content. Then, based on the validity flag and MD5 checksum of the latest logical unit, determine if it is a valid logical unit. If it is invalid, revert to the last valid logical unit and use this unit as the basis for the current file operation. Simultaneously, the file's record rollback area data is restored to the starting position of the last write operation in the file's data area, achieving data recovery before the file system error. The file system mounting ends after the logical unit scan of the main and sub-management areas of all files in the file directory is complete.

[0077] Those skilled in the art will recognize that the modules and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented using electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0078] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and equipment can be referred to the corresponding process in the foregoing method implementation, and will not be repeated here.

[0079] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0080] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the objectives of the embodiments of the present invention, depending on actual needs.

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

[0082] If the aforementioned functions are implemented as 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 solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the energy-saving signal transmission / reception methods of various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0083] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in this application.

[0084] It should be understood that the sequence number of each step in the invention and its embodiments does not absolutely imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

Claims

1. A file system design method applicable to power distribution terminals, characterized in that, include: Based on file type and file name, separate physical storage space is allocated 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 both the main management area and the sub-management area are composed of logical units. After the file data writing is completed, the current latest file status is updated in the logical unit and stored in the main management area and the sub-management area; After the file system is powered on, the mounting 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 occurred, the file is restored to its last normal state before the power failure 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. Both the main management area and the sub-management area consist of 32 logical units, each of which is 128 bytes in size. The logical unit consists of the file write pointer position, the file erase sector address, the file status, the file size, the logical unit number, the MD5 checksum, and the validity identifier; The write operation of the logical unit includes even-time writes and odd-time writes. The destination address of odd-time writes is the main management area, and the destination address of even-time writes is the sub-management area. The mounting operation includes scanning and judging the logical units of the main management area and 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 sequentially. The logical unit with the latest sequence number is scanned according to the sequence number of the logical units in the main management area and the sub-management area. Then, it is judged whether the validity identifier in the logical unit with the latest sequence number is valid and whether the MD5 checksum is correct. If the validity identifier is valid and the MD5 checksum is correct, the logical unit with the latest sequence number is valid, and this logical unit is used as the file reference. Subsequent file write operations are based on this logical unit. If the validity identifier is invalid or the MD5 checksum is abnormal, the logical unit with the latest sequence number is invalid. At this time, a rollback operation is performed on the scan queue, rolling back to the previous second-newest logical unit and using this logical unit as the file reference. The record rollback area data at the end of the file is read, and the record rollback area data is written back to the file write pointer position in the logical unit with the latest sequence number confirmed this time, so as to restore the result of the last normal file write operation.

2. The file system design method for power distribution terminals according to claim 1, characterized in that, The mounting operation includes scanning and judging the logical units of the main management area and sub-management area of ​​the file. If the main management area is empty and the sub-management area is not empty, the MD5 checksum of the logical unit in the sub-management area is checked to see if it is correct, if the sequence number of the logical unit in the sub-management area is continuous, and if the validity identifier of the logical unit in the sub-management area is valid. After checking and confirming that the MD5 checksum of the logical unit in the sub-management area is correct, the sequence number is continuous, and the validity identifier is valid, the information content of the sub-management area is restored to the main management area.

3. The file system design method for power distribution terminals according to claim 1, 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 checksum in the logical unit of the main management area is checked to see if it is correct, if the sequence number of the logical unit in the main management area is continuous, and if the validity identifier in the logical unit of the main management area is valid. After checking and confirming that the MD5 checksum of the logical unit in the main management area is correct, the sequence number is continuous, and the validity identifier is valid, the information content of the main management area is restored to the sub-management area.

4. A file system design system for power distribution terminals that implements the file system design method for power distribution terminals as described in any one of claims 1-3, characterized in that, include: The storage space partitioning module allocates independent physical storage space in the FLASH device to store each file based on its file type and file name. The file structure partitioning module consists of a main management area, a sub-management area, a file data area, and a record rollback area for each file. 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. The file update storage module updates the current latest file status to the logical unit after the file data writing is completed, and stores it in the main management area and the sub-management area; The file mount operation module performs the mount operation after the file system is powered on. It determines whether any 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 occurred, it restores the file to its last normal state before the power failure based on the contents of the logical units of the main management area and the sub-management area, as well as the contents of the file's record rollback area.

5. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the file system design method for a power distribution terminal as described in any one of claims 1-3.

6. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the file system design method for power distribution terminals as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Method and system for recording nude core program log of relay protection device

    CN114546680A

  • Parameter storage mechanism of embedded system

    CN112596808A

  • FLASH file management system with service life management function

    CN112631516A