File retrieval method and device, electronic equipment and storage medium

By inserting index files into the CPIO data format, recording the directory and its offsets, and quickly locate and retrieve the target files, the problem of inefficient retrieval of file based on the CPIO format is solved, and efficient file retrieval is achieved.

CN119166593APending Publication Date: 2024-12-20CHINA TELECOM NETWORK SECURITY TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411188536.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

When searching files based on CPIO data format, file retrieval efficiency is low, and data segments need to be read in turn to match the target file, resulting in large consumption of time and computing resources.

Method used

Insert index files in the CPIO data format, record the associated directories and their offsets under each directory, quickly locate the target directory through the index file and search the target file from the location of the data segment to avoid reading all data segments in sequence.

Benefits of technology

It significantly improves the efficiency of file retrieval, saves time and computing resource consumption, ensures the query and retrieval efficiency of the file system, and maintains the compatibility of CPIO data format.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166593A_ABST
    Figure CN119166593A_ABST
Patent Text Reader

Abstract

The invention discloses a file retrieval method and device, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps that firstly, when a retrieval instruction of a target file is received, a target index file associated with the target file is determined in a CPIO data format, the target index file comprises offset of N associated directories under a current directory, then a target directory to which the target file belongs is determined in the N associated directories, and the target directory is stored in the CPIO data format; and according to the target offset of the target directory, skipping to the data segment position of the target directory in the CPIO data format, and starting to retrieve the target file from the data segment position, so that the file retrieval efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a file retrieval method, device, electronic device and storage medium. Background Art

[0002] The CoPy In and Out (CPIO) data format is a standard format for archiving and backing up files. It uses a byte-based container to store files and directories as a continuous sequence of bytes, for example, multiple data segments are concatenated, and each data segment consists of a file header, a file name, and a file body, which includes specific files or directories. In addition, it also supports the retention of file permissions, timestamps, owners, groups, and other metadata to ensure the integrity and recoverability of files, and is widely used in actual scenarios.

[0003] At present, when performing file retrieval based on the CPIO data format, each data segment in the CPIO data format is sequentially read until the target file is found. However, this method of sequentially reading data segments for file retrieval has the problem of low file retrieval efficiency. Summary of the invention

[0004] The present application provides a file retrieval method, device, electronic device and storage medium to improve the efficiency of file retrieval.

[0005] In a first aspect, a file retrieval method is provided, comprising:

[0006] When a search instruction for a target file is received, a target index file associated with the target file is determined in the CPIO data format; wherein the target index file includes offsets of N associated directories under the current directory, where N is an integer greater than 1;

[0007] The target directory to which the target file belongs is determined in the N associated directories, and according to the target offset of the target directory, the data segment position of the target directory in the CPIO data format is jumped to, and the target file is retrieved from the data segment position.

[0008] In an embodiment of the present application, first, when a retrieval instruction for a target file is received, a target index file associated with the target file is determined in the CPIO data format, the target index file including the offsets of N associated directories under the current directory, and then the target directory to which the target file belongs is determined in the N associated directories, and according to the target offset of the target directory, a jump is made to the data segment position of the target directory in the CPIO data format, and the target file is retrieved from the data segment position; compared with the prior art, an embodiment of the present application utilizes an index file inserted in the CPIO data format to record the associated directories under each directory and the offset of the associated directory relative to the current directory, so that the specified directory to be retrieved can be located more quickly and specific files in the directory can be quickly accessed, without having to read all files in the data segment in sequence to match and retrieve the target file, thereby greatly saving time and computing resource consumption and improving the efficiency of file retrieval.

[0009] In some embodiments, when receiving a retrieval instruction for a target file, before determining a target index file associated with the target file in the CPIO data format, the method further includes:

[0010] Recursively traverse all directories contained in the M data segments in the CPIO data format, and create index files in order for the data segments where all the directories are located; wherein the index files of all the directories are used to indicate the data segment positions of the data segments where the respective associated directories are located, and M is an integer greater than 1.

