Information storage method and system based on character device, storage medium and device

By creating a collection of character device nodes and operation functions for abnormal data access in an embedded storage device, the problem of abnormal data being erased during system upgrade or factory reset is solved, and the effective recording and reading of abnormal data is realized, ensuring the reliability and accessibility of data.

CN120104067AActive Publication Date: 2025-06-06CHENGDU BIWIN STORAGE TECHNOLOGY CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202510578470.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-07
Publication Date
2025-06-06
Estimated Expiration
2045-05-07

AI Technical Summary

Technical Problem

The prior art cannot effectively prevent exception-related information from being erased when the system is upgraded or restored to factory settings, and it is impossible to effectively record and read exception data.

Method used

By creating character device nodes for exception data access in embedded storage devices and setting up a collection of operation functions for them, skipping the file system to directly access the storage area, ensuring that exception data is not erased when the system is upgraded or restored to factory settings, and can effectively record and read exception data.

Benefits of technology

It realizes reducing the impact of abnormal data when the system is upgraded or restored to factory settings, and can obtain abnormal data when the storage device system is not running normally, ensuring the reliability and accessibility of abnormal data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104067A_ABST
    Figure CN120104067A_ABST
Patent Text Reader

Abstract

The invention discloses an information storage method and system based on character equipment, a storage medium and equipment. The information storage method comprises the following steps: acquiring a storage area with a preset size in embedded storage equipment; creating a character device node for abnormal data access under a preset directory node of the embedded storage device, and taking the storage area as a storage space of the character device node; setting an operation function set required for accessing the character device node; initializing the storage area into a preset data storage structural body, wherein the data storage structural body is used for recording the position of abnormal data; and judging whether abnormity occurs or not, if yes, calling the operation function set, and writing the target abnormal data into the storage data structural body. The influence on the abnormal data is reduced when the system is upgraded or factory settings are restored, and the abnormal data can be obtained under the condition that the storage equipment system is not normally operated, so that the abnormal data can be effectively recorded and read.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to an information storage method, system, storage medium and device based on character devices. Background Art

[0002] In Linux system, character device is one of the basic devices that constitute the system. Compared with block device, it has the characteristics of flexible access, low latency and no need for complex cache management. In embedded development, especially in ARM (AdvancedRISC Machines, microprocessor), UFS (Universal Flash Storage) is used as the system disk to run Android system code. When the system is running, the file system and block device driver are used to store user data, mainly in the system data partition, but this method has limitations. For example, when the system is running, it may cause abnormal operation due to device failure, but the user cannot perceive the specific cause of the abnormality, so it is necessary to store the abnormal data so that the user can understand the cause of the abnormality through the stored abnormal data.

[0003] Currently, the way to store data when the system is running is by creating and writing files. This method has the following problems: First, this information will be erased when the system is upgraded or restored to factory settings. For example: 1. During the system update or upgrade process, if an error occurs, the data partition may be formatted or overwritten to restore the normal operation of the system. 2. The system test has a factory reset test, and it must be ensured that the factory reset data is not erased. 3. Factory reset will delete file system user data. Second, the specific physical location of the data storage cannot be located. If some abnormalities occur and the file system cannot be started, the system will restart, making it impossible to record and read abnormal data. Summary of the invention

[0004] The technical problem to be solved by the present invention is: to provide an information storage method, system, storage medium and device based on character devices, so as to avoid abnormal related information being erased when the system is upgraded or the factory settings are restored, and abnormal data can be effectively recorded and read.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: An information storage method based on a character device, comprising: Get a storage area of ​​a preset size in an embedded storage device; Creating a character device node for abnormal data access under a preset directory node of the embedded storage device, and using the storage area as a storage space of the character device node; Set the set of operation functions required to access the character device node; Initializing the storage area to a preset data storage structure, wherein the data storage structure is used to record the location of abnormal data; Determine whether an exception occurs, and if so, call the operation function set and write the target exception data into the storage data structure.

[0006] In order to solve the above technical problems, another technical solution adopted by the present invention is: An information storage system based on a character device, comprising an application calling module, an I / O scheduling module, a character device driver module, a storage function module, a UFS driver module and a UFS chip; The application calling module includes a user space program; The I / O scheduling module includes a character device node access I / O interface, and the character device node access I / O interface establishes a connection between the user space program and the character device driver module; The character device driver module is used to create a character device node for abnormal data access, transmit control commands and control parameters through the character device node, and control the specific functions of the storage function module; The storage function module implements the various steps in the above-mentioned character device-based information storage method, including an interface and a storage area for access by the UFS driver module; the UFS driver module is used to realize reading and writing of the UFS chip.

