Methods and apparatus for determining partition access methods, storage media and electronic devices
By obtaining and constructing the target table during the kernel initialization phase of the embedded system, the partition access method is determined, which solves the problem of inconsistent handling of bad blocks by the Linux kernel for different file system types, and achieves stronger versatility and stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2023-05-31
- Publication Date
- 2026-06-30
AI Technical Summary
In the existing technology, the Linux kernel of embedded systems lacks a unified solution for handling bad blocks of different file system types, resulting in inconsistent processing, which can easily introduce problems, especially when the file system type changes.
During the system kernel initialization phase, the system partition initialization program obtains the file system type corresponding to each partition in the target storage medium, determines the partition access method based on whether it has the ability to handle damaged storage blocks, and constructs a target table to handle partitions that do not have this ability, ensuring that the file system only accesses undamaged storage blocks.
It achieves unified handling of bad blocks under different file system types, improves the versatility of the system kernel on storage media, reduces the error rate when switching file systems, and ensures the stability of data access.
Smart Images

Figure CN116627340B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communications, and more specifically, to a method and apparatus for determining a partition access mode, a storage medium, and an electronic device. Background Technology
[0002] For embedded systems, the file system is primarily used to manage and store data and programs. Currently, embedded Linux operating systems support many file systems, with commonly used NAND flash-based file systems including Squashfs, cramfs, ubifs, jiffs2, and yaffs. The specific file system used depends on factors such as the storage medium, access speed, and storage capacity.
[0003] Currently, various file types can be used with NAND flash. However, due to the physical characteristic of NAND flash having bad blocks, each file system type handles bad blocks differently. For example, SquashFS and CramFS file systems do not inherently handle bad blocks, while UBI and Yaffs file systems do. The Linux kernel does not have a unified solution for handling bad blocks across different file systems. There are currently two main approaches: one is to determine the file system type by reading the superblock data of the partition containing the flash file system, thus determining whether bad block handling is necessary. The other is to directly determine whether bad block handling is needed based on the partition name (because usually, once a partition is partitioned, its corresponding file system type is largely determined). However, both approaches have drawbacks: the first approach cannot identify the file system type of all partitions. For example, some UBI partitions do not initially have a file system image; they are only formatted as UBI when the file system is mounted. Some partitions encrypt data for security reasons, making it impossible to identify the file system type by directly reading the data. The second approach, which distinguishes file system types based on partition names, has the major problem that if the partition's file system type changes, improper bad block handling can easily introduce problems.
[0004] Regarding the related technologies, there is currently no effective solution to the problem of inconsistent handling of bad blocks by the system kernel on storage media for different file system types.
[0005] Therefore, it is necessary to improve the relevant technology to overcome the aforementioned defects. Summary of the Invention
[0006] This invention provides a method and apparatus for determining partition access methods, a storage medium, and an electronic device, to at least solve the problem of inconsistent bad block handling by the system kernel for different file system types on the storage medium.
[0007] According to one aspect of the present invention, a method for determining a partition access mode is provided, comprising: during the system kernel initialization phase, obtaining the file system type corresponding to each partition in a target storage medium from partition parameters through a system partition initialization program, wherein the partition parameters are parameters used to partition the target storage medium; determining whether the file system corresponding to each partition has a target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks; and determining the partition access mode of each partition based on whether the file system corresponding to each partition has the target capability.
[0008] In an exemplary embodiment, determining the partition access method of each partition based on whether the file system corresponding to each partition has the target capability includes: if the first file system corresponding to the first partition has the target capability, determining the partition access method of the first file system as the partition access method of the first partition; if the second file system corresponding to the second partition does not have the target capability, constructing a target table for the second partition, and determining the partition access method of the second partition based on the target table, wherein the target table records the target storage block in the second partition, and the target storage block is a non-damaged storage block.
[0009] In an exemplary embodiment, constructing the target table of the second partition includes: determining each target storage block in the second partition and the physical address of each target storage block in the second partition; allocating a logical address to each target storage block, and constructing a correspondence between the logical address and the physical address of each target storage block in the second partition, wherein the target table also records the correspondence between the logical address and the physical address of each target storage block.
[0010] In an exemplary embodiment, determining the partition access mode of the second partition according to the target table includes: determining the way the second file system accesses the second partition according to the target table as the partition access mode of the second partition; wherein, the second file system accessing the second partition according to the target table includes: the second file system only accessing the target storage blocks recorded in the target table.
[0011] In an exemplary embodiment, after obtaining the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program, the method further includes: writing the file system type corresponding to each partition into a partition information file, wherein the partition information file is used to store the partition information of the target storage medium.
[0012] In an exemplary embodiment, after determining the partition access method of each partition based on whether the file system corresponding to each partition has the target capability, the method further includes: parsing the partition information file through a system partition mounting script to determine the file system type and the corresponding partition device of each partition; and mounting each partition device according to the corresponding file system type.
[0013] In an exemplary embodiment, mounting each partition device according to the corresponding file system type includes: determining the mount parameters of the file system corresponding to each partition based on the file system type of each partition; and mounting the file system of the partition device corresponding to each partition according to the mount parameters of the file system corresponding to each partition.
[0014] In an exemplary embodiment, before obtaining the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program, the method further includes: configuring the partition parameters through the system kernel boot program during the system kernel boot phase, wherein the partition parameters include at least the file system type corresponding to each partition.
[0015] According to another aspect of the present invention, a device for determining a partition access mode is also provided, comprising: an acquisition module, configured to, during the system kernel initialization phase, acquire, from partition parameters a file system type corresponding to each partition in a target storage medium via a system partition initialization program, wherein the partition parameters are parameters used to partition the target storage medium; a first determination module, configured to determine whether the file system corresponding to each partition possesses a target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks; and a second determination module, configured to determine the partition access mode of each partition based on whether the file system corresponding to each partition possesses the target capability.
[0016] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, wherein the computer program is configured to execute the above-described partition access method determination method at runtime.
[0017] According to another aspect of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for determining the partition access mode through the computer program.
[0018] Through this invention, during the system kernel initialization phase, the system partition initialization program can obtain the file system type corresponding to each partition in the target storage medium from the partition parameters. Then, based on the file system type of each partition, it can determine whether the file system corresponding to each partition has the target capability (the target capability includes the ability to handle damaged storage blocks). Furthermore, based on whether the file system corresponding to each partition has the target capability, it can determine the partition access method for each partition. By using the determined partition access method, the system kernel can perform differentiated processing of bad blocks for different file systems on the target storage medium. This makes the system kernel more universal in handling bad blocks using different file systems on the target storage medium, and solves the problem of the system kernel's lack of universality in handling bad blocks for different file system types on the storage medium. Attached Figure Description
[0019] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with the description thereof, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0020] Figure 1 This is a hardware structure block diagram of a computer terminal for a method of determining partition access mode according to an embodiment of the present invention.
[0021] Figure 2 This is a flowchart (a) of a method for determining the partition access mode according to an embodiment of the present invention;
[0022] Figure 3 This is a flowchart (II) of a method for determining the partition access mode according to an embodiment of the present invention;
[0023] Figure 4 This is a structural block diagram of a device for determining a partition access method according to an embodiment of the present invention. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] The methods and embodiments provided in this application can be executed on a computer terminal or similar computing device. Taking running on a computer terminal as an example, Figure 1 This is a hardware structure block diagram of a computer terminal for a method of determining partition access mode according to an embodiment of the present invention. For example... Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor unit (MPU) or a programmable logic device (PLD)) and a memory 104 for storing data are also shown. In one exemplary embodiment, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 Equivalent functions or ratios shown Figure 1 The functions shown have more different configurations.
[0027] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the partition access mode determination method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0028] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0029] Specifically, this embodiment provides a method for determining partition access methods, including but not limited to the Linux system applied to the aforementioned computer terminal. Figure 2 This is a flowchart (I) of a method for determining a partition access mode according to an embodiment of the present invention, which includes the following steps:
[0030] Step S202: During the system kernel initialization phase, the file system type corresponding to each partition in the target storage medium is obtained from the partition parameters through the system partition initialization program, wherein the partition parameters are parameters used to partition the target storage medium;
[0031] As an optional example, the system partition initializer is the Linux partition initializer, and the target storage medium is NAND flash. The file system type for each partition is specified.
[0032] In an exemplary embodiment, before performing step S202 above, the method further includes: configuring partition parameters through the system kernel boot program during the system kernel boot phase, wherein the partition parameters include at least the file system type corresponding to each partition.
[0033] As an optional example, the system kernel bootloader is the Linux kernel bootloader, and the system kernel is the Linux kernel. Partition parameters may also include: the partition name for each partition, the type of current storage medium (NAND flash or other flash), the storage size of each partition, etc.
[0034] Step S204: Determine whether the file system corresponding to each partition has the target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks;
[0035] It should be noted that the squashfs and cramfs file systems do not have the ability to handle corrupted storage blocks, while the ubi and yaffs file systems do.
[0036] Step S206: Determine the partition access method for each partition based on whether the file system corresponding to each partition has the target capability.
[0037] Through the above steps, during the system kernel initialization phase, the system partition initialization program can obtain the file system type corresponding to each partition in the target storage medium from the partition parameters. Then, based on the file system type of each partition, it can determine whether the file system corresponding to each partition has the target capabilities (target capabilities include the ability to handle damaged storage blocks). Furthermore, based on whether the file system corresponding to each partition has the target capabilities, it can determine the partition access method for each partition. By using the determined partition access method, the system kernel can perform differentiated processing of bad blocks for different file systems on the target storage medium. This makes the system kernel more universal in handling bad blocks using different file systems on the target storage medium, and solves the problem of the system kernel's incompatibility in handling bad blocks for different file system types on the storage medium.
[0038] In an exemplary embodiment, step S206 can be implemented by the following steps S11-S12:
[0039] Step S11: If the first file system corresponding to the first partition has the target capability, determine the partition access method of the first file system as the partition access method of the first partition.
[0040] It should be noted that for the primary file system, which inherently possesses bad block handling capabilities (bad blocks being the aforementioned damaged storage blocks), the original partition access method of the Linux kernel can be used directly, and additional bad block handling is typically not performed. This is because the bad block handling logic is already implemented at the file system level. If it is processed again during partition access, the presence of bad blocks could very likely cause data access anomalies at the file system level.
[0041] Step S12: If the second file system corresponding to the second partition does not have target capabilities, construct a target table for the second partition and determine the partition access method of the second partition according to the target table. The target table records the target storage blocks in the second partition, and the target storage blocks are undamaged storage blocks.
[0042] It should be noted that, in this embodiment of the application, the first file system refers to a file system capable of handling damaged storage blocks, and the second file system refers to a file system that does not have the capability to handle damaged storage blocks. Partitions in the target storage medium can be divided into two types of partitions, namely the first partition and the second partition, based on whether the file system corresponding to the partition possesses the target capability.
[0043] It should be noted that for a second file system without bad block handling logic, a good block table (i.e., the target table mentioned above) needs to be created for the partition first, and the file system layer's access method for the partition needs to be built based on the good block table.
[0044] In an exemplary embodiment, the construction of the target table for the second partition can be achieved through the following steps S21-S22:
[0045] Step S21: Determine each target storage block in the second partition and the physical address of each target storage block in the second partition;
[0046] Step S22: Assign a logical address to each target storage block, and construct a target table for the second partition using the logical and physical addresses of each target storage block in the second partition. The target table also records the correspondence between the logical and physical addresses of each target storage block.
[0047] In this embodiment, the target table constructed through the above steps S21-S22 contains the logical address and physical address of the target storage block, which makes it easier to determine the partition access method of the second partition based on the target table.
[0048] In an exemplary embodiment, determining the partition access method of the second partition according to the target table includes: determining the way the second file system accesses the second partition according to the target table as the partition access method of the second partition; wherein, the second file system accessing the second partition according to the target table includes: the second file system only accessing the target storage block recorded in the target table.
[0049] It should be noted that since the target table records only undamaged target storage blocks, even if there are bad blocks in the NAND flash, the second file system can still access normal file system data based on the target table if the second file system only accesses the target storage blocks recorded in the target table.
[0050] In an exemplary embodiment, after obtaining the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program, the method further includes step S31: writing the file system type corresponding to each partition into a partition information file, wherein the partition information file is used to store the partition information of the target storage medium.
[0051] In an exemplary embodiment, after determining the partition access method of each partition based on whether the file system corresponding to each partition has the target capability, the method further includes steps S32-S33:
[0052] Step S32: Parse the partition information file using the system partition mount script to determine the file system type and corresponding mount device for each partition;
[0053] Step S33: Mount each partition device according to the corresponding file system type.
[0054] In this embodiment, since step S31 has already recorded the partition and its corresponding file system type in the partition information file, the Linux partition mount script can parse this partition information file to find the file system type used by the partition. Therefore, it can perform differentiated mounting of different file systems based on their specific file system types. This avoids the need to modify the Linux kernel partition mount script in advance according to the file system type to be switched in existing technologies, thus reducing the error rate.
[0055] In an exemplary embodiment, step S33 above can be implemented as follows: determining the mount parameters of the file system corresponding to each partition according to the file system type corresponding to each partition; mounting each partition according to the corresponding file system according to the mount parameters of the file system corresponding to each partition.
[0056] It's important to note that different file system types require different mount parameters when mounting file devices. Therefore, it's necessary to determine the mount parameters for the partition's corresponding file system type based on those parameters, and then mount the partition according to the appropriate file system type. Here, "mounted device" refers to a storage device.
[0057] It should be noted that in Linux systems, the process of associating a file system with a storage device is called mounting.
[0058] Obviously, the embodiments described above are only some embodiments of the present invention, and not all embodiments. To better understand the method for determining the partition access method described above, the process is explained below with reference to embodiments, but this is not intended to limit the technical solutions of the embodiments of the present invention. Specifically:
[0059] Figure 3 This is a flowchart (II) of a method for determining the partition access mode according to an embodiment of the present invention, as shown below. Figure 3 As shown, the specific steps are as follows:
[0060] Step 102: Configure the Linux bootloader to partition and the corresponding file system type;
[0061] It should be noted that since Linux partitioning is usually configured and implemented in the Linux kernel bootloader, and the partition and the file system type used by the partition are closely related, you need to add the corresponding partition file system type field when configuring partition parameters in the Linux bootloader.
[0062] Step 103: During Linux initialization, the partitions and their corresponding file system types are parsed and written to the partition information file;
[0063] It should be noted that in the early stages of Linux kernel initialization, the configuration parameters (such as partition parameters) passed to the kernel by the Linux bootloader are parsed. Therefore, this embodiment of the application can use the parsing of partition parameters to resolve the partition file system type and write the determined file system type to the Linux kernel partition information file. The partition information file is mainly used to match the file system corresponding to the partition when mounting the partition file system.
[0064] Step 104: The Linux partition initialization program determines the file system type corresponding to the partition to see if it is a squashfs or cramfs file system. If it is, proceed to step 106; otherwise, proceed to step 105.
[0065] It's important to note that the Linux kernel needs to add a check for the file system type during partition initialization, primarily to handle bad blocks. Since each file system type handles bad blocks differently—some file systems lack built-in bad block handling (e.g., squashfs, cramfs), while others implement their own (e.g., UBI, yaffs)—the kernel needs to proceed to step 106 to handle bad blocks for file systems without this feature. For files with built-in bad block handling, the system executes step 105.
[0066] Step 105: Construct the original Linux kernel partition access method;
[0067] It's important to note that for file systems with built-in bad block handling, the original Linux kernel partition access methods can be used directly, typically without additional bad block processing. This is because the bad block handling logic is already implemented at the file system level. If it's processed again during partition access, the presence of bad blocks could very likely cause data access anomalies at the file system level.
[0068] Step 106: Create a block table for the partition (equivalent to the target table in the above embodiment), and construct a partition access method based on the block table;
[0069] It should be noted that for file systems like squashfs and cramfs that do not have bad block handling logic, a block table needs to be created for the partition first, and the file system layer's access method for the partition needs to be built based on the good block table. In this way, if there are bad blocks in the NAND flash, file systems like squashfs and cramfs can still access the normal file system data through this access method.
[0070] Step 107: The Linux partition mount script automatically parses the partition information file and completes the mounting of the file system for each partition;
[0071] It should be noted that since step 103 has already recorded the partition and its corresponding file system in the partition information file, the Linux partition mount script can parse the partition information file to find the file system type used by the partition, and thus complete the differentiated mounting of different file systems according to different file system types.
[0072] It should be noted that, compared to existing technologies, the technical solution of this application enables NAND flash to use different file system types. By configuring the corresponding file system type for each partition in the bootloader, and then retrieving the corresponding file system in the kernel based on the bootloader configuration, differentiated handling of bad blocks is achieved for different file systems. This makes the handling of bad blocks more universal for NAND flash using different file systems. It solves the problem of insufficient universality in bad block handling solutions when using NAND flash with different file system types.
[0073] Furthermore, existing technologies require fixing the partition mount command in the partition mount script when mounting a partition. This means that if the partition changes its file system, the partition mount script needs to be modified. In contrast, the script in this application automatically parses the partition information generated during partition initialization to determine the file system type used by the partition, thus completing the normal mounting of each partition's file system. This proposal solves the problem of existing technologies requiring synchronous modification of the partition mount script when adjusting the partition file system.
[0074] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.
[0075] This embodiment also provides a device for determining a partition access method. This device is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0076] Figure 4 This is a structural block diagram of a device for determining a partition access method according to an embodiment of the present invention. The device includes:
[0077] The acquisition module 42 is used to obtain the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program during the system kernel initialization phase. The partition parameters are parameters used to partition the target storage medium.
[0078] The first determining module 44 is used to determine whether the file system corresponding to each partition has the target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks;
[0079] The second determining module 46 is used to determine the partition access method of each partition based on whether the file system corresponding to each partition has the target capability.
[0080] With the above-mentioned device, during the system kernel initialization phase, the system partition initialization program can obtain the file system type corresponding to each partition in the target storage medium from the partition parameters. Then, based on the file system type of each partition, it can determine whether the file system corresponding to each partition has the target capability (the target capability includes the ability to handle damaged storage blocks). Then, based on whether the file system corresponding to each partition has the target capability, it can determine the partition access method of each partition. By using the determined partition access method, the system kernel can perform differentiated processing of bad blocks for different file systems. This makes the system kernel more universal in handling bad blocks using different file systems on the target storage medium, and solves the problem of the system kernel's incompatibility in handling bad blocks for different file system types on the storage medium.
[0081] In an exemplary embodiment, the second determining module 46 is further configured to, when the first file system corresponding to the first partition has target capabilities, determine the partition access mode of the first file system as the partition access mode of the first partition; when the second file system corresponding to the second partition does not have target capabilities, construct a target table for the second partition, and determine the partition access mode of the second partition according to the target table, wherein the target table records the target storage block in the second partition, and the target storage block is a storage block without damage.
[0082] In an exemplary embodiment, the second determining module 46 includes: a construction unit, configured to determine each target storage block in the second partition and the physical address of each target storage block in the second partition; allocate a logical address to each target storage block, and construct a target table of the second partition using the logical address and physical address of each target storage block in the second partition, wherein the target table also records the correspondence between the logical address and the physical address of each target storage block.
[0083] In an exemplary embodiment, the second determining module 46 includes: a determining unit, configured to determine the way the second file system accesses the second partition according to the target table as the partition access method of the second partition; wherein, the second file system accessing the second partition according to the target table includes: the second file system only accessing the target storage block recorded in the target table.
[0084] In an exemplary embodiment, the above-described apparatus further includes a writing module, configured to obtain the file system type corresponding to each partition in the target storage medium from the partition parameters through a system partition initialization program, and then write the file system type corresponding to each partition into a partition information file, wherein the partition information file is used to store the partition information of the target storage medium.
[0085] In an exemplary embodiment, the above apparatus further includes: a mounting module, configured to determine the partition access method of each partition based on whether the file system corresponding to each partition has the target capability, and then parse the partition information file through a system partition mounting script to determine the file system type and the corresponding partition device of each partition; and mount the file system of the partition device corresponding to each partition according to the file system type of each partition.
[0086] In an exemplary embodiment, the mounting module is further configured to determine the mounting parameters of the file system corresponding to each partition based on the file system type corresponding to each partition; and to mount the file system of the partition device corresponding to each partition based on the mounting parameters of the file system corresponding to each partition.
[0087] In an exemplary embodiment, the above apparatus further includes a configuration module, configured during the system kernel boot phase, before obtaining the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program, by configuring the partition parameters through the system kernel boot program, wherein the partition parameters include at least: the file system type corresponding to each partition.
[0088] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0089] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0090] S1, During the system kernel initialization phase, the file system type corresponding to each partition in the target storage medium is obtained from the partition parameters through the system partition initialization program, wherein the partition parameters are parameters used to partition the target storage medium;
[0091] S2, determine whether the file system corresponding to each partition has the target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks;
[0092] S3, determine the partition access method for each partition based on whether the file system corresponding to each partition has the target capability.
[0093] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0094] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0095] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0096] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0097] S1, During the system kernel initialization phase, the file system type corresponding to each partition in the target storage medium is obtained from the partition parameters through the system partition initialization program, wherein the partition parameters are parameters used to partition the target storage medium;
[0098] S2, determine whether the file system corresponding to each partition has the target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks;
[0099] S3, determine the partition access method for each partition based on whether the file system corresponding to each partition has the target capability.
[0100] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0101] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0102] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0103] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method of determining a partitioned access mode, characterized in that, include: During the system kernel initialization phase, the system partition initialization program obtains the file system type corresponding to each partition in the target storage medium from the partition parameters, wherein the partition parameters are parameters used to partition the target storage medium; Based on the file system type corresponding to each partition, determine whether the file system corresponding to each partition has the target capability, wherein the target capability includes the ability to handle damaged storage blocks; The partition access method for each partition is determined based on whether the file system corresponding to each partition has the target capability; The method of determining the partition access mode of each partition based on whether the file system corresponding to each partition has the target capability includes: if the first file system corresponding to the first partition has the target capability, determining the partition access mode of the first file system as the partition access mode of the first partition; if the second file system corresponding to the second partition does not have the target capability, constructing a target table for the second partition, and determining the partition access mode of the second partition based on the target table, wherein the target table records the target storage blocks in the second partition, and the target storage blocks are undamaged storage blocks.
2. The method of claim 1, wherein, Constructing the target table for the second partition includes: Determine each target storage block in the second partition and the physical address of each target storage block in the second partition; A logical address is assigned to each target storage block, and a target table for the second partition is constructed using the logical and physical addresses of each target storage block in the second partition. The target table also records the correspondence between the logical address and the physical address of each target storage block.
3. The method of claim 1, wherein, Determining the partition access method of the second partition based on the target table includes: The method by which the second file system accesses the second partition according to the target table is determined as the partition access method of the second partition; Wherein, the second file system accessing the second partition according to the target table includes: the second file system only accessing the target storage block recorded in the target table.
4. The method of claim 1, wherein, After obtaining the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program, the method further includes: Write the file system type corresponding to each partition into a partition information file, wherein the partition information file is used to store the partition information of the target storage medium.
5. The method of claim 4, wherein, After determining the partition access method for each partition based on whether the file system corresponding to each partition has the target capability, the method further includes: The system partition mount script parses the partition information file to determine the file system type and corresponding partition device for each partition. Mount each partition device according to the corresponding file system type.
6. The method of claim 1, wherein, Before obtaining the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization procedure, the method further includes: During the system kernel boot phase, the partition parameters are configured by the system kernel bootloader, wherein the partition parameters include at least the file system type corresponding to each partition.
7. A device for determining a partition access method, characterized in that, include: The acquisition module is used to obtain the file system type corresponding to each partition in the target storage medium from the partition parameters through the system partition initialization program during the system kernel initialization phase. The partition parameters are parameters used to partition the target storage medium. The first determining module is used to determine whether the file system corresponding to each partition has the target capability based on the file system type corresponding to each partition, wherein the target capability includes the ability to handle damaged storage blocks; The second determining module is used to determine the partition access method of each partition based on whether the file system corresponding to each partition has the target capability; The second determining module is further configured to, when the first file system corresponding to the first partition has target capabilities, determine the partition access method of the first file system as the partition access method of the first partition; when the second file system corresponding to the second partition does not have target capabilities, construct a target table for the second partition and determine the partition access method of the second partition according to the target table, wherein the target table records the target storage block in the second partition, and the target storage block is a storage block without damage.
8. A computer readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 6. 9.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 6 through the computer program.