[0011] In some embodiments, determining the target index file associated with the target file in the CPIO data format includes:

[0012] Read the index files of all the directories in sequence;

[0013] According to the file information of the target file, a target index file associated with the target file is determined in the CPIO data format; wherein the file information of the target file includes at least one of the file name, file attribute, and file format of the target file.

[0014] Through the above method, in the CPIO format data, the index file of each directory is inserted in the form of a standard CPIO data segment, and the offset of the associated directory can be stored in the index file of each directory, so that the specific data segment position can be directly located during subsequent file retrieval. Through this hierarchical and sequentially constructed indexing method, the entire file system structure is clear, thereby improving the efficiency of subsequent query and retrieval. In addition, the use of standard CPIO data segments to insert index files does not affect the compatibility of the CPIO data format.

[0015] In some embodiments, determining the target directory to which the target file belongs in the N associated directories includes:

[0016] Match the file name of the target file with the directory names of the N associated directories respectively;

[0017] If the directory name of the first associated directory among the N associated directories matches the file name, the first associated directory is determined as the target directory to which the target file belongs.

[0018] In some embodiments, the method further comprises:

[0019] If the directory names of the N associated directories do not match the file name, a first search failure message is generated; wherein the first search failure message at least includes the directory names of the N associated directories and the file name of the target file.

[0020] In some embodiments, after retrieving the target file from the data segment location, the method further includes:

[0021] If the target file is not found in the next data segment position of the data segment position, a second search failure message is generated; wherein the second search failure message at least includes the reason for the search failure and the file name of the target file.

[0022] In a second aspect, a file retrieval device is provided, comprising:

[0023] A determination module, configured to determine, in a CPIO data format, a target index file associated with the target file when a search instruction for the target file is received; wherein the target index file includes offsets of N associated directories under the current directory, where N is an integer greater than 1;

[0024] A retrieval module is used to determine the target directory to which the target file belongs in the N associated directories, and jump to the data segment position of the target directory in the CPIO data format according to the target offset of the target directory, and retrieve the target file from the data segment position.

[0025] In some embodiments, the apparatus further comprises an index building module;

[0026] The index building module is used to recursively traverse all directories contained in the M data segments in the CPIO data format, and create index files in order for the data segments where all the directories are located; wherein the index files of all the directories are used to indicate the data segment positions of the data segments where the respective associated directories are located, and M is an integer greater than 1.

[0027] According to a third aspect, an electronic device is provided, including:

[0028] A memory for storing a computer program; a processor for implementing any one of the methods described in the first aspect when executing the computer program stored in the memory.

[0029] According to a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of the first aspects is implemented.

[0030] For each aspect from the second to the fourth aspect and the technical effects that may be achieved by each aspect, please refer to the above description of the technical effects that can be achieved by the first aspect or various possible schemes in the first aspect, and no further details will be given here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A flowchart of a file retrieval method improved by an embodiment of the present application;

[0032] Figure 2 An example diagram of an index file provided in an embodiment of the present application;

[0033] Figure 3 A logical schematic diagram of creating an index file for a directory in a CPIO data format provided by an embodiment of the present application;

[0034] Figure 4 A flowchart of a complete file retrieval method provided in an embodiment of the present application;

[0035] Figure 5 A schematic diagram of the structure of a file retrieval device provided in an embodiment of the present application;

[0036] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0038] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0039] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0040] Figure 1 This is a flowchart of a file retrieval method provided in an embodiment of the present application. The process can be executed by a file retrieval device, which is implemented by software and / or hardware. Figure 1 As shown, the process includes the following steps:

[0041] 101: When a search instruction for a target file is received, a target index file associated with the target file is determined in a CPIO data format.

[0042] In some embodiments, when a retrieval instruction for a target file is received, before determining a target index file associated with the target file in the CPIO data format, corresponding index files may be created in advance for all directories included in the CPIO data format, so as to provide a basis for subsequent rapid file retrieval; specifically, the following process may be included:

[0043] Recursively traverse all directories contained in the M data segments in the CPIO data format, and create index files in order for the data segments where all directories are located; wherein the index files of all directories are used to indicate the data segment positions of the data segments where the respective associated directories are located, and M is an integer greater than 1.

[0044] For example, taking the first data segment of the M data segments (also called the data segment where the root directory is located) as an example, the directory of the data segment contains two associated directories. At this time, the directory names of the two associated directories (for example, associated directory a and associated directory b, or subdirectory a and subdirectory b) can be added to the index file to be inserted into the first data segment, and the offsets of the associated directories a and b are reserved respectively (for example, a|000000000000#b|000000000000#; wherein 000000000000 is the reserved offset);

[0045] Then, the index file of the first data segment can be generated by sorting and recursively packaging in the order of "directory, index file, file under the directory, and associated directory under the directory". Furthermore, since the root directory does not need a "directory" segment, the first data segment should be the index file of the root directory; Figure 2 As shown, it may include an index file (.index), file 1...file n, a regular file, an associated directory a, each file of the associated directory a, an associated directory b, and each file of the associated directory b;

[0046] Then continue to read subsequent data segments in sequence. When the data segment where the above-mentioned associated directory is located is read, the offset of the associated directory in the index file 1 is updated in time; for example, the root directory contains associated directory a and associated directory b, then the updated index file 1 is: a|0000002f123b#b|0000002f193b#; among which 0000002f123b and 0000002f193b are the updated offsets.

[0047] It should be noted that, since the offset position has been reserved in advance when creating an index for each directory, updating the index file only involves updating the offset part, which will not increase the length of the index file and will not affect the compatibility of the CPIO data format.

[0048] Figure 3 A logical diagram of creating an index file for a directory in a CPIO data format is provided in an embodiment of the present application. First, recursively traverse the directory to be packaged (such as Figure 3 As shown in 301, it includes directory a, directory c, and directory b; wherein directory c is the associated directory of directory a; then, in each directory traversed, an index file is created. If a corresponding associated directory exists in the current directory, the directory name of the associated directory of the current directory is written in a specific format in the index file, and the offset of the associated directory is reserved, such as Figure 3As shown in 302, the content of .index is: a|000000000000#b|000000000000#; the content of a / .index is: a / c|000000000000#; the content of a / c / .index is empty; the content of b / .index is empty; finally, the standard packaging command (for example, cat .. / files|cpio-H newc-o>.. / cpio1.test) can be used to sort and recursively package in the order of "directory, index file, files under the directory, and associated directories under the directory", so as to generate the following: Figure 3 The index files of all directories shown in 303 in the figure record the file header, file name, file body of the data segment, and the directory name and offset of the associated directory under the current directory; specifically, the associated directories contained in the index file (.index) are a and b, and their corresponding offsets are offset_a and offset_b respectively; the associated directories contained in the index file (a / .index) are a / c, and their corresponding offset is offset_c; the associated directories contained in the index file (a / c.index) are empty, and the associated directories contained in the index file (b / .index) are also empty.

[0049] Through the above method, in the CPIO format data, the index file of each directory is inserted in the form of a standard CPIO data segment, and the offset of the associated directory can be stored in the index file of each directory, so that the specific data segment position can be directly located during subsequent file retrieval. Through this hierarchical and sequentially constructed indexing method, the entire file system structure is clear, thereby improving the efficiency of subsequent query and retrieval. In addition, the use of standard CPIO data segments to insert index files does not affect the compatibility of the CPIO data format.

[0050] In some embodiments, determining a target index file associated with a target file in a CPIO data format may specifically include: reading index files of all directories in sequence; determining a target index file associated with a target file in a CPIO data format based on file information of the target file; wherein the file information of the target file includes at least one of the file name, file attributes, and file format of the target file.

[0051] For example, by reading the index files of each directory one by one (starting from the head, such as ".index" and then "a / .index") according to the storage structure of the CPIO data format, according to any one or more of the metadata of the target file, such as the file name, file attributes, file format, etc., and the content recorded in the index file (such as Figure 3 If similar content is matched, it indicates that it is a target index file associated with the target file.

[0052] 102: Determine the target directory to which the target file belongs in the N associated directories, and jump to the data segment position of the target directory in the CPIO data format according to the target offset of the target directory, and start retrieving the target file from the data segment position.

[0053] In some embodiments, determining the target directory to which the target file belongs in the above-mentioned N associated directories can be: matching the file name of the target file with the directory names of the N associated directories respectively; if the directory name of the first associated directory among the N associated directories matches the file name, then determining the first associated directory as the target directory to which the target file belongs.

[0054] For example, the above Figure 3 For example, assuming that the target file is named a / c / z, a similarity comparison is performed with the directory name (e.g. a / c) contained in the index file. If the similarity threshold is met, a / c is used as the target directory to which the target file belongs; or a character comparison is performed. If the character requirement is met, a / c is used as the target directory to which the target file belongs.

[0055] In other embodiments, if the directory names of the N associated directories do not match the file name, a first retrieval failure message is generated; wherein the first retrieval failure message includes at least the directory names of the N associated directories and the file name of the target file, thereby facilitating manual troubleshooting by the user to find the cause of the retrieval failure.

[0056] In other embodiments, if the directory names of N associated directories do not match the file name, an iterative method can be used to jump to the data segment location of the index file of each associated directory in turn to determine whether the index file of each associated directory also records the associated directory associated with itself. If so, the file name and directory name are compared in turn until all index files of the directories are traversed and no matching directory name is found, and a first retrieval failure message is generated.

[0057] It should be noted that the first search failure message can be notified to the user through text, dialog boxes, windows, etc. The specific expression content is similar to "The target file a / c / z is not matched in the associated directories a, b, a / c", so as to provide intuitive information feedback to the user, and can also be recorded as an internal log entry to provide data support for future search process optimization and troubleshooting.

[0058] In other embodiments, after retrieving the target file starting from the data segment position, if the target file is not retrieved in the next data segment position of the data segment position, a second retrieval failure message is generated; wherein the second retrieval failure message includes at least the reason for the retrieval failure and the file name of the target file, to facilitate manual troubleshooting by the user.

[0059] Furthermore, if the target file is not retrieved in the next data segment position of the data segment position, it is also possible to determine, based on the index file of the current target directory, whether it is other directories recorded in the index file. If so, a prompt message will pop up to indicate a message that the target directory is incorrectly located, and the directory names of other directories will be provided to facilitate manual troubleshooting by users.

[0060] In an embodiment of the present application, first, when a retrieval instruction for a target file is received, a target index file associated with the target file is determined in the CPIO data format, the target index file including the offsets of N associated directories under the current directory, and then the target directory to which the target file belongs is determined in the N associated directories, and according to the target offset of the target directory, a jump is made to the data segment position of the target directory in the CPIO data format, and the target file is retrieved from the data segment position; compared with the prior art, an embodiment of the present application utilizes an index file inserted in the CPIO data format to record the associated directories under each directory and the offset of the associated directory relative to the current directory, so that the specified directory to be retrieved can be located more quickly and specific files in the directory can be quickly accessed, without having to read all files in the data segment in sequence to match and retrieve the target file, thereby greatly saving time and computing resource consumption and improving the efficiency of file retrieval.

[0061] Based on the above Figure 1 The file retrieval method shown, and the above Figure 3 The index file shown, Figure 4 A complete file search flowchart provided in the embodiment of the present application. Assume that the target file to be searched is a / c / z. Figure 4 As shown, the process includes the following steps:

[0062] 401: When a search instruction for a target file is received, the .index index file inserted into the first data segment in the CPIO data format is read.

[0063] 402: Determine whether the target file is in the current directory; if so, go to 407; if not, go to 403.

[0064] 403: Match a / c / z in the target file with a and b in the index file .index. When a is matched, jump to the data segment where offset_a is located based on the offset of a.

[0065] 404: Read the index file a / .index inserted into the current data segment, and determine whether the target file is in the current directory a; if so, go to 407; if not, go to 405.

[0066] 405: Match a / c / z of the target file with a / c contained in the index file a / .index. If the match is successful, jump to the data segment where offset_c is located according to the offset offset_c of a / c.

[0067] 406: Read the index file a / c / .index inserted into the current data segment, and when it is determined that the target file is in the current directory a / c, retrieve the target file a / c / z in the next data segment of the data segment.

[0068] In other embodiments, if the retrieval target file is a / c / mm, when the next data segment located in the a / c / .index segment cannot match a / c / mm, it will read directory b sequentially and return a retrieval failure message.

[0069] 407: Retrieve the target file in the next data segment located in the current directory.

[0070] Based on the same technical concept, a file retrieval device is also provided in an embodiment of the present application, and the device can implement the above-mentioned file retrieval method process in the embodiment of the present application.

[0071] Figure 5 The schematic diagram of the structure of a file search device provided in an embodiment of the present application includes a determination module 501 and a search module 502 ; and may further include an index construction module 503 .

[0072] The determination module 501 is used to determine the target index file associated with the target file in the CPIO data format when receiving a search instruction for the target file; wherein the target index file includes the offsets of N associated directories under the current directory, where N is an integer greater than 1;

[0073] The retrieval module 502 is used to determine the target directory to which the target file belongs in the N associated directories, and jump to the data segment position of the target directory in the CPIO data format according to the target offset of the target directory, and retrieve the target file from the data segment position.

[0074] The index building module 503 is used to recursively traverse all directories contained in the M data segments in the CPIO data format, and create index files in order for the data segments where all the directories are located; wherein the index files of all the directories are used to indicate the data segment positions of the data segments where the respective associated directories are located, and M is an integer greater than 1.

[0075] The determination module 501 is specifically used to read the index files of all the directories in sequence; determine the target index file associated with the target file in the CPIO data format according to the file information of the target file; wherein the file information of the target file includes at least one of the file name, file attribute, and file format of the target file.

[0076] The search module 502 is specifically used to match the file name of the target file with the directory names of the N associated directories respectively;

[0077] If the directory name of the first associated directory among the N associated directories matches the file name, the first associated directory is determined as the target directory to which the target file belongs.

[0078] The retrieval module 502 is also used to generate a first retrieval failure message if the directory names of the N associated directories do not match the file name; wherein the first retrieval failure message at least includes the directory names of the N associated directories and the file name of the target file.

[0079] The retrieval module 502 is also used to generate a second retrieval failure message if the target file is not retrieved in the next data segment position of the data segment position; wherein the second retrieval failure message at least includes the reason for the retrieval failure and the file name of the target file.

[0080] It should be noted here that the above-mentioned device provided in the embodiment of the present application can implement all the method steps in the above-mentioned method embodiment and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.

[0081] Based on the same technical concept, an electronic device is also provided in an embodiment of the present application, and the electronic device can realize the functions of the aforementioned file retrieval device.

[0082] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0083] At least one processor 601, and a memory 602 connected to the at least one processor 601. The specific connection medium between the processor 601 and the memory 602 is not limited in the embodiment of the present application. Figure 6 In the example, the processor 601 and the memory 602 are connected via a bus 600. Figure 6 The connection between other components is shown by bold lines, and is not intended to be limiting. The bus 600 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 601 can also be called a controller, and there is no limitation on the name.

[0084] In the embodiment of the present application, the memory 602 stores instructions that can be executed by at least one processor 601. The at least one processor 601 can execute a file retrieval method discussed above by executing the instructions stored in the memory 602. The processor 601 can implement Figure 5 The functions of each module in the device shown.

[0085] Among them, the processor 601 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 602 and calling the data stored in the memory 602, the various functions of the device and processing data, the device can be monitored as a whole.

[0086] In the embodiment of the present application, the processor 601 may include one or more processing units, and the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 601. In some embodiments, the processor 601 and the memory 602 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.

[0087] Processor 601 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of a file retrieval method disclosed in the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.

[0088] The memory 602 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 602 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 602 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 602 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0089] By programming the processor 601, the code corresponding to the file retrieval method described in the above embodiment can be fixed into the chip, so that the chip can execute the code when running. Figure 1 The embodiment shown is a file retrieval method. How to design and program the processor 601 is a technique known to those skilled in the art and will not be described in detail here.

[0090] It should be noted here that the above-mentioned electronic device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.

[0091] Based on the same technical concept, the embodiment of the present application provides a computer storage medium, the computer storage medium includes: computer program code, when the computer program code is run on a computer, the computer executes any of the file retrieval methods discussed above. Since the principle of solving the problem by the above-mentioned computer storage medium is similar to that of a file retrieval method, the implementation of the above-mentioned computer storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.

[0092] In the specific implementation process, the computer storage medium may include: Universal Serial Bus Flash Drive (USB), mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and other storage media that can store program codes.

[0093] Based on the same technical concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the file retrieval methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of a file retrieval method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.

[0094] The computer program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more conductors, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0095] The method in the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the present application is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, a core network device, an OAM or other programmable device.