[0007] In order to solve the above technical problems, another technical solution adopted by the present invention is: A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the various steps of the above-mentioned information storage method based on a character device.

[0008] In order to solve the above technical problems, another technical solution adopted by the present invention is: An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of the above-mentioned information storage method based on character device is implemented.

[0009] The beneficial effects of the present invention are as follows: a storage area is selected in an embedded storage device as the storage space of a character device node, that is, a storage area is separately set up in the embedded storage device for storing abnormal data, and the abnormal data is separated from the user data and the system data, thereby reducing the impact on the abnormal data when the system is upgraded or restored to factory settings; and by creating a character device node for abnormal data access under a preset directory node of the embedded storage device, and setting a set of operation functions required for access for the character device node, when abnormal data is accessed, the file system of the embedded storage device can be skipped, and access is performed through the set of operation functions on the character device node, so that even when the storage device system is not operating normally, the abnormal data can be obtained; when the storage device system is operating normally, the specific position of the abnormal data can be located based on the data storage structure to obtain the target abnormal data, so that the abnormal data can be effectively recorded and read. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 A flowchart of a method for storing information based on a character device in an embodiment of the present invention; Figure 2 A structural diagram of a data storage structure of an information storage method based on a character device in an embodiment of the present invention; Figure 3 A schematic diagram of a parameter format of an abnormal data request of an information storage method based on a character device in an embodiment of the present invention; Figure 4 A schematic diagram of the structure of an information storage system based on a character device in an embodiment of the present invention; Figure 5 The figure is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0011] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0012] An information storage method based on a character device, comprising: Get a storage area of ​​a preset size in an embedded storage device; Creating a character device node for abnormal data access under a preset directory node of the embedded storage device, and using the storage area as a storage space of the character device node; Set the set of operation functions required to access the character device node; Initializing the storage area to a preset data storage structure, wherein the data storage structure is used to record the location of abnormal data; Determine whether an exception occurs, and if so, call the operation function set and write the target exception data into the storage data structure.

[0013] As can be seen from the above description, the beneficial effects of the present invention are: selecting a storage area in the embedded storage device as the storage space of the character device node, that is, setting up a separate storage area in the embedded storage device for storing abnormal data, separating the abnormal data from the user data and the system data, thereby reducing the impact on the abnormal data when the system is upgraded or restored to factory settings; and by creating a character device node for abnormal data access under a preset directory node of the embedded storage device, and setting a set of operation functions required for access for the character device node, when abnormal data is accessed, the file system of the embedded storage device can be skipped, and access is performed through the set of operation functions on the character device node, so that even when the storage device system is not operating normally, the abnormal data can be obtained; when the storage device system is operating normally, the specific location of the abnormal data can be located based on the data storage structure to obtain the target abnormal data, so that the abnormal data can be effectively recorded and read.

[0014] Furthermore, after obtaining a storage area of ​​a preset size in the embedded storage device, the method further includes: Dividing the storage area into at least two storage partitions of the same size, each of the storage partitions storing data in the form of the data storage structure; The storage data structure includes a version number and an index number of the next storage partition, and writing the target abnormal data into the storage data structure includes: Obtain the storage partition storing the latest version number, and obtain the index number of the next storage partition in the storage partition; Taking the storage partition corresponding to the index number of the next storage partition as the target partition; The target abnormal data is written into the target partition, and the version number in the target partition is updated.

[0015] From the above description, it can be seen that by dividing the storage area into multiple storage partitions of the same size, and storing the abnormal data in the corresponding target partition according to the index number of the next storage partition during the data storage process, and updating the corresponding version number after the target abnormal data is written, the version number is used to indicate the time point when the corresponding storage partition is updated.

[0016] Furthermore, the storage data structure includes a data entry set and a data area, and different abnormal data are represented by different identifiers in the data entry set; The step of writing the target abnormal data into the storage data structure comprises: Determine whether there is a target data entry in the data entry set of the target partition that is consistent with the identifier of the target abnormal data; if so, write the abnormal data into the data area according to the target data entry; If not, the target abnormal data is written into the data area and a new data entry is generated, and the new data entry is added to the data entry set.

