A processing method of a data interface module
By providing a universal storage data interface module, the compatibility problem of file processing interfaces between upper-layer applications and different operating systems is solved, thereby simplifying development and optimizing resources.
Patent Information
- Application Number
- CN202311243882.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-09-22
AI Technical Summary
In existing technologies, the compatibility issues of file processing interfaces between upper-layer applications and different operating systems lead to high development difficulty, large volume of redundant code, and wasted storage resources.
This invention provides a universal storage data interface module that is backward compatible with the file processing interfaces of various operating systems and provides a unified instruction processing interface and data management instruction set. Through this module, upper-layer applications can manage application data simply by using the unified instruction set.
It reduces the development difficulty of upper-layer applications, reduces the volume of redundant code, and improves the utilization rate of storage resources.
Smart Images

Figure CN117311614B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a processing method for a data storage interface module. Background Technology
[0002] Operating systems use files as data storage objects. Upper-layer applications running on an operating system generate a lot of application data during operation. When managing the storage of this application data, these applications need to call the operating system's file processing interfaces. This means that a cross-system upper-layer application needs to integrate the file processing interfaces of various operating systems and their corresponding interface call logic into its own code. This approach increases the development difficulty of upper-layer applications and also results in large volumes of redundant code and wasted storage resources. Summary of the Invention
[0003] The purpose of this invention is to address the shortcomings of existing technologies by providing a data storage interface module processing method, electronic device, and computer-readable storage medium. The data storage interface module provided by this invention is a universal interface module. This universal interface module is backward compatible with the file processing interfaces of various operating systems, provides a unified instruction processing interface, and offers a unified set of data management instructions (create, read, modify, delete, and restore). On an operating system with this universal interface module installed, upper-layer applications only need to use the unified data management instruction set to manage application data, eliminating the need for redundant code development to ensure compatibility with the file processing interfaces of various operating systems. This invention achieves two goals: firstly, it reduces the difficulty and efficiency of upper-layer application development; secondly, it reduces the volume of redundant application code and improves the utilization rate of system storage resources.
[0004] To achieve the above objectives, a first aspect of the present invention provides a method for processing a data storage interface module, the method comprising:
[0005] The first storage data interface module receives a first operation instruction sent by a first upper-layer application on the first operating system through a first instruction processing interface; and extracts the corresponding first instruction header and first instruction body from the first operation instruction; the first storage data interface module is a software or hardware interface module installed on the first operating system; the first operating system provides the first storage data interface module with a first file processing interface that can perform file creation, deletion, and read / write operations on the current operating system for interface calls; the first storage data interface module provides the first instruction processing interface to any of the first upper-layer applications on the first operating system for interface calls; the first operation instruction includes the first instruction header and the first instruction body, and the first instruction header includes an interface initialization instruction header, an interface closing instruction header, a data creation instruction header, a data reading instruction header, a data modification instruction header, a data deletion instruction header, and a data recovery instruction header;
[0006] When the first instruction header is the interface initialization instruction header, the first file processing interface of the first operating system is called to create two binary files with an initial file size of 0 on the first operating system as the corresponding first storage file and first index table file; and two data items are added to the first index table file, namely the first counter and the first index table, and the first counter is initialized to 0 and the first index table is initialized to an empty index table; and when the file is successfully created and the index table file is successfully set, the first initialization state, which is set to a successful state, is sent back to the first upper-layer application through the first instruction processing interface;
[0007] When the first instruction header is the data creation instruction header, application layer data creation processing is performed based on the first instruction body, the first index table file, and the first storage file to generate a corresponding first creation state and a first creation data handle; and the first creation state and the first creation data handle are sent back to the first upper-layer application through the first instruction processing interface; the first creation state includes a failure state and a success state; when the first creation state is a failure state, the corresponding first creation data handle is empty;
[0008] When the first instruction header is the data read instruction header, application layer data read processing is performed according to the first instruction body, the first index table file, and the first storage file to generate the corresponding first read status and first read data; and the first read status and the first read data are sent back to the first upper-layer application through the first instruction processing interface; the first read status includes a failure status and a success status; when the first read status is a failure status, the corresponding first read data is empty;
[0009] When the first instruction header is the data modification instruction header, the application layer data modification process is performed based on the first instruction body, the first index table file, and the first storage file to generate a corresponding first modification state; and the first modification state is sent back to the first upper-layer application through the first instruction processing interface; the first modification state includes a failure state and a success state.
[0010] When the first instruction header is the data deletion instruction header, the application layer data deletion process is performed based on the first instruction body, the first index table file, and the first storage file to generate a corresponding first deletion status; and the first deletion status is sent back to the first upper-layer application through the first instruction processing interface; the first deletion status includes a failure status and a success status.
[0011] When the first instruction header is the data recovery instruction header, application-layer data recovery processing is performed based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first recovery status and first recovery data; and the first recovery status and the first recovery data are sent back to the first upper-layer application through the first instruction processing interface; the first recovery status includes a failure status and a success status; when the first recovery status is a failure status, the corresponding first recovery data is empty;
[0012] When the first instruction header is the interface closing instruction header, the first file processing interface is called to delete the first storage file and the first index table file; and when the file deletion is successful, the first closing state, which is specifically set to a successful state, is sent back to the first upper-layer application through the first instruction processing interface.
[0013] Preferably, the first operating system includes at least Windows series operating systems, Windows Phone series operating systems, Unix series operating systems, Linux series operating systems, Android series operating systems, iOS series operating systems, and Mac series operating systems;
[0014] The first storage file includes multiple first storage data blocks; each first storage data block includes first block length data, first status data, first permission data, and first application storage data; the data lengths of the first block length data, the first status data, and the first permission data are all fixed lengths, respectively preset first, second, and third data lengths; the first block length data is the data length of the corresponding first storage data block; the first status data includes usage status and idle status; the first permission data includes four types of permission flags, namely data read permission flag, data modify permission flag, data delete permission flag, and data restore permission flag; the flag values of the four types of permission flags all include an allow flag value and a prohibit flag value;
[0015] All the first storage data blocks in the first storage file are stored sequentially in a chain-like manner; each first storage data block corresponds to a first data block offset; the first data block offset corresponding to the first first storage data block is a preset starting offset, and the first data block offset corresponding to the next first storage data block is the sum of the first data block offset corresponding to the previous first storage data block and the first block length data; the starting offset is the first binary data position in the first storage file by default;
[0016] The first index table file includes the first counter and the first index table; the first counter is the total number of the first storage data blocks in the first storage file whose first status data is in the usage state; the first index table includes multiple first index records; the first index record includes a first application layer data handle and a first application data block offset; the total number of records in the first index record is greater than or equal to the count value of the first counter;
[0017] When the first instruction header is the interface initialization instruction header or the interface closing instruction header, the corresponding first instruction body is empty; when the first instruction header is the data creation instruction header, the corresponding first instruction body includes first application data and first permission configuration, the first permission configuration includes four types of permission flags: data read permission flag, data modify permission flag, data delete permission flag, and data restore permission flag, the flag values of the four types of permission flags all include an allow flag value and a prohibit flag value; when the first instruction header is the data read instruction header, the corresponding first instruction body includes a first read data handle; when the first instruction header is the data modify instruction header, the corresponding first instruction body includes a first modify data handle and first application modify data; when the first instruction header is the data delete instruction header, the corresponding first instruction body includes a first delete data handle; when the first instruction header is the data restore instruction header, the corresponding first instruction body includes a first restore data handle.
[0018] Preferably, the step of generating a corresponding first creation state and a first creation data handle by performing application-layer data creation processing based on the first instruction body, the first index table file, and the first storage file specifically includes:
[0019] The first storage data interface module extracts the corresponding first application data and the first permission configuration from the first instruction body; and initializes the corresponding first creation state to a failure state and the corresponding first creation data handle to empty;
[0020] The length of the first application data is statistically analyzed to generate a corresponding first length. The sum of the first length and the preset lengths of the first, second, and third data is taken as the corresponding first total length. A corresponding first block length data is set as the first total length. A corresponding first status data is set as the usage status. The first permission configuration is taken as a corresponding first permission data. The first application data is taken as a corresponding first application storage data. The obtained first block length data, first status data, first permission data, and first application storage data are combined to form a corresponding first storage data block. The first file processing interface is called to add the first storage data block obtained in this instance to the end of the first storage file. The storage position of the starting data of the first storage data block added in this instance in the first storage file is taken as the corresponding first offset.
[0021] After successfully obtaining the first offset, a unique data identifier is assigned to the first storage data block added at this time as the corresponding first data identifier; the first data identifier is used as a corresponding first application layer data handle; the first offset is used as a corresponding first application data block offset; and the obtained first application layer data handle and the first application data block offset form a corresponding first index record; and the first file processing interface is called to add the first index record to the end of the first index table of the first index table file, and the count value of the first counter of the first index table file is incremented by 1;
[0022] After successfully adding index records and updating counters in the first index table file, the first creation data handle is updated to the corresponding first data identifier, and the first creation status is updated to a success status.
[0023] The obtained first creation state and the first creation data handle are used as the output of the application layer data creation process.
[0024] Preferably, the step of generating the corresponding first read status and first read data by performing application-layer data reading processing based on the first instruction body, the first index table file, and the first storage file specifically includes:
[0025] The first storage data interface module extracts the corresponding first read data handle from the first instruction body;
[0026] The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first read data handle in the first index table is extracted as the corresponding current index record.
[0027] When the current index record is empty, the corresponding first read status is set to a failure status, and the corresponding first read data is set to empty;
[0028] When the current index record is not empty, the offset of the first application data block in the current index record is extracted as the corresponding current offset; the first storage data block whose starting data storage position in the first storage file matches the current offset is taken as the corresponding current storage data block; the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data read permission flags of the first status data and the first permission data are identified; if the first status data is in a usage state and the flag value of the data read permission flag is an allowed flag value, the first file processing interface is called to read the first application storage data in the current storage data block as the corresponding first read data, and the corresponding first read status is set to a successful state when the read is successful; if the first status data is in an idle state or the flag value of the data read permission flag is a prohibited flag value, the corresponding first read status is set to a failed state, and the corresponding first read data is set to empty.
[0029] The obtained first read status and the first read data are used as the output of the application layer data read processing result for this time.
[0030] Preferably, the step of generating a corresponding first modified state by performing application-layer data modification processing based on the first instruction body, the first index table file, and the first storage file specifically includes:
[0031] The first storage data interface module extracts the corresponding first modified data handle and the first application modified data from the first instruction body;
[0032] The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first modified data handle in the first index table is extracted as the corresponding current index record.
[0033] When the current index record is empty, the corresponding first modification status is set to a failure status;
[0034] When the current index record is not empty, the offset of the first application data block in the current index record is extracted as the corresponding current offset; and the first storage data block in the first storage file whose starting data storage position matches the current offset is taken as the corresponding current storage data block; and the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data modification permission flag of the first status data and the first permission data is identified; if the first status data is in the usage state and the flag value of the data modification permission flag is an allowed flag value, then the first file processing interface is called to update the first application storage data in the current storage data block to the corresponding first application modified data, and the corresponding first modification status is set to the success state when the update is successful; if the first status data is in the idle state or the flag value of the data modification permission flag is a prohibited flag value, then the corresponding first modification status is set to the failure state.
[0035] The obtained first modified state is output as the result of this application layer data modification process.
[0036] Preferably, the step of generating a corresponding first deletion status by performing application-layer data deletion processing based on the first instruction body, the first index table file, and the first storage file specifically includes:
[0037] The first storage data interface module extracts the corresponding first deletion data handle from the first instruction body;
[0038] The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first deleted data handle in the first index table is extracted as the corresponding current index record.
[0039] When the current index record is empty, the corresponding first deletion status is set to a failure status;
[0040] When the current index record is not empty, the offset of the first application data block of the current index record is extracted as the corresponding current offset; and the first storage data block in the first storage file whose starting data storage position matches the current offset is taken as the corresponding current storage data block; and the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data deletion permission flag of the first status data and the first permission data is identified; if the first status data is in use and the flag value of the data deletion permission flag is an allowed flag value, then the first file processing interface is called to update the first status data of the current storage data block to an idle state, and the first file processing interface is called to decrement the count value of the first counter of the first index table file by 1, and after the first status data and the first counter are successfully updated, the corresponding first deletion state is set to a successful state; if the first status data is in an idle state or the flag value of the data deletion permission flag is a prohibited flag value, then the corresponding first deletion state is set to a failed state.
[0041] The obtained first deletion status is output as the result of this application layer data deletion process.
[0042] Preferably, the step of generating the corresponding first recovery status and first recovery data by performing application-layer data recovery processing based on the first instruction body, the first index table file, and the first storage file specifically includes:
[0043] The first storage data interface module extracts the corresponding first recovery data handle from the first instruction body;
[0044] The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first recovery data handle in the first index table is extracted as the corresponding current index record.
[0045] When the current index record is empty, the corresponding first recovery status is set to failure status, and the corresponding first recovery data is set to empty;
[0046] When the current index record is not empty, the offset of the first application data block of the current index record is extracted as the corresponding current offset; the first storage data block whose starting data storage position in the first storage file matches the current offset is taken as the corresponding current storage data block; the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data recovery permission flag of the first status data and the first permission data is identified; if the first status data is in an idle state and the flag value of the data recovery permission flag is an allowed flag value, the first file processing interface is called to update the first status data of the current storage data block to a used state, and the first application storage data of the current storage data block is read as the corresponding first recovery data, and the first file processing interface is called to increment the count value of the first counter of the first index table file by 1, and after the first status data and the first counter are successfully updated, the corresponding first recovery status is set to a successful state; if the first status data is in an idle state or the flag value of the data recovery permission flag is a prohibited flag value, the corresponding first recovery status is set to a failed state, and the corresponding first recovery data is set to empty.
[0047] The obtained first recovery status and the first recovery data are used as the output of the application layer data recovery process.
[0048] A second aspect of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0049] The processor is configured to be coupled to the memory, read and execute instructions in the memory to implement the method described in the first aspect above;
[0050] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0051] A third aspect of the present invention provides a computer-readable storage medium storing computer instructions that, when executed by a computer, cause the computer to perform the method described in the first aspect.
[0052] This invention provides a method for processing a storage data interface module, an electronic device, and a computer-readable storage medium. The storage data interface module provided by this invention is a universal interface module. This universal interface module is backward compatible with the file processing interfaces of various operating systems, provides a unified instruction processing interface, and offers a unified set of data management instructions (create, read, modify, delete, and restore). On an operating system with this universal interface module installed, upper-layer applications only need to use the unified data management instruction set to manage application data, eliminating the need for redundant code development to ensure compatibility with the file processing interfaces of various operating systems. This invention reduces the difficulty and efficiency of upper-layer application development, while also reducing the volume of redundant application code and improving the utilization rate of system storage resources. Attached Figure Description
[0053] Figure 1 This is a schematic diagram of a processing method for a data storage interface module provided in Embodiment 1 of the present invention;
[0054] Figure 2 This is a schematic diagram of the structure of an electronic device provided in Embodiment 2 of the present invention. Detailed Implementation
[0055] 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. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0056] Embodiment 1 of the present invention provides a processing method for a storage data interface module, such as... Figure 1 The schematic diagram of a data storage interface module processing method provided in Embodiment 1 of the present invention mainly includes the following steps:
[0057] Step 1: The first storage data interface module receives the first operation instruction sent by the first upper-layer application on the first operating system through the first instruction processing interface; and extracts the corresponding first instruction header and first instruction body from the first operation instruction.
[0058] The first storage data interface module is a software or hardware interface module installed on the first operating system; the first operating system provides the first storage data interface module with a first file processing interface that can perform file creation, deletion, and read / write operations on the current operating system for interface calls; the first storage data interface module provides a first instruction processing interface to any first upper-layer application on the first operating system for interface calls; the first operating system in this embodiment of the invention includes at least Windows series operating systems, Windows Phone series operating systems, Unix series operating systems, Linux series operating systems, Android series operating systems, iOS series operating systems, and Mac series operating systems;
[0059] The first operation instruction includes a first instruction header and a first instruction body. The first instruction header includes an interface initialization instruction header, an interface closing instruction header, a data creation instruction header, a data reading instruction header, a data modification instruction header, a data deletion instruction header, and a data recovery instruction header.
[0060] Here, the first storage data interface module of this embodiment of the invention is compatible with various file processing interfaces of multiple operating systems, and provides a statistical instruction processing interface, namely the first instruction processing interface, to the upper-layer application. The first storage data interface module of this embodiment of the invention also provides the upper-layer application with a unified set of interface management instructions (interface initialization, interface closing) and a unified set of data management instructions (data creation, data reading, data modification, data deletion, data recovery). The first storage data interface module of this embodiment of the invention plans a corresponding pair of storage resources for the upper-layer application, namely the first storage file and the first index table file mentioned below, through the interface management instructions (interface initialization, interface closing); and performs storage management of the application data of the upper-layer application through the data management instruction set (data creation, data reading, data modification, data deletion, data recovery).
[0061] It should be noted that the first storage data interface module in this embodiment of the invention achieves the purpose of simultaneously serving multiple first upper-layer applications by allocating a corresponding first instruction processing interface to each first upper-layer application, and each first instruction processing interface corresponds by default to a pair of first storage files and a first index table file.
[0062] Step 2: When the first instruction header is the interface initialization instruction header, the first file processing interface of the first operating system is called to create two binary files with an initial file size of 0 on the first operating system as the corresponding first storage file and first index table file; and two data items are added to the first index table file, namely the first counter and the first index table, and the first counter is initialized to 0 and the first index table is initialized to an empty index table; and when the file is created successfully and the index table file is set successfully, the first initialization state set to the successful state is sent back to the first upper-layer application through the first instruction processing interface.
[0063] When the first instruction header is an interface initialization instruction header or an interface shutdown instruction header, the corresponding first instruction body is empty.
[0064] The reason why the file is created in binary format in this embodiment of the invention is that binary files have the highest data storage utilization rate on all operating systems, and the file processing interface of binary files is also the most flexible, allowing data access based on relative offsets within the file.
[0065] The data format of the first storage file in this embodiment of the invention is as follows:
[0066] The first storage file includes multiple first storage data blocks; wherein, the first storage data block includes first block length data, first status data, first permission data, and first application storage data.
[0067] Here, each first storage data block corresponds to application data created by a first upper-layer application; the first block length data is the data length of the corresponding first storage data block; the first status data includes usage status and idle status. When it is in usage status, it means that the corresponding application data has not yet been deleted; when it is in idle status, it means that the corresponding application data has been deleted; the first permission data includes four types of permission flags: data read permission flag, data modify permission flag, data delete permission flag, and data restore permission flag. The flag values of these four types of permission flags include allow flag values and prohibit flag values. When the flag value of each type of permission flag is an allow flag value, it means that the current application data can be read, modified, deleted, or restored. When the flag value of each type of permission flag is a prohibit flag value, it means that the current application data cannot be read, modified, deleted, or restored.
[0068] It should be noted that in the first storage data block of the present invention, the data lengths of the first block length data, the first status data and the first permission data are all fixed lengths, which are preset first, second and third data lengths respectively; the first, second and third data lengths here are three preset data length parameters.
[0069] It should also be noted that when the file size of the first storage file in this embodiment of the invention is 0, there are no storage data blocks inside; when the file size of the first storage file is not 0, it consists of one or more first storage data blocks, and all the first storage data blocks are stored sequentially in a chain-like manner. Each first storage data block corresponds to a first data block offset. The first data block offset corresponding to the first first storage data block is a preset starting offset, and the first data block offset corresponding to the next first storage data block is the sum of the first data block offset corresponding to the previous first storage data block and the length data of the first block. The starting offset here is the position of the first binary data in the first storage file by default.
[0070] The data format of the first index table file in this embodiment of the invention is as follows:
[0071] The first index table file includes a first counter and a first index table; wherein, the first index table includes multiple first index records; the first index record includes a first application layer data handle and a first application data block offset.
[0072] Here, each first index record in the first index table corresponds one-to-one with a first storage data block in the first storage file. As previously known, each first storage data block corresponds one-to-one with application data created by the first upper-layer application. The first application layer data handle is a unique data identifier assigned by the first storage data interface module of this embodiment to the corresponding application data. The first application data block offset is the offset of the first storage data block corresponding to the current index record in the first data block in the first storage file. Furthermore, the first counter represents the total number of first storage data blocks in the first storage file whose first state data is in a "used" state. Because not every first storage data block in the first storage file has a "used" state as its first state data, not every first index record in the first index table corresponds to a first storage data block whose first state data is in a "used" state. Therefore, the total number of records in the first index table must be greater than or equal to the count value of the first counter.
[0073] Step 3: When the first instruction header is a data creation instruction header, the application layer data creation process is performed based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first creation state and the first creation data handle; and the first creation state and the first creation data handle are sent back to the first upper-layer application through the first instruction processing interface.
[0074] When the first instruction header is a data creation instruction header, the corresponding first instruction body includes first application data and first permission configuration. The first permission configuration includes four types of permission flags: data read permission flag, data modify permission flag, data delete permission flag, and data restore permission flag. The flag values of the four types of permission flags include an allow flag value and a prohibit flag value. The first creation status includes a failure status and a success status. When the first creation status is a failure status, the corresponding first creation data handle is empty.
[0075] Specifically, it includes: Step 31, when the first instruction header is a data creation instruction header, performing application layer data creation processing based on the first instruction body, the first index table file and the first storage file to generate the corresponding first creation state and the first creation data handle;
[0076] Specifically, this includes: step 311, extracting the corresponding first application data and first permission configuration from the first instruction body; and initializing the corresponding first creation state to a failure state and the corresponding first creation data handle to empty;
[0077] Step 312: Calculate the length of the first application data to generate a corresponding first length, and use the sum of the first length and the preset lengths of the first, second, and third data as the corresponding first total length. Set a corresponding first block length data as the first total length. Set a corresponding first status data as the usage status. Set the first permission configuration as a corresponding first permission data. Set the first application data as a corresponding first application storage data. Combine the obtained first block length data, first status data, first permission data, and first application storage data to form a corresponding first storage data block. Call the first file processing interface to add the obtained first storage data block to the end of the first storage file, and use the storage position of the starting data of the added first storage data block in the first storage file as the corresponding first offset.
[0078] Step 313: After successfully obtaining the first offset, assign a unique data identifier to the first storage data block to be added as the corresponding first data identifier; use the first data identifier as a corresponding first application layer data handle; use the first offset as a corresponding first application data block offset; and form a corresponding first index record by combining the obtained first application layer data handle and the first application data block offset; and call the first file processing interface to add the first index record to the end of the first index table of the first index table file, and increment the count value of the first counter of the first index table file by 1.
[0079] Step 314: After successfully adding index records and updating counters in the first index table file, update the first creation data handle to the corresponding first data identifier and update the first creation status to a success status.
[0080] Step 315: The obtained first creation state and first creation data handle are output as the result of this application layer data creation process;
[0081] Step 32: Send the first creation status and the first creation data handle back to the first upper-layer application through the first instruction processing interface.
[0082] Step 4: When the first instruction header is a data read instruction header, perform application layer data read processing based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first read status and first read data; and send the first read status and first read data back to the first upper-layer application through the first instruction processing interface.
[0083] Wherein, when the first instruction header is a data read instruction header, the corresponding first instruction body includes a first read data handle; the first read state includes a failure state and a success state; when the first read state is a failure state, the corresponding first read data is empty;
[0084] Specifically, it includes: Step 41, when the first instruction header is a data read instruction header, performing application layer data read processing based on the first instruction body, the first index table file and the first storage file to generate the corresponding first read status and first read data;
[0085] Specifically, this includes: step 411, extracting the corresponding first read data handle from the first instruction body;
[0086] Step 412: Call the first file processing interface to query the first index table of the first index table file, and extract the first index record in the first index table that matches the first application layer data handle and the first read data handle as the corresponding current index record;
[0087] Step 413: When the current index record is empty, set the corresponding first read status to failure status and set the corresponding first read data to empty;
[0088] Step 414: When the current index record is not empty, extract the offset of the first application data block of the current index record as the corresponding current offset; and take the first storage data block in the first storage file whose starting data storage position matches the current offset as the corresponding current storage data block; and call the first file processing interface to read the corresponding first status data and first permission data from the current storage data block; and identify the data read permission flag of the first status data and the first permission data; if the first status data is in the usage state and the flag value of the data read permission flag is the allowed flag value, then call the first file processing interface to read the first application storage data of the current storage data block as the corresponding first read data, and set the corresponding first read status to the success state when the read is successful; if the first status data is in the idle state or the flag value of the data read permission flag is the prohibited flag value, then set the corresponding first read status to the failure state, and set the corresponding first read data to empty;
[0089] Step 415: The obtained first read status and first read data are output as the application layer data read processing result for this time;
[0090] Step 42: Send the first read status and the first read data back to the first upper-layer application through the first instruction processing interface.
[0091] Step 5: When the first instruction header is a data modification instruction header, perform application-layer data modification processing based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first modification state; and send the first modification state back to the first upper-layer application through the first instruction processing interface.
[0092] When the first instruction header is a data modification instruction header, the corresponding first instruction body includes a first modified data handle and a first application modified data; the first modification status includes a failure status and a success status.
[0093] Specifically, it includes: Step 51, when the first instruction header is a data modification instruction header, performing application-layer data modification processing based on the first instruction body, the first index table file and the first storage file to generate the corresponding first modification state;
[0094] Specifically, it includes: step 511, extracting the corresponding first modified data handle and first application modified data from the first instruction body;
[0095] Step 512: Call the first file processing interface to query the first index table of the first index table file, and extract the first index record in the first index table that matches the first application layer data handle and the first modified data handle as the corresponding current index record;
[0096] Step 513: When the current index record is empty, set the corresponding first modification status to failure status;
[0097] Step 514: When the current index record is not empty, extract the offset of the first application data block of the current index record as the corresponding current offset; and take the first storage data block in the first storage file whose starting data storage position matches the current offset as the corresponding current storage data block; and call the first file processing interface to read the corresponding first status data and first permission data from the current storage data block; and identify the data modification permission flag of the first status data and the first permission data; if the first status data is in the usage state and the flag value of the data modification permission flag is the allowed flag value, then call the first file processing interface to update the first application storage data of the current storage data block to the corresponding first application modification data, and set the corresponding first modification status to the success state when the update is successful; if the first status data is in the idle state or the flag value of the data modification permission flag is the prohibited flag value, then set the corresponding first modification status to the failure state.
[0098] Step 515: The obtained first modified state is output as the result of this application layer data modification process;
[0099] Step 52: Send the first modified state back to the first upper-layer application through the first instruction processing interface.
[0100] Step 6: When the first instruction header is a data deletion instruction header, perform application-layer data deletion processing based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first deletion status; and send the first deletion status back to the first upper-layer application through the first instruction processing interface.
[0101] When the first instruction header is a data deletion instruction header, the corresponding first instruction body includes a first data deletion handle; the first deletion status includes a failure status and a success status.
[0102] Specifically, it includes: Step 61, when the first instruction header is a data deletion instruction header, performing application-layer data deletion processing based on the first instruction body, the first index table file and the first storage file to generate the corresponding first deletion status;
[0103] Specifically, this includes: Step 61, extracting the corresponding first deletion data handle from the first instruction body;
[0104] Step 62: Call the first file processing interface to query the first index table of the first index table file, and extract the first index record in the first index table that matches the first application layer data handle and the first deleted data handle as the corresponding current index record;
[0105] Step 63: When the current index record is empty, set the corresponding first deletion status to failure status;
[0106] Step 64: When the current index record is not empty, extract the offset of the first application data block of the current index record as the corresponding current offset; and take the first storage data block in the first storage file whose starting data storage position matches the current offset as the corresponding current storage data block; and call the first file processing interface to read the corresponding first status data and first permission data from the current storage data block; and identify the data deletion permission flag of the first status data and the first permission data; if the first status data is in use and the data deletion permission flag is set to an allowed flag value, call the first file processing interface to update the first status data of the current storage data block to an idle state, and call the first file processing interface to decrement the count value of the first counter of the first index table file by 1, and set the corresponding first deletion state to a successful state after both the first status data and the first counter are successfully updated; if the first status data is in an idle state or the data deletion permission flag is set to a prohibited flag value, set the corresponding first deletion state to a failed state.
[0107] Step 65: The obtained first deletion status is output as the result of this application layer data deletion process;
[0108] Step 62: Send the first deletion status back to the first upper-layer application through the first instruction processing interface.
[0109] Step 7: When the first instruction header is a data recovery instruction header, perform application-layer data recovery processing based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first recovery status and first recovery data; and send the first recovery status and first recovery data back to the first upper-layer application through the first instruction processing interface;
[0110] Wherein, when the first instruction header is a data recovery instruction header, the corresponding first instruction body includes a first recovery data handle; the first recovery state includes a failure state and a success state; when the first recovery state is a failure state, the corresponding first recovery data is empty;
[0111] Specifically, it includes: Step 71, when the first instruction header is a data recovery instruction header, performing application-layer data recovery processing based on the first instruction body, the first index table file and the first storage file to generate the corresponding first recovery status and first recovery data;
[0112] Specifically, this includes: step 711, extracting the corresponding first recovery data handle from the first instruction body;
[0113] Step 712: Call the first file processing interface to query the first index table of the first index table file, and extract the first index record in the first index table that matches the first application layer data handle and the first recovery data handle as the corresponding current index record;
[0114] Step 713: When the current index record is empty, set the corresponding first recovery status to failure status and set the corresponding first recovery data to empty;
[0115] Step 714: When the current index record is not empty, extract the offset of the first application data block of the current index record as the corresponding current offset; and take the first storage data block in the first storage file whose starting data storage position matches the current offset as the corresponding current storage data block; and call the first file processing interface to read the corresponding first status data and first permission data from the current storage data block; and identify the data recovery permission flag of the first status data and the first permission data; if the first status data is in an idle state and the flag value of the data recovery permission flag is an allowed flag value, then call the first file processing interface to update the first status data of the current storage data block to a used state, and read the first application storage data of the current storage data block as the corresponding first recovery data, and call the first file processing interface to increment the count value of the first counter of the first index table file by 1, and set the corresponding first recovery status to a successful state after the first status data and the first counter are successfully updated; if the first status data is in an idle state or the flag value of the data recovery permission flag is a prohibited flag value, then set the corresponding first recovery status to a failed state, and set the corresponding first recovery data to empty;
[0116] Step 715: The obtained first recovery status and first recovery data are output as the result of this application layer data recovery process;
[0117] Step 72: Send the first recovery status and the first recovery data back to the first upper-layer application through the first instruction processing interface.
[0118] Step 8: When the first instruction header is the interface close instruction header, call the first file processing interface to delete the first storage file and the first index table file; and when the file deletion is successful, send back the first close state, which is specifically set to the success state, to the first upper-layer application through the first instruction processing interface.
[0119] Figure 2 This is a schematic diagram of an electronic device provided in Embodiment 2 of the present invention. This electronic device can be the aforementioned terminal device or server, or it can be a terminal device or server connected to the aforementioned terminal device or server that implements the method of the embodiments of the present invention. Figure 2As shown, the electronic device may include: a processor 301 (e.g., CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transmission and reception operations of the transceiver 303. The memory 302 may store various instructions for performing various processing functions and implementing the processing steps described in the foregoing method embodiments. Preferably, the electronic device involved in the embodiments of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The communication port 306 is used for communication between the electronic device and other peripherals.
[0120] exist Figure 2 The system bus 305 mentioned can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This system bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 2 The symbol is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write libraries, and read-only libraries). Memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk drive.
[0121] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0122] It should be noted that the embodiments of the present invention also provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the methods provided in the above embodiments.
[0123] This invention also provides a chip for executing instructions, which is used to perform the processing steps described in the foregoing method embodiments.
[0124] This invention provides a method for processing a storage data interface module, an electronic device, and a computer-readable storage medium. The storage data interface module provided by this invention is a universal interface module. This universal interface module is backward compatible with the file processing interfaces of various operating systems, provides a unified instruction processing interface, and offers a unified set of data management instructions (create, read, modify, delete, and restore). On an operating system with this universal interface module installed, upper-layer applications only need to use the unified data management instruction set to manage application data, eliminating the need for redundant code development to ensure compatibility with the file processing interfaces of various operating systems. This invention reduces the difficulty and efficiency of upper-layer application development, while also reducing the volume of redundant application code and improving the utilization rate of system storage resources.
[0125] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. 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.
[0126] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0127] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A processing method for a data storage interface module, characterized in that, The method includes: The first storage data interface module receives a first operation instruction sent by a first upper-layer application on the first operating system through a first instruction processing interface; and extracts the corresponding first instruction header and first instruction body from the first operation instruction; the first storage data interface module is a software or hardware interface module installed on the first operating system; the first operating system provides the first storage data interface module with a first file processing interface that can perform file creation, deletion, and read / write operations on the current operating system for interface calls; the first storage data interface module provides the first instruction processing interface to any of the first upper-layer applications on the first operating system for interface calls; the first operation instruction includes the first instruction header and the first instruction body, and the first instruction header includes an interface initialization instruction header, an interface closing instruction header, a data creation instruction header, a data reading instruction header, a data modification instruction header, a data deletion instruction header, and a data recovery instruction header; When the first instruction header is the interface initialization instruction header, the first file processing interface of the first operating system is called to create two binary files with an initial file size of 0 on the first operating system as the corresponding first storage file and first index table file; and two data items are added to the first index table file, namely the first counter and the first index table, and the first counter is initialized to 0 and the first index table is initialized to an empty index table; and when the file is successfully created and the index table file is successfully set, the first initialization state, which is set to a successful state, is sent back to the first upper-layer application through the first instruction processing interface; When the first instruction header is the data creation instruction header, application layer data creation processing is performed based on the first instruction body, the first index table file, and the first storage file to generate a corresponding first creation state and a first creation data handle; and the first creation state and the first creation data handle are sent back to the first upper-layer application through the first instruction processing interface; the first creation state includes a failure state and a success state; when the first creation state is a failure state, the corresponding first creation data handle is empty; When the first instruction header is the data read instruction header, application layer data read processing is performed according to the first instruction body, the first index table file, and the first storage file to generate the corresponding first read status and first read data; and the first read status and the first read data are sent back to the first upper-layer application through the first instruction processing interface; the first read status includes a failure status and a success status; when the first read status is a failure status, the corresponding first read data is empty; When the first instruction header is the data modification instruction header, the application layer data modification process is performed based on the first instruction body, the first index table file, and the first storage file to generate a corresponding first modification state; and the first modification state is sent back to the first upper-layer application through the first instruction processing interface; the first modification state includes a failure state and a success state. When the first instruction header is the data deletion instruction header, the application layer data deletion process is performed based on the first instruction body, the first index table file, and the first storage file to generate a corresponding first deletion status; and the first deletion status is sent back to the first upper-layer application through the first instruction processing interface; the first deletion status includes a failure status and a success status. When the first instruction header is the data recovery instruction header, application-layer data recovery processing is performed based on the first instruction body, the first index table file, and the first storage file to generate the corresponding first recovery status and first recovery data; and the first recovery status and the first recovery data are sent back to the first upper-layer application through the first instruction processing interface; the first recovery status includes a failure status and a success status; when the first recovery status is a failure status, the corresponding first recovery data is empty; When the first instruction header is the interface close instruction header, the first file processing interface is called to delete the first storage file and the first index table file; and when the file deletion is successful, the first close state, which is specifically set to the success state, is sent back to the first upper-layer application through the first instruction processing interface; The first storage file includes multiple first storage data blocks; each first storage data block includes first block length data, first status data, first permission data, and first application storage data; the lengths of the first block length data, the first status data, and the first permission data are all fixed lengths, respectively preset first, second, and third data lengths; the first block length data is the data length of the corresponding first storage data block; the first status data includes usage status and idle status; the first permission data includes four types of permission flags: data read permission flag, data modify permission flag, data delete permission flag, and data restore permission flag; the flag values of the four types of permission flags all include an allow flag value and a prohibit flag value. The first index table file includes the first counter and the first index table; the first counter is the total number of the first storage data blocks in the first storage file whose first status data is in the usage state; the first index table includes multiple first index records; the first index record includes a first application layer data handle and a first application data block offset; the total number of records in the first index record is greater than or equal to the count value of the first counter; the first index record corresponds to one first storage data block; the first application layer data handle is a unique data identifier of the corresponding first storage data block; the first application data block offset is the storage location of the starting data of the corresponding first storage data block in the first storage file; When the first instruction header is the interface initialization instruction header or the interface closing instruction header, the corresponding first instruction body is empty; when the first instruction header is the data creation instruction header, the corresponding first instruction body includes first application data and first permission configuration, the first permission configuration includes four types of permission flags: data read permission flag, data modify permission flag, data delete permission flag, and data restore permission flag, the flag values of the four types of permission flags all include an allow flag value and a prohibit flag value; when the first instruction header is the data read instruction header, the corresponding first instruction body includes a first read data handle; when the first instruction header is the data modify instruction header, the corresponding first instruction body includes a first modify data handle and first application modify data; when the first instruction header is the data delete instruction header, the corresponding first instruction body includes a first delete data handle; when the first instruction header is the data restore instruction header, the corresponding first instruction body includes a first restore data handle.
2. The processing method of the storage data interface module according to claim 1, characterized in that, The first operating system includes at least the Windows series operating system, the Windows Phone series operating system, the Unix series operating system, the Linux series operating system, the Android series operating system, the iOS series operating system, and the Mac series operating system; All the first storage data blocks in the first storage file are stored sequentially in a chain-like manner; each first storage data block corresponds to a first data block offset; the first data block offset corresponding to the first first storage data block is a preset starting offset, and the first data block offset corresponding to the next first storage data block is the sum of the first data block offset corresponding to the previous first storage data block and the first block length data; the starting offset is the first binary data position in the first storage file by default.
3. The processing method of the storage data interface module according to claim 2, characterized in that, The step of generating a corresponding first creation state and a first creation data handle based on the first instruction body, the first index table file, and the first storage file through application-layer data creation processing specifically includes: The first storage data interface module extracts the corresponding first application data and the first permission configuration from the first instruction body; and initializes the corresponding first creation state to a failure state and the corresponding first creation data handle to empty; The length of the first application data is statistically analyzed to generate a corresponding first length. The sum of the first length and the preset lengths of the first, second, and third data is taken as the corresponding first total length. A corresponding first block length data is set as the first total length. A corresponding first status data is set as the usage status. The first permission configuration is taken as a corresponding first permission data. The first application data is taken as a corresponding first application storage data. The obtained first block length data, first status data, first permission data, and first application storage data are combined to form a corresponding first storage data block. The first file processing interface is called to add the first storage data block obtained in this instance to the end of the first storage file. The storage position of the starting data of the first storage data block added in this instance in the first storage file is taken as the corresponding first offset. After successfully obtaining the first offset, a unique data identifier is assigned to the first storage data block added at this time as the corresponding first data identifier; the first data identifier is used as a corresponding first application layer data handle; the first offset is used as a corresponding first application data block offset; and the obtained first application layer data handle and the first application data block offset form a corresponding first index record; and the first file processing interface is called to add the first index record to the end of the first index table of the first index table file, and the count value of the first counter of the first index table file is incremented by 1; After successfully adding index records and updating counters in the first index table file, the first creation data handle is updated to the corresponding first data identifier, and the first creation status is updated to a success status. The obtained first creation state and the first creation data handle are used as the output of the application layer data creation process.
4. The processing method of the storage data interface module according to claim 2, characterized in that, The step of generating the corresponding first read status and first read data by performing application-layer data reading processing based on the first instruction body, the first index table file, and the first storage file specifically includes: The first storage data interface module extracts the corresponding first read data handle from the first instruction body; The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first read data handle in the first index table is extracted as the corresponding current index record. When the current index record is empty, the corresponding first read status is set to a failure status, and the corresponding first read data is set to empty; When the current index record is not empty, the offset of the first application data block in the current index record is extracted as the corresponding current offset; the first storage data block whose starting data storage position in the first storage file matches the current offset is taken as the corresponding current storage data block; the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data read permission flags of the first status data and the first permission data are identified; if the first status data is in a usage state and the flag value of the data read permission flag is an allowed flag value, the first file processing interface is called to read the first application storage data in the current storage data block as the corresponding first read data, and the corresponding first read status is set to a successful state when the read is successful; if the first status data is in an idle state or the flag value of the data read permission flag is a prohibited flag value, the corresponding first read status is set to a failed state, and the corresponding first read data is set to empty. The obtained first read status and the first read data are used as the output of the application layer data read processing result for this time.
5. The processing method of the storage data interface module according to claim 2, characterized in that, The step of generating a corresponding first modified state by performing application-layer data modification processing based on the first instruction body, the first index table file, and the first storage file specifically includes: The first storage data interface module extracts the corresponding first modified data handle and the first application modified data from the first instruction body; The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first modified data handle in the first index table is extracted as the corresponding current index record. When the current index record is empty, the corresponding first modification status is set to a failure status; When the current index record is not empty, the offset of the first application data block in the current index record is extracted as the corresponding current offset; and the first storage data block in the first storage file whose starting data storage position matches the current offset is taken as the corresponding current storage data block; and the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data modification permission flag of the first status data and the first permission data is identified; if the first status data is in the usage state and the flag value of the data modification permission flag is an allowed flag value, then the first file processing interface is called to update the first application storage data in the current storage data block to the corresponding first application modified data, and the corresponding first modification status is set to the success state when the update is successful; if the first status data is in the idle state or the flag value of the data modification permission flag is a prohibited flag value, then the corresponding first modification status is set to the failure state. The obtained first modified state is output as the result of this application layer data modification process.
6. The processing method of the storage data interface module according to claim 2, characterized in that, The step of generating a corresponding first deletion status by performing application-layer data deletion processing based on the first instruction body, the first index table file, and the first storage file specifically includes: The first storage data interface module extracts the corresponding first deletion data handle from the first instruction body; The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first deleted data handle in the first index table is extracted as the corresponding current index record. When the current index record is empty, the corresponding first deletion status is set to a failure status; When the current index record is not empty, the offset of the first application data block of the current index record is extracted as the corresponding current offset; and the first storage data block in the first storage file whose starting data storage position matches the current offset is taken as the corresponding current storage data block; and the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data deletion permission flag of the first status data and the first permission data is identified; if the first status data is in use and the flag value of the data deletion permission flag is an allowed flag value, then the first file processing interface is called to update the first status data of the current storage data block to an idle state, and the first file processing interface is called to decrement the count value of the first counter of the first index table file by 1, and after the first status data and the first counter are successfully updated, the corresponding first deletion state is set to a successful state; if the first status data is in an idle state or the flag value of the data deletion permission flag is a prohibited flag value, then the corresponding first deletion state is set to a failed state. The obtained first deletion status is output as the result of this application layer data deletion process.
7. The processing method of the storage data interface module according to claim 2, characterized in that, The step of generating a corresponding first recovery status and first recovery data by performing application-layer data recovery processing based on the first instruction body, the first index table file, and the first storage file specifically includes: The first storage data interface module extracts the corresponding first recovery data handle from the first instruction body; The first file processing interface is called to query the first index table of the first index table file, and the first index record that matches the first application layer data handle and the first recovery data handle in the first index table is extracted as the corresponding current index record. When the current index record is empty, the corresponding first recovery status is set to failure status, and the corresponding first recovery data is set to empty; When the current index record is not empty, the offset of the first application data block of the current index record is extracted as the corresponding current offset; the first storage data block whose starting data storage position in the first storage file matches the current offset is taken as the corresponding current storage data block; the first file processing interface is called to read the corresponding first status data and first permission data from the current storage data block; and the data recovery permission flag of the first status data and the first permission data is identified; if the first status data is in an idle state and the flag value of the data recovery permission flag is an allowed flag value, the first file processing interface is called to update the first status data of the current storage data block to a used state, and the first application storage data of the current storage data block is read as the corresponding first recovery data, and the first file processing interface is called to increment the count value of the first counter of the first index table file by 1, and after the first status data and the first counter are successfully updated, the corresponding first recovery status is set to a successful state; if the first status data is in an idle state or the flag value of the data recovery permission flag is a prohibited flag value, the corresponding first recovery status is set to a failed state, and the corresponding first recovery data is set to empty. The obtained first recovery status and the first recovery data are used as the output of the application layer data recovery process.
8. An electronic device, characterized in that, include: Memory, processor, and transceiver; The processor is configured to be coupled to the memory, read and execute instructions in the memory to implement the method according to any one of claims 1-7; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the method described in any one of claims 1-7.
Citation Information
Patent Citations
Data file storage method and device
CN111400258A
Intelligent unified storage system based on software definition
CN111897486A