[0096] The computer program or instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0097] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0098] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the instructions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0099] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0100] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A file retrieval method, characterized in that: include: When a search instruction for a target file is received, a target index file associated with the target file is determined in the CPIO data format; wherein the target index file includes offsets of N associated directories under the current directory, where N is an integer greater than 1; The target directory to which the target file belongs is determined in the N associated directories, and according to the target offset of the target directory, the data segment position of the target directory in the CPIO data format is jumped to, and the target file is retrieved from the data segment position.

2. The method according to claim 1, characterized in that When receiving a retrieval instruction for a target file, before determining a target index file associated with the target file in the CPIO data format, the method further includes: Recursively traverse all directories contained in the M data segments in the CPIO data format, and create index files in order for the data segments where all the directories are located; wherein the index files of all the directories are used to indicate the data segment positions of the data segments where the respective associated directories are located, and M is an integer greater than 1.

3. The method according to claim 2, characterized in that The determining of the target index file associated with the target file in the CPIO data format comprises: Read the index files of all the directories in sequence; According to the file information of the target file, a target index file associated with the target file is determined in the CPIO data format; wherein the file information of the target file includes at least one of the file name, file attribute, and file format of the target file.

4. The method according to claim 2, characterized in that Determining the target directory to which the target file belongs in the N associated directories includes: Match the file name of the target file with the directory names of the N associated directories respectively; If the directory name of the first associated directory among the N associated directories matches the file name, the first associated directory is determined as the target directory to which the target file belongs.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: If the directory names of the N associated directories do not match the file name, a first search failure message is generated; wherein the first search failure message at least includes the directory names of the N associated directories and the file name of the target file.

6. The method according to any one of claims 1 to 4, characterized in that: After retrieving the target file from the data segment position, the method further includes: If the target file is not found in the next data segment position of the data segment position, a second search failure message is generated; wherein the second search failure message at least includes the reason for the search failure and the file name of the target file.

7. A file retrieval device, characterized in that: include: A determination module, configured to determine, in a CPIO data format, a target index file associated with the target file when a search instruction for the target file is received; wherein the target index file includes offsets of N associated directories under the current directory, where N is an integer greater than 1; A retrieval module is used to determine the target directory to which the target file belongs in the N associated directories, and jump to the data segment position of the target directory in the CPIO data format according to the target offset of the target directory, and retrieve the target file from the data segment position.

8. The device according to claim 7, characterized in that The device also includes an index building module; The index building module is used to recursively traverse all directories contained in the M data segments in the CPIO data format, and create index files in order for the data segments where all the directories are located; wherein the index files of all the directories are used to indicate the data segment positions of the data segments where the respective associated directories are located, and M is an integer greater than 1.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method according to any one of claims 1 to 6 when executing a computer program stored in the memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • File processing method and device in embedded system, equipment and storage medium

    CN121411802A