[0017] From the above description, it can be seen that by using different identifiers to represent different exception data, and comparing the data entry set of the target partition with the target exception data, when there is a target data entry in the data entry set that is consistent with the identifier of the target exception data, the target exception data is written into the data area based on the target data entry; and when there is no consistent target data entry, a new data entry is generated and added to the data entry set, so that different exception types can be distinguished.

[0018] Furthermore, the data entry records the offset address and data size of the data in the data area; Writing the target abnormal data into the data area according to the target data entry comprises: If the size of the original exception data corresponding to the target data entry is greater than or equal to the size of the target exception data, writing the target exception data into the data area according to the offset address, and replacing the size of the original exception data with the size of the target exception data; If the size of the original exception data corresponding to the target data entry is smaller than the target exception data, the target data entry is deleted, and the exception data corresponding to the subsequent data entry is moved to the offset address of the original exception data; the target exception data is written to the end of all the exception data in the data area, and a new data entry is generated for the target exception data and stored at the end of all the data entries.

[0019] From the above description, it can be seen that by comparing the relationship between the data sizes of the target data entry and the target exception data, when the data size of the target data entry is greater than or equal to the size of the target exception data, it means that the target data entry can accommodate the target exception data, and therefore the target exception data is written to the original position of the target data entry; and when the data size of the target data entry is smaller than the target exception data, it means that the target data entry cannot accommodate the target exception data, and therefore the target data entry is deleted, and the position of the exception data corresponding to the target data entry is filled by moving the position of the exception data corresponding to the subsequent data entry, and then the target exception data is written to the end of all exception data in the data area, and the new data entry is added to the end of all data entries, thereby reducing redundant data and storage space occupancy.

[0020] Further, the storage data structure includes a free address offset position; The step of writing the target abnormal data into the data area and generating a new data entry comprises: Writing the abnormal data into the data area according to the idle address offset position; The new data entry is generated according to the size, identifier and free address offset position of the target abnormal data.

[0021] From the above description, it can be seen that by setting the free address offset position in the storage data structure, when the corresponding data entry does not exist in the target partition, the target abnormal data can be written to the corresponding position of the data area according to the free address offset position, so that the data can be stored in the data area in an orderly manner; and a new data entry is generated according to the size, identifier and free address offset position of the target abnormal data, indicating the attributes of the newly written abnormal data, so as to distinguish different abnormal data.

[0022] Furthermore, the storage data structure also includes free capacity and the number of data; The storage status of the current target partition is obtained, and the new free capacity, free address offset position and data quantity are calculated according to the storage status and the original data is replaced.

[0023] From the above description, it can be seen that after calculating the new free capacity, free address offset position and number of data, the original free capacity, free address offset position and number of data are updated, and the entire updated storage data structure is moved to the next storage partition. By changing the storage position of the abnormal data, illegal users cannot lock on to the storage position of the abnormal data, thereby playing a role in protecting data security.

[0024] Further, the version number includes a first version number and a second version number stored in different locations, and the method further includes: Receive an instruction to read target abnormal data; Determine whether the first version number is consistent with the second version number, if so, read the target abnormal data; if not, prompt data abnormality; The updating of the version number in the target partition comprises: The first version number and the second version number are updated simultaneously.

[0025] From the above description, it can be seen that by storing two version numbers at different locations in the storage data structure, and comparing the two version numbers each time the data in the corresponding storage partition is read, it is determined whether the data has been tampered with, thereby improving data security.

[0026] Another embodiment of the present invention provides an information storage system based on a character device, including an application calling module, an I / O scheduling module, a character device driver module, a storage function module, a UFS driver module and a UFS chip; The application calling module includes a user space program; The I / O scheduling module includes a character device node access I / O interface, and the character device node access I / O interface establishes a connection between the user space program and the character device driver module; The character device driver module is used to create a character device node for abnormal data access, transmit control commands and control parameters through the character device node, and control the specific functions of the storage function module; The storage function module implements the various steps in the above-mentioned character device-based information storage method, including an interface and a storage area for access by the UFS driver module; The UFS driver module is used to implement reading and writing of the UFS chip.

