File pre-distribution method and device, equipment and storage medium
By detecting and converting the file system format of the SD card and performing non-interactive partitioning and formatting in the Linux system, the problem of low pre-allocation of SD card files in the Linux system is solved, and rapid file creation and storage performance optimization is achieved .
Patent Information
- Application Number
- CN202411660511.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2024-12-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In Linux systems, the file system of the SD card does not support file pre-allocation through the fallocate function, resulting in the inability to quickly pre-allocation of files, affecting file access performance and the life of storage devices.
Provide a file pre-allocation method, detect the presence of a secure digital card in the target device and mount it, convert the file system format to the target file system format (such as EXT4), and then create partitions and format the file system in a non-interactive manner. , implement file pre-allocation.
It significantly improves file creation speed, optimizes storage performance, reduces disk fragmentation, extends the read and write life of SD cards, and improves the read and write efficiency of files.
Smart Images

Figure CN119149505A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of embedded systems, and in particular to a file pre-allocation method, device, equipment and storage medium. Background Art
[0002] In the field of digital storage, SD cards, as a portable storage device, are widely used in various electronic devices. Common file systems for SD cards include FAT32 and exFAT; among them, the FAT32 file system is widely used due to its wide compatibility and stability, while the exFAT file system is favored for its support for large-capacity storage devices. In the Linux operating system, the supported file systems mainly include ext4, FAT32 and NTFS, which can meet the needs of different users.
[0003] File pre-allocation technology is a method of pre-allocating disk space during the file creation phase. Its purpose is to reduce fragmentation caused by insufficient disk space during file writing, thereby improving file access performance. In addition, by storing specific data structures in pre-allocated files and directly overwriting these data structures in the pre-allocated files in a loop when the storage space is exhausted, frequent deletion of old files and creation of new files can be avoided, which not only helps to extend the read and write life of the SD card, but also protects the SD card from damage under abnormal circumstances.
[0004] However, for the Linux system's on-board recorder, although the FAT32 file system is used to mount the SD card, for large-capacity SD cards, it needs to be expanded to the exFAT file system to support mounting, and in the Linux system, file pre-allocation is usually achieved by calling the fallocate function. However, actual tests have found that the file system used by the SD card in the Linux system does not support pre-allocation through fallocate; specifically, when the fallocate function is called, the system cannot occupy disk space without writing content, which makes it impossible to quickly pre-allocate files. Summary of the invention
[0005] The present application provides a file pre-allocation method, device, equipment and storage medium, which can improve the file pre-allocation efficiency of a secure digital card.
[0006] In a first aspect, the present application provides a file pre-allocation method, comprising: when it is detected that a secure digital card is inserted into a target device, mounting the secure digital card, wherein the target device is an embedded device that supports the exFAT file system; detecting a first file system format of the secure digital card, and if the first file system format is not a target file system format, converting the first file system format to the target file system format; performing file pre-allocation processing on the secure digital card after the format conversion to obtain a pre-allocated file. In a possible implementation, converting the first file system format into the target file system format specifically includes: determining a mount point of the secure digital card, and based on the mount point, unmounting the secure digital card; creating a partition in a non-interactive manner to obtain a target partition, and formatting the file system format of the target partition into the target file system format; and re-mounting the secure digital card.
[0007] In a possible implementation, the partition creation is performed in a non-interactive manner to obtain a target partition, which specifically includes: creating a new DOS partition table; creating a first partition, and setting a corresponding classification type, partition number, start sector and end sector for the first partition; and writing the first partition into the DOS partition table, and using the first partition in the DOS partition table as the target partition.
[0008] In a possible implementation, after obtaining the target partition, the method further includes: detecting whether the secure digital card is mounted, and if so, forcibly uninstalling the secure digital card until it is detected that the secure digital card is not mounted.
[0009] In a possible implementation, formatting the file system format of the target partition into the target file system format specifically includes: creating a simulated user input combination instruction and a target file system creation instruction, setting a pipeline operation for the simulated user input combination instruction and the target file system creation instruction, and generating a file system format formatting instruction; based on the file system format formatting instruction, formatting the file system format of the target partition into the target file system format.
[0010] In a possible implementation, the re-mounting of the secure digital card specifically includes: creating a target mount point in a target file system and recording a target mount point directory; performing a mount status detection on the secure digital card, and when it is detected that the secure digital card is not mounted, generating mount instruction parameters according to the target file system format and the target mount point directory, and mounting the secure digital card based on the mount instruction parameters.
[0011] In a possible implementation, the file pre-allocation processing is performed on the secure digital card after format conversion to obtain pre-allocated files, which specifically includes: determining the number of pre-allocated files and the file size corresponding to each file; based on the file data and the file size, cyclically creating pre-allocated files for the secure digital card to obtain a pre-allocated file list, wherein the pre-allocated file list is composed of the pre-allocated files.
[0012] In a second aspect, the present application provides a file pre-allocation device, comprising: a secure digital card detection module, a file system format conversion module and a file pre-allocation module; wherein the secure digital card detection module is used to mount the secure digital card when it is detected that a secure digital card is inserted into a target device, wherein the target device is an embedded device that supports the exFAT file system; the file system format conversion module is used to detect a first file system format of the secure digital card, and if the first file system format is not a target file system format, convert the first file system format into the target file system format; the file pre-allocation module is used to perform file pre-allocation processing on the secure digital card after format conversion to obtain a pre-allocated file.
[0013] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.
[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0015] The present application provides a method, apparatus, device and storage medium for pre-allocating files, which have the following advantages over the prior art: When it is detected that a secure digital card is inserted into a target device, the secure digital card is mounted, wherein the target device is an embedded device supporting the exFAT file system; in the process, by setting the target device to support the exFAT file system, the method can adapt to secure digital cards of different capacities, including large-capacity secure digital cards, which improves the compatibility of the target device with the secure digital card; the first file system format of the secure digital card is detected, and if the first file system format is not the target file system format, the first file system format is converted to the target file system format; the secure digital card after the format conversion is pre-allocated to obtain a pre-allocated file; by formatting the file system of the secure digital card as the EXT4 file system and implementing file pre-allocation, the speed of file creation can be significantly improved, and file creation can be achieved in milliseconds, thereby optimizing storage performance, and file pre-allocation can reduce disk fragmentation, because the pre-allocated continuous space can avoid scattered storage of files when writing, which helps to improve the reading and writing efficiency of files. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0019] Figure 1 It is a flowchart of an embodiment of a file pre-allocation method provided by the present application; Figure 2 It is a structural schematic diagram of an embodiment of a file pre-allocation device provided by the present application; Figure 3 It is a structural schematic diagram of an electronic device provided by this application. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0021] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0022] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0023] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0024] It should be further understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0025] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context. Example 1, see Figure 1 , Figure 1 is a flowchart of an embodiment of a file pre-allocation method provided by the present application, such as Figure 1As shown, the method includes steps 101 to 103, which are specifically as follows: Step 101: When it is detected that a secure digital card is inserted into a target device, the secure digital card is mounted, wherein the target device is an embeddable device supporting the exFAT file system.
[0026] Preferably, the target device may be a vehicle-mounted recorder based on a Linux system.
[0027] In one embodiment, when it is detected that the exFAT file system is not extended in the target device, the exFAT file system is extended on the target device.
[0028] Specifically, since the Linux 5.4 kernel begins to natively support the exFAT file system, the Linux system kernel version in the target device is detected. If the kernel version meets the preset kernel version requirement, it is determined that the exFAT file system is extended in the target device. Otherwise, the exFAT support package is installed on the target device, and based on the exFAT support package, the exFAT file system is expanded on the target device.
[0029] Preferably, the preset kernel version requirement is that the kernel version is not less than 5.4.
[0030] In one embodiment, in a Linux system, udev or mdev can be used to monitor and respond to the insertion and removal events of a secure digital card. These tools can configure rules to automatically perform a mount operation when a secure digital card is detected to be inserted; for example, udev rules can be configured to execute a mount script when a new MMC device is detected.
[0031] Preferably, in the Linux system, the SD card can be detected by regularly executing the mmc_rescan operation. This operation will try to rescan the MMC / SD slot and mount the detected device. If a new device is detected, the system can automatically perform the mount operation.
[0032] In one embodiment, when the secure digital card is mounted, a mount point is created and a mount point directory is recorded; a mount status detection is performed on the secure digital card, and when it is detected that the secure digital card is not mounted, the secure digital card is mounted to the mount point directory.
[0033] Specifically, a mount point is a directory in the file system that is used as an entry point to access the mounted file system. Before mounting a secure digital card, you need to create a directory in the file system as a mount point; for example, create / mnt / sdcard as the mount point for the secure digital card. After creating the mount point, you need to record the path of this directory for use when mounting and accessing the secure digital card; before trying to mount the secure digital card, you need to check whether the secure digital card has been mounted. This can be done by viewing the / proc / mounts file or using the mount command. If it is detected that the secure digital card is not mounted, you can use the mount command to mount the secure digital card to the mount point directory created previously. This process ensures that the secure digital card has been correctly mounted before being accessed, and the mount point directory is recorded for subsequent operations.
[0034] Step 102: Detecting a first file system format of the secure digital card, and if the first file system format is not a target file system format, converting the first file system format to the target file system format.
[0035] In one embodiment, since the secure digital card is mounted in step 101, the mount point of the secure digital card can be determined. Therefore, based on the mount point, the df command can be directly used to view the first file system type corresponding to the secure digital card.
[0036] Preferably, in addition to the df command, the lsblk command, the fdisk command, or the blkid command may also be used.
[0037] In one embodiment, the target file system format is an EXT4 file system.
[0038] In one embodiment, the mount point of the secure digital card is determined, and based on the mount point, the secure digital card is uninstalled; a partition is created in a non-interactive manner to obtain a target partition, and the file system format of the target partition is formatted into the target file system format; and the secure digital card is remounted.
[0039] Specifically, when the secure digital card is uninstalled based on the mount point, lazy uninstallation and forced uninstallation are adopted, and an uninstallation command is adopted to uninstall the mount point, so as to realize the uninstallation of the secure digital card.
[0040] Example description: For example, if the mount point of the secure digital card is / mnt / sdcard, then the command line . / bin / umount -lf / mnt / sdcard is used to lazily unmount and force unmount the secure digital card. umount is a command line tool used to unmount the file system, which makes the file system "disappear" from the Linux system, that is, it is no longer accessible; -l stands for "lazy unmount"; when the -l option is used, the umount command unmounts the file system immediately, but does not immediately synchronize (flush) all unwritten system buffers, which means that any unwritten changes may be written to the disk later instead of being written immediately, which can improve the efficiency of the unmount operation, but does not immediately release all resources; -f stands for "force unmount". If the file system cannot be unmounted normally for some reason (such as files are in use), use the -f option to force unmounting; this may cause data loss, so only use it when you are sure that no important operations are in progress; / mnt / sdcard is the mount point; in this example, the Secure Digital card is mounted in the / mnt / sdcard directory; the umount command will "unmount" this directory, making the contents of the Secure Digital card no longer accessible through this directory.
[0041] In one embodiment, partition creation is performed in a non-interactive manner. When a target partition is obtained, a new DOS partition table is created; a first partition is created, and a corresponding classification type, partition number, start sector, and end sector are set for the first partition; the first partition is written into the DOS partition table, and the first partition in the DOS partition table is used as the target partition.
[0042] Preferably, the creation of non-interactive partitions is achieved by constructing a non-interactive partition creation command based on the non-interactive partition creation command, wherein the non-interactive partition creation command is (echo o; echo n; echo p; echo1; echo; echo; echo w) | fdisk / dev / mmcblk2; this command sequence passes the output of a series of echo commands directly to the fdisk command through a pipe (|), thereby achieving a non-interactive partition creation process.
[0043] Specifically, echo o: outputs the letter "o", which is the fdisk command used to create a new empty DOS partition table. This step will clear the existing partition table on the / dev / mmcblk2 device and prepare to create a new partition table, namely the DOS partition table.
[0044] Specifically, echo n: outputs the letter "n", which is the fdisk command used to create a new partition, the first partition.
[0045] Specifically, echo p: outputs the letter "p", indicating that a primary partition (Primarypartition) is to be created.
[0046] Specifically, echo 1: outputs the number "1", assigns the number 1 to the newly created first partition, that is, sets the corresponding partition number.
[0047] Specifically, the first echo: outputs a blank line, accepting the default partition type of fdisk, usually Linuxnative (type 83), that is, setting the corresponding partition type.
[0048] Specifically, the second echo: outputs a blank line, accepts the default starting sector of fdisk, that is, sets the corresponding starting sector.
[0049] Specifically, the third echo: outputs a blank line, accepts the default end sector of fdisk, that is, sets the corresponding end sector.
[0050] Specifically, echo w: outputs the letter "w", which is the fdisk command used to write changes to the disk and exit. This step will write the new partition table to the / dev / mmcblk2 device, making the partition table effective.
[0051] Through the above steps, the fdisk tool will create a new DOS partition table on the / dev / mmcblk2 device and add a primary partition to the partition table. This primary partition is set to partition number 1, and the partition type, start sector, and end sector all use default values. These default values are automatically determined by fdisk based on the disk's geometry and available space.
[0052] In one embodiment, in a Linux system, in some cases, when a new partition is created, the system may automatically mount the partition. This is usually due to the system configuration or the function of some automatic mounting services (such as udev or mdev). Therefore, after obtaining the target partition, it is also detected whether the secure digital card is mounted. If so, the secure digital card is forcibly uninstalled until it is detected that the secure digital card is not mounted.
[0053] In one embodiment, when formatting the file system format of the target partition into the target file system format, a simulated user input combination instruction is created, and a target file system creation instruction is created, a pipeline operation is set for the simulated user input combination instruction and the target file system creation instruction, and a file system format formatting instruction is generated; based on the file system format formatting instruction, the file system format of the target partition is formatted into the target file system format.
[0054] Specifically, the simulated user input combination instruction is (echo y; echo), the target file system creation instruction is mkfs.ext4 / dev / mmcblk2p1, and "|" is a pipe operator; the generated file system format formatting instruction is (echo y; echo) |mkfs.ext4 / dev / mmcblk2p1.
[0055] Specifically, echo y: outputs the character "y", which is usually an affirmative answer to the mkfs.ext4 command prompt "Are you sure you want to format this partition?"; echo: outputs a blank line, which is usually the default response to subsequent prompts of the mkfs.ext4 command, such as confirming the partition size or file system label.
[0056] Specifically, mkfs.ext4: is the command to create the EXT4 file system; / dev / mmcblk2p1: specifies the partition device file to be formatted.
[0057] Specifically, |: This is the pipe operator, which uses the output of the command on the left as the input of the command on the right. In this command, the pipe passes the output of the echo y; echo command (that is, "y\n" and "\n") to the mkfs.ext4 command, simulating the user manually entering "y" and pressing the Enter key in the command line.
[0058] Specifically, a file system formatting instruction is generated by combining the combined instructions of simulating user input with the target file system creation instructions using a pipeline; this instruction tells the mkfs.ext4 tool to directly perform the formatting operation without interactive input; after executing this command, the / dev / mmcblk2p1 partition will be formatted as the EXT4 file system; in this process, all data previously existing on the partition will be cleared because formatting will recreate the file system structure and metadata.
[0059] In one embodiment, when the secure digital card is remounted, a target mount point is created in a target file system and a target mount point directory is recorded; a mount status detection is performed on the secure digital card, and when it is detected that the secure digital card is not mounted, a mount instruction parameter is generated according to the target file system format and the target mount point directory, and the secure digital card is mounted based on the mount instruction parameter.
[0060] Specifically, the secure digital card is remounted using the command line / bin / mount -t ext4 -o exec,noatime / dev / mmcblk2p1 / mnt / sdcard / . This command mounts the / dev / mmcblk2p1 partition to the / mnt / sdcard / directory and specifies the file system type and mount options.
[0061] Specifically, in Linux systems, a mount point is a directory that serves as an entry point for accessing the mounted file system. In the above command line, the mount point has been specified as / mnt / sdcard / . This directory must exist in the target file system in order to mount the secure digital card to this location. Before attempting to mount the secure digital card, you need to check whether the secure digital card has been mounted. This can be done by using the mount command. If this command returns any results, it means that the secure digital card has been mounted. If no results are returned, it means that the secure digital card has not been mounted.
[0062] Specifically, if the secure digital card is not mounted, then the mount command parameters need to be generated. These parameters include: (1) -t ext4: specifies the file system type as EXT4; (2) -o exec,noatime: sets the mount options. exec allows binary files to be executed in the mounted file system. noatime means that the last access time of the file will not be updated, which can improve performance; (3) / dev / mmcblk2p1: device file of the secure digital card partition; (4) / mnt / sdcard / : mount point directory.
[0063] Specifically, the mount command and the above mount instruction parameters are used to mount the secure digital card.
[0064] Step 103: performing file pre-allocation processing on the secure digital card after format conversion to obtain a pre-allocated file. In one embodiment, the number of pre-allocated files and the file size corresponding to each file are determined; based on the file data and the file size, the pre-allocated files are cyclically created on the secure digital card to obtain a pre-allocated file list, wherein the pre-allocated file list is composed of the pre-allocated files.
[0065] Specifically, the total capacity of the secure digital card is obtained, and the number of pre-allocated files and the file size corresponding to each file are determined; based on the number of files and the file size, the required target capacity is determined; and it is judged whether the target capacity is greater than the total capacity; if not, it is determined that the number of pre-allocated files and the file size corresponding to each file meet the pre-allocation requirements; otherwise, the number of pre-allocated files and the file size corresponding to each file are re-determined until the target capacity is no greater than the total capacity.
[0066] An example is given. Determine the number of files to be created and the size of each file based on the total capacity of the secure digital card and your specific needs. For example, when the secure digital card capacity is a commonly used 64G SD card, although the SD card capacity is marked as 64G, its actual total capacity is 64x1000x1000x1000÷1024÷1024=61035 (M). 61035÷200≈305 files. Therefore, it can be determined to pre-allocate 305 files, each with a size of approximately 200MB. Calculate whether the target capacity exceeds the total capacity of the secure digital card: 305 files×200MB / file=61000MB. Ensure that the target capacity does not exceed the total capacity of the secure digital card.
[0067] Specifically, based on the file data and the file size, the secure digital card is pre-allocated files are created cyclically. When the pre-allocated file list is obtained, a Bash script is used to cyclically create each pre-allocated file, and the fallocate command is used to pre-allocate space of a specified size to obtain a pre-allocated file list. This script will create 305 files of 200 MB in size in the / mnt / sdcard directory.
[0068] In one embodiment, after obtaining the pre-allocated file list, the number of pre-allocated files in the pre-allocated file list and the size of each pre-allocated file are verified.
[0069] Specifically, use the ls -lh command to view the created preallocated file list and verify whether the size of each preallocated file in the preallocated file list is correct.
[0070] Example 2, see Figure 2 , Figure 21 is a schematic diagram of a structure of an embodiment of a file pre-allocation device provided by the present application. Corresponding to the above file pre-allocation method, the present application also provides a file pre-allocation device. The file pre-allocation device includes a unit for executing the above file pre-allocation method, and the file pre-allocation device can be configured in a desktop computer, a tablet computer, a laptop computer, and other terminals. Specifically, the file pre-allocation device includes a secure digital card detection module 201, a file system format conversion module 202, and a file pre-allocation module 203. The secure digital card detection module 201 is used to mount the secure digital card when it is detected that a secure digital card is inserted into a target device, wherein the target device is an embeddable device supporting the exFAT file system.
[0071] The file system format conversion module 202 is used to detect the first file system format of the secure digital card, and if the first file system format is not the target file system format, convert the first file system format to the target file system format.
[0072] The file pre-allocation module 203 is used to perform file pre-allocation processing on the secure digital card after format conversion to obtain pre-allocated files.
[0073] In one embodiment, the file system format conversion module 202 is used to convert the first file system format into the target file system format, specifically including: determining the mount point of the secure digital card, and based on the mount point, unmounting the secure digital card; creating a partition in a non-interactive manner to obtain a target partition, and formatting the file system format of the target partition into the target file system format; and re-mounting the secure digital card.
[0074] In one embodiment, the file system format conversion module 202 is used to create a partition in a non-interactive manner to obtain a target partition, specifically including: creating a new DOS partition table; creating a first partition, and setting a corresponding classification type, partition number, start sector and end sector for the first partition; and writing the first partition into the DOS partition table, and using the first partition in the DOS partition table as the target partition.
[0075] In one embodiment, after obtaining the target partition, the file system format conversion module 202 further includes: detecting whether the secure digital card is mounted, and if so, forcibly uninstalling the secure digital card until it is detected that the secure digital card is not mounted.
[0076] In one embodiment, the file system format conversion module 202 is used to format the file system format of the target partition into the target file system format, specifically including: creating a simulated user input combination instruction and a target file system creation instruction, setting a pipeline operation for the simulated user input combination instruction and the target file system creation instruction, and generating a file system format formatting instruction; based on the file system format formatting instruction, formatting the file system format of the target partition into the target file system format.
[0077] In one embodiment, the file system format conversion module 202 is used to re-mount the secure digital card, specifically including: creating a target mount point in the target file system and recording the target mount point directory; performing a mount status detection on the secure digital card, and when it is detected that the secure digital card is not mounted, generating a mount instruction parameter according to the target file system format and the target mount point directory, and mounting the secure digital card based on the mount instruction parameter.
[0078] In one embodiment, the file pre-allocation module 203 is used to perform file pre-allocation processing on the secure digital card after format conversion to obtain pre-allocated files, specifically including: determining the number of pre-allocated files and the file size corresponding to each file; based on the file data and the file size, cyclically creating pre-allocated files for the secure digital card to obtain a pre-allocated file list, wherein the pre-allocated file list is composed of the pre-allocated files.
[0079] The file pre-allocation device can implement the file pre-allocation method of the method embodiment. The options in the method embodiment are also applicable to this embodiment and will not be described in detail here.
[0080] like Figure 3 As shown, Figure 3 It is a structural diagram of an electronic device provided by the present application; it includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114, and the memory 113 is used to store computer programs.
[0081] In one embodiment of the present application, the processor 111 is used to implement the file pre-allocation method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.
[0082] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0083] Therefore, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the file pre-allocation method provided in any of the aforementioned method embodiments are implemented.
[0084] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which can store program codes. The computer-readable storage medium can be non-volatile or volatile.
[0085] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0086] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0087] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present application can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0088] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0089] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0090] 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 application 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.
[0091] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A file pre-allocation method, It is characterized in that include: When it is detected that a secure digital card is inserted into the target device, mounting the secure digital card, wherein the target device is an embeddable device supporting the exFAT file system; detecting a first file system format of the secure digital card, and if the first file system format is not a target file system format, converting the first file system format into the target file system format; The secure digital card after format conversion is subjected to file pre-allocation processing to obtain a pre-allocated file.
2. The method according to claim 1, It is characterized in that The converting the first file system format to the target file system format specifically includes: Determine the mount point of the secure digital card, and uninstall the secure digital card based on the mount point; Create a partition in a non-interactive manner to obtain a target partition, and format the file system format of the target partition into the target file system format; Re-mount the secure digital card.
3. The method according to claim 2, It is characterized in that The partition creation based on the non-interactive mode to obtain the target partition specifically includes: Create a new dos partition table; Create a new first partition, and set a corresponding classification type, partition number, start sector, and end sector for the first partition; The first partition is written into the DOS partition table, and the first partition in the DOS partition table is used as the target partition.
4. The method according to claim 2, It is characterized in that After getting the target partition, it also includes: Detect whether the secure digital card is mounted, and if so, forcibly uninstall the secure digital card until it is detected that the secure digital card is not mounted.
5. The method according to claim 2, It is characterized in that The step of formatting the file system format of the target partition into the target file system format specifically includes: Creating a simulated user input combined instruction and a target file system creation instruction, setting a pipeline operation for the simulated user input combined instruction and the target file system creation instruction, and generating a file system formatting instruction; Based on the file system formatting instruction, the file system format of the target partition is formatted into the target file system format.
6. The method according to claim 2, It is characterized in that The re-mounting process of the secure digital card specifically includes: Create a target mount point in the target file system and record the target mount point directory; The mount status of the secure digital card is detected. When it is detected that the secure digital card is not mounted, a mount instruction parameter is generated according to the target file system format and the target mount point directory, and the secure digital card is mounted based on the mount instruction parameter.
7. The method according to claim 1, It is characterized in that The pre-allocation of files on the secure digital card after format conversion to obtain pre-allocated files specifically includes: Determine the number of pre-allocated files and the file size corresponding to each file; Based on the file data and the file size, the secure digital card is subjected to a cyclic creation of pre-allocated files to obtain a pre-allocated file list, wherein the pre-allocated file list is composed of the pre-allocated files.
8. A file pre-allocation device, It is characterized in that include: Secure digital card detection module, file system format conversion module and file pre-allocation module; The secure digital card detection module is used to mount the secure digital card when it is detected that a secure digital card is inserted into a target device, wherein the target device is an embeddable device supporting the exFAT file system; The file system format conversion module is used to detect the first file system format of the secure digital card, and if the first file system format is not the target file system format, convert the first file system format into the target file system format; The file pre-allocation module is used to perform file pre-allocation processing on the secure digital card after format conversion to obtain pre-allocated files.
9. A computer device, It is characterized in that The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, It is characterized in that The 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 7 can be implemented.
Citation Information
Patent Citations
Method for automatically mounting USB storage device under embedded Linux
CN101847101A
Mounting method and device of external multi-partition storage device
CN106873921A
Method and apparatus for extending user partition
CN107148612A
Automatic mounting method for movable storage equipment and locomotive video monitoring system
CN109976811A
Application level sd card space management
CN114595189A