[0027] Another embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program implements the steps in the above-mentioned character device-based information storage method.

[0028] Another embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned character device-based information storage method when executing the computer program.

[0029] The character device-based information storage method, system, storage medium and device provided by the present invention can be applied to the UFS information scenario of character devices, for example, to implement UFS information storage based on character devices on the Android platform, which is described below through specific implementation methods: Embodiment 1 Please refer to Figure 1 , an information storage method based on a character device, comprising: S1. Obtain a storage area of ​​a preset size in an embedded storage device; wherein, in some embodiments, the storage area is further divided into at least two storage partitions of the same size, and each of the storage partitions stores data in the form of the data storage structure. For example, a 16K storage area (vendor_storage) is applied to the embedded storage device, and further divided into 4 storage units, each of which is 4K in size, then the first storage partition 1, the second storage partition 2, the third storage partition 3, and the fourth storage partition 4 are obtained respectively.

[0030] S2. Create a character device node for abnormal data access under the preset directory node of the embedded storage device, and use the storage area as the storage space of the character device node; that is, the existing system accesses the embedded storage device through the file system, while in this embodiment, the embedded storage device can be accessed through the character device node.

[0031] For example, create a character device node under the / dev node: / dev / vendor_storage; Miscellaneous Devices in the Linux kernel is a general device type used to represent some devices that are not suitable for other device types; the miscellaneous device driver provides a flexible mechanism that allows different types of devices to be registered as miscellaneous devices, and the miscellaneous device driver is used to create miscellaneous character device nodes in the file system, that is, character device nodes of the storage area (vendor_storage).

[0032] S3. Set the set of operation functions required to access the character device node. For example, the character device node ( / dev / vendor_storage) corresponds to a file node operation set structure: file_operations. The operation set structure contains the file opening function open, the file closing function release, the device non-data operation function unlocked_ioctl and other functional functions. After creating the character device node, the function implementation of the file node operation set structure will be instantiated, so that the character device node can be accessed and the operation of each storage partition can be realized. The specific function form is as follows: const struct file_operations vendor_storage_fops = { .open = vendor_storage_open, / / File opening function .unlocked_ioctl = vendor_storage_ioctl, / / Processing device non-data operation function .release = vendor_storage_release, / / file closing function }.

[0033] S4. Initialize the storage area to a preset data storage structure, where the data storage structure is used to record the location of abnormal data. Specifically, call an initialization function (ufs_vendor_storage_init) to initialize a data storage structure (g_vendor).

[0034] Please refer to Figure 2 , the data storage structure is a structure for storing data in each storage partition, including a unique tag number (tag), for example, the unique tag number is 0x524B5644, each partition has the same tag number, which is used for data reading and writing and request verification; the next storage partition index number (next_index), for example, the next storage partition index number of the first storage partition 1 is the second storage partition 2, the next storage partition index number of the second storage partition 2 is the third storage partition 3, the next storage partition index number of the third storage partition 3 is the fourth storage partition 4, and the next storage partition index number of the fourth storage partition 4 is the first storage partition 1; a data entry set (item[n]), for example, a data entry set is represented as: item

[50] , where each element (n) represents a written data item information, including an identifier (id), an offset address of the data in the data area (offset), and a size of the data (size). Each data item contains a unique identifier id, which represents a type of data (i.e., an identifier Represents an exception, which may occur multiple times, but the content of the exception data is different). There is no exception data during initialization. Only when the exception data needs to be stored will the data storage structure be updated and written to one of the storage partitions; number of data (item_num); free address offset position (free_offset); free capacity (free_size); data area (data) [UFS_VENDOR_PART_SIZE*4096-424]; reserved data (hash) for subsequent expansion; the first version number (version1) and the second version number (version2). Usually, the first version number is the same as the second version number. Verification is performed each time the data is read. If the first version number is consistent with the second version number, the corresponding target data is read; if not, a data exception is prompted, indicating that the data has been tampered with; at the same time, when reading exception data, specific exception data can be accessed periodically through the identifier id.

[0035] S5. Determine whether an exception occurs. If so, call the operation function set and write the target exception data into the storage data structure. Specifically: When an exception occurs, first traverse all storage partitions in the storage area (vendor_storage) and search for the latest historical exception data according to the version number; in which, there is no exception data in the storage area in the original state, that is, there is no exception data in each storage partition, and they are all initialized storage data structures. Therefore, the version number and unique label number of each storage partition searched are 0, and any storage partition can be selected to write the target exception data; and when the target exception data is written, the corresponding storage partition will update the version number; wherein, the version number is updated in a monotonically increasing manner, for example, the version number can be a combination of the current time and the version number, which is used to indicate the time point when the storage partition is updated, that is, the storage partitions (1-4) store exception data at 4 different time points respectively; If this is not the first time writing, perform the following steps: S51, obtaining the storage partition storing the latest version number, and obtaining the index number of the next storage partition in the storage partition, specifically: First, traverse all storage partitions. Since each storage partition may contain abnormal data, you need to first find the storage partition with the latest version number (taking the above monotonically increasing method as an example, select the largest version number) and the unique tag number 0x524B5644. At the same time, the first version number and the second version number must be consistent. For example, if the first storage partition 1 stores the latest version number and meets the above requirements, then get the index number of the next storage partition in the first storage partition 1, that is, the index number of the next storage partition is the second storage partition 2. Figure 3 The figure shows the parameter format of the exception data request; tag is the unique tag number, id is the identifier, len is the data size (length), and data

[1024] is the access data storage space.

[0036] S52: Use the storage partition corresponding to the index number of the next storage partition as the target partition; that is, use the second storage partition 2 as the target partition.

[0037] S53, writing the target abnormal data into the target partition, and updating the version number in the target partition; that is, writing the target abnormal data into the second storage partition 2, and updating the version number; when updating the version number, increasing the sequence numbers of the first version number and the second version number by one.

[0038] The target abnormal data writing specifically includes the following steps: S531. Determine whether there is a target data entry in the data entry set of the target partition that is consistent with the identifier of the target exception data; that is, before writing the target exception data, check through the data entry set in the data storage structure whether there is a data entry that is consistent with the current exception identifier id; if so, execute S532; if not, execute S533.

[0039] S532, writing the target abnormal data into the data area according to the target data entry; wherein the target data entry records the offset address and data size of the data in the data area; If the size of the original exception data corresponding to the target data entry is greater than or equal to the size of the target exception data, writing the target exception data into the data area according to the offset address, and replacing the size of the original exception data with the size of the target exception data; If the size of the original exception data corresponding to the target data entry is smaller than the target exception data, the target data entry is deleted, and the exception data corresponding to the subsequent data entry is moved to the offset address of the original exception data. For example, if the exception data corresponding to all data entries are stored in the data area in sequence, the offset addresses of the exception data corresponding to the subsequent data entries are moved forward in sequence, and the corresponding offset addresses are updated; the target exception data is written to the end of all the exception data in the data area, and a new data entry is generated for the target exception data and stored at the end of all the data entries.

[0040] S533, writing the target abnormal data into the data area and generating a new data entry, and adding the new data entry into the data entry set, specifically: The target abnormal data is written into the data area according to the idle address offset position; and the new data entry is generated according to the size, identifier and idle address offset position of the target abnormal data, that is, a data entry is added according to the corresponding attribute of the target abnormal data.

[0041] S6. After the target abnormal data is written, the storage data structure is updated. Specifically: S61, obtaining the storage status of the current target partition, calculating the new free capacity, free address offset position and data quantity according to the storage status and replacing the original data; S62, moving the updated storage data structure in the target partition to the storage partition corresponding to the index number of the next storage partition; for example, abnormal data is currently read from the second storage partition 2, and then written back after being updated and modified. At this time, the data is written to the third storage partition 3, which plays a role in protecting the data.

[0042] Embodiment 2 Please refer to Figure 4 , an information storage system based on a character device, comprising an application calling module, an I / O scheduling module, a character device driver module, a storage function module, a UFS driver module and a UFS chip; The application calling module (vendor_storage_read_vcc / vendor_storage_read_vccq) includes a user space program; includes abnormal data writing, abnormal data reading, abnormal data erasing interfaces, and the interfaces are mainly implemented by accessing character devices through the I / O scheduling module interface; The I / O scheduling module includes a character device node access I / O interface, and the character device node access I / O interface establishes a connection between the user space program and the character device driver module; for example, it includes open(), close(), Ioctl() and other interfaces for character device nodes to perform read and write operations; the user space interacts with the character device driver through various interfaces of the I / O scheduling module; The character device driver module ( / dev / vendor_storage, file_operations) is used to create a character device node for abnormal data access, transmit control commands and control parameters through the character device node, and control the specific functions of the storage function module to provide an access bridge; The storage function module implements the corresponding steps of the above storage method, including an interface and a storage area for access by the UFS driver module; for example, the storage function module includes an interface for the driver layer to access the storage area (vendor_storage), specifically including an interface vendor_storage_open for opening the storage area, an interface vendor_storage_ioctl for receiving control commands and access parameters transmitted by the character device module, and performing write, read and erase operations on the storage area; the interface mainly operates the UFS driver module to realize the writing and reading of abnormal data; The UFS driver module is used to implement reading and writing of the UFS chip.

[0043] The specific process is as follows: In the application calling module, the user space program obtains the device descriptor through the device node / dev / vendor_storage created by the interface open(); then the application calling module calls the interface ioctl() to send a request to the device descriptor, and sends a control command to the storage function layer program through the device descriptor node. The processor will call the corresponding unlocked_ioctl function; calling the interface ioctl() will pass the request command and request parameters. The request command is as follows: Figure 3 As shown, it includes data reading, data writing, and data clearing. The request parameters include the tag number tag, the identifier id of the accessed data, the accessed data length len, and the data storage space data; the storage function module program recognizes the control command, determines the correctness of the request parameters, such as determining whether the tag number tag is equal to 0x56524551, and identifies the type of abnormal data to be accessed through the identifier id, and finally completes the data reading, data writing, and data clearing operations through the UFS driver module.

[0044] Among them, abnormal data includes overvoltage and overcurrent information; when storing overvoltage and overcurrent information, the corresponding type identifier is carried, and 64 bytes are written each time, for example: If VCC overvoltage occurs, write the VCC overvoltage value and overvoltage status, a total of 64 bytes; the first 32 bytes are the VCC overvoltage value, the last 32 bytes are the VCC overvoltage status, and the identifier is 1.

[0045] If VCC overcurrent occurs, write the VCC overcurrent value and overcurrent status, a total of 64 bytes; the first 32 bytes are the VCC overcurrent value, the last 32 bytes are the VCC overcurrent status, and the identifier is 2.

[0046] If VCCQ overvoltage occurs, the VCCQ overvoltage value and overvoltage status are written, a total of 64 bytes; the first 32 bytes are the VCCQ overvoltage value, the next 32 bytes are the VCCQ overvoltage status, and the identifier is 3.

[0047] If VCCQ overcurrent occurs, the VCCQ overcurrent value and overcurrent status are written, a total of 64 bytes; the first 32 bytes are the VCCQ overcurrent value, the last 32 bytes are the VCCQ overcurrent status, and the identifier is 4.

[0048] Embodiment 3 A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the various steps of the information storage method based on a character device as described in the first embodiment.

[0049] Embodiment 4 Please refer to Figure 5 , an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, each step of the information storage method based on a character device as described in Embodiment 1 is implemented.

[0050] In summary, the information storage method, system, storage medium and device based on character devices provided by the present invention select a storage area in the embedded storage device as the storage space of the character device node, that is, a storage area is separately set up in the embedded storage device for storing abnormal data, and the abnormal data is separated from the user data and the system data, so as to reduce the impact on the abnormal data when the system is upgraded or restored to factory settings. And by creating a character device node for abnormal data access under the preset directory node of the embedded storage device, and setting the operation function set required for access for the character device node, when abnormal data is accessed, the file system of the embedded storage device can be skipped, and access is performed through the operation function set on the character device node, that is, the user can access the abnormality-related information without touching the main operating system; and when the system is operating normally, the specific physical location of the target abnormal data can be located based on the data storage structure to obtain the target abnormal data; because the file system of the embedded storage device can be skipped to read data, when the storage device system is not operating normally, the embedded storage device can be removed to obtain the abnormal data through other tools, so that the abnormal data can be effectively recorded and read.

[0051] In the above embodiments provided in the present application, it should be understood that the disclosed methods, devices, computer-readable storage media, and electronic devices 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. There may be other division methods in actual implementation, such as multiple components or modules can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or components or modules, which can be electrical, mechanical or other forms.

[0052] The components described as separate components may or may not be physically separated, and the components shown as components may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the components may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0053] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each component may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0054] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0055] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0056] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0057] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for storing information based on a character device, characterized in that: include: Get a storage area of ​​a preset size in an embedded storage device; Creating a character device node for abnormal data access under a preset directory node of the embedded storage device, and using the storage area as a storage space of the character device node; Set the set of operation functions required to access the character device node; Initializing the storage area to a preset data storage structure, wherein the data storage structure is used to record the location of abnormal data; Determine whether an exception occurs, and if so, call the operation function set and write the target exception data into the storage data structure.

2. The information storage method based on character device according to claim 1, characterized in that: After obtaining the storage area of ​​the preset size in the embedded storage device, the method further includes: Dividing the storage area into at least two storage partitions of the same size, each of the storage partitions storing data in the form of the data storage structure; The storage data structure includes a version number and an index number of the next storage partition, and writing the target abnormal data into the storage data structure includes: Obtain the storage partition storing the latest version number, and obtain the index number of the next storage partition in the storage partition; Taking the storage partition corresponding to the index number of the next storage partition as the target partition; The target abnormal data is written into the target partition, and the version number in the target partition is updated.

3. The information storage method based on character device according to claim 2, characterized in that: The storage data structure includes a data entry set and a data area, and different abnormal data are represented by different identifiers in the data entry set; The step of writing the target abnormal data into the storage data structure comprises: Determine whether there is a target data entry in the data entry set of the target partition that is consistent with the identifier of the target abnormal data; if so, write the abnormal data into the data area according to the target data entry; If not, the target abnormal data is written into the data area and a new data entry is generated, and the new data entry is added to the data entry set.

4. The information storage method based on character device according to claim 3, characterized in that: The data entry records the offset address and data size of the abnormal data in the data area; Writing the target abnormal data into the data area according to the target data entry comprises: If the size of the original exception data corresponding to the target data entry is greater than or equal to the size of the target exception data, writing the target exception data into the data area according to the offset address, and replacing the size of the original exception data with the size of the target exception data; If the size of the original exception data corresponding to the target data entry is smaller than the target exception data, the target data entry is deleted, and the exception data corresponding to the subsequent data entry is moved to the offset address of the original exception data; the target exception data is written to the end of all the exception data in the data area, and a new data entry is generated for the target exception data and stored at the end of all the data entries.

5. The information storage method based on character device according to claim 3, characterized in that: The storage data structure includes a free address offset position; The step of writing the target abnormal data into the data area and generating a new data entry comprises: Writing the target abnormal data into the data area according to the idle address offset position; The new data entry is generated according to the size, identifier and free address offset position of the target abnormal data.

6. The information storage method based on character device according to claim 5, characterized in that: The storage data structure also includes free capacity and the number of data; The storage status of the current target partition is obtained, and the new free capacity, free address offset position and data quantity are calculated according to the storage status and the original data is replaced.

7. The information storage method based on character device according to claim 2, characterized in that: The version number includes a first version number and a second version number stored in different locations, and the method further includes: Receive an instruction to read target abnormal data; Determine whether the first version number is consistent with the second version number, if so, read the target abnormal data; if not, prompt data abnormality; The updating of the version number in the target partition comprises: The first version number and the second version number are updated simultaneously.

8. An information storage system based on character devices, characterized in that: It includes application calling module, I / O scheduling module, character device driver module, storage function module, UFS driver module and UFS chip; The application calling module includes a user space program; The I / O scheduling module includes a character device node access I / O interface, and the character device node access I / O interface establishes a connection between the user space program and the character device driver module; The character device driver module is used to create a character device node for abnormal data access, transmit control commands and control parameters through the character device node, and control the specific functions of the storage function module; The storage function module implements each step of the character device-based information storage method as described in any one of claims 1-7, and includes an interface and a storage area for access by the UFS driver module; the UFS driver module is used to realize reading and writing of the UFS chip.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the character device-based information storage method as described in any one of claims 1 to 7 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, each step of the character device-based information storage method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Error tracking method of embedded system and device thereof

    CN101539883A

  • Data index method and server based edition vector

    CN103116615A

  • Method and system for collecting abnormal information after embedded OLT collapses

    CN105183576A

  • Database implementation method and database

    CN106570056A

  • Embedded equipment and abnormal information processing method thereof

    CN110750375A