CN109885257B - Disk file reading and writing method and device - Google Patents

Disk file reading and writing method and device Download PDF

Info

Publication number
CN109885257B
CN109885257B CN201910100744.3A CN201910100744A CN109885257B CN 109885257 B CN109885257 B CN 109885257B CN 201910100744 A CN201910100744 A CN 201910100744A CN 109885257 B CN109885257 B CN 109885257B
Authority
CN
China
Prior art keywords
file
read
disk partition
virtual
write
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910100744.3A
Other languages
Chinese (zh)
Other versions
CN109885257A (en
Inventor
杨春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN201910100744.3A priority Critical patent/CN109885257B/en
Publication of CN109885257A publication Critical patent/CN109885257A/en
Application granted granted Critical
Publication of CN109885257B publication Critical patent/CN109885257B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method and a device for reading and writing a disk file. The method comprises the following steps: acquiring a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written; determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition; and executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request. The invention can share the simulated virtual disk partition to the terminal, thereby realizing the purpose that the two sharing ends can access the file at the same time.

Description

Disk file reading and writing method and device
Technical Field
The invention relates to the technical field of mobile communication, in particular to a method and a device for reading and writing a disk file.
Background
Sharing files between devices is a very common usage scenario, such as sharing files between a mobile phone and a personal computer or between a mobile phone and a mobile phone. There are also many ways of file sharing, such as sharing over a network or sharing over USB. Sharing by USB is further divided into implementations based on mass storage protocol and implementations based on media transfer protocol (PTP/MTP) protocol.
At present, the way of sharing files among devices is mainly a way of sharing files through a USB, and is realized based on a mass storage protocol. With continuous iteration of software technology and the limitation of a large-capacity storage protocol, a file sharing mode gradually evolves to a PTP/MTP protocol, especially to sharing between devices with complex functions and systems, such as sharing files between a smart phone and a computer.
However, the USB-based mass storage protocol needs to define a specific partition on the disk of the device side, and the partition is shared in the form of block devices, so that the device side cannot access the partition data at the same time after the host side (e.g., a computer).
Disclosure of Invention
The embodiment of the invention provides a disk file reading and writing method and device, and aims to solve the problem that file sharing modes in the prior art cannot be accessed simultaneously.
In order to solve the above technical problem, the embodiment of the present invention is implemented as follows:
in a first aspect, an embodiment of the present invention provides a method for reading and writing a disk file, including: acquiring a file read/write request sent by a terminal; the file reading/writing request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written; determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition; and executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request.
In a second aspect, an embodiment of the present invention provides a disk file read/write apparatus, including: the read-write request acquisition module is used for acquiring a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written; the physical partition determining module is used for determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition; and the read-write operation execution module is used for executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request.
In a third aspect, an embodiment of the present invention provides a mobile terminal, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor, where the computer program, when executed by the processor, implements the steps of the method for reading and writing a disk file described in any one of the above.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for reading and writing the disk file described in any of the foregoing are implemented.
In the embodiment of the invention, a file read/write request sent by a terminal is obtained, wherein the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written, a target physical disk partition corresponding to the target virtual disk partition is determined according to a mapping relation between the virtual disk partition and the physical disk partition, and corresponding file read/write operation is executed in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request. The embodiment of the invention shares the simulated virtual disk partition to the terminal, thereby realizing the purpose that the two sharing ends can access the file at the same time.
Drawings
Fig. 1 is a flowchart illustrating steps of a method for reading and writing a disk file according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating steps of a method for reading and writing a disk file according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram illustrating a disk file read-write apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram illustrating a disk file read-write apparatus according to an embodiment of the present invention;
fig. 5 shows a block diagram of a mobile terminal according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Referring to fig. 1, a flowchart illustrating steps of a method for reading and writing a disk file according to an embodiment of the present invention is shown, where the method for reading and writing a disk file can be applied to a mobile terminal, and specifically includes the following steps:
step 101: acquiring a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written.
In the embodiment of the present invention, the mobile terminal may be a mobile electronic device such as a mobile phone, a PDA (personal digital Assistant), a tablet computer, and the like.
The terminal refers to other terminals connected with the mobile terminal, and may be a mobile terminal, such as a mobile phone, or a personal computer, and the like, which is not limited in this embodiment of the present invention.
When the mobile terminal shares files with other terminals, the file data may be shared through a network, or the file data may be shared through a USB, which may be determined according to actual situations, and this is not limited in the embodiment of the present invention.
The physical disk partition may be simulated at the mobile terminal side, that is, the virtual disk partition is obtained through simulation, after the mobile terminal is connected with another terminal through a network or a USB, the virtual disk partition is shared to the another terminal, and the another terminal may view files on the disk partition according to the virtual disk partition and perform operations such as reading and writing, which will be described in detail in the following embodiment two.
When other terminals need to perform read or write operations on files on the virtual disk partitions, a file read/write request can be initiated to the mobile terminal, the file read/write request includes a target virtual disk partition where a file to be read/written is located, that is, a certain partition in the virtual disk partitions, for example, the virtual disk partition displayed on the terminal a includes partition 1, partition 2 and partition 3, and when a read operation on a certain file on partition 3 is performed, partition 3 is the target disk partition.
The file read/write request may further include a virtual logical address of the file to be read/written, that is, a logical address on the target virtual disk partition, and the start position, the read/write length, and the like of the file to be read/written may be specified by the virtual logical address, so that the file may correspond to the physical disk partition of the mobile terminal, and corresponding read/write operations may be performed on the physical disk partition.
After acquiring the file read/write request sent by the terminal, step 102 is executed.
Step 102: and determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition.
The mapping relationship between the virtual disk partition and the physical disk partition is stored in advance in the system of the mobile terminal, for example, the physical disk partition includes partition a, partition b and partition c, the virtual disk partition includes partition 1, partition 2 and partition 3, partition a corresponds to partition 2, partition b corresponds to partition 1, and partition c corresponds to partition 3.
The mapping relationship may be stored in a mobile terminal system in a list form, as shown in table 1 below:
table 1:
physical disk partitioning Virtual disk partitioning
a 2
b 1
c 3
As shown in table 1, physical partition a has a mapping relationship with virtual partition 2, physical partition b has a mapping relationship with virtual partition 1, and physical partition c has a mapping relationship with virtual partition 3.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not intended to limit the embodiments of the present invention.
Of course, a database may also be created in the mobile terminal system for the mapping relationship, and the mapping relationship is stored in the form of a database, and specifically, the mapping relationship may be determined according to actual situations, which is not limited in the embodiment of the present invention.
After the target virtual disk partition where the file to be read/written is located is obtained, a target physical disk partition corresponding to the target virtual disk partition may be determined according to a mapping relationship between the virtual disk partition and the physical disk partition, and step 103 is performed.
Step 103: and executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request.
The corresponding relation between the virtual logical address and the physical logical address is also stored in the mobile terminal system, after the virtual logical address of the file to be read/written (namely the address of the file to be read/written on the target virtual disk partition) is obtained according to the file read/write request, the physical logical address, namely the physical logical address on the target physical disk partition, can be obtained according to the matching of the virtual logical address, and then the physical logical address of the target file on the target physical disk partition corresponding to the file to be read/written, namely the initial position of the target file, can be determined according to the physical logical address.
The file read/write request may further include a read or write operation on the target file, for example, reading data of a specified length in the target file, or writing data of a specified length from a certain byte of the target file, and the like.
The embodiment of the invention shares the simulated virtual disk partition to the terminal, thereby realizing the purpose that the two sharing ends can access the file simultaneously and avoiding the problem that the two ends can not access the file simultaneously when the file is shared.
The disk file reading and writing method provided by the embodiment of the invention comprises the steps of obtaining a file reading/writing request sent by a terminal, wherein the file reading/writing request comprises a target virtual disk partition where a file to be read/written is located and a virtual logical address of the file to be read/written, determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition, and executing corresponding file reading/writing operation in the target physical disk partition according to the virtual logical address of the file to be read/written and the file reading/writing request. The embodiment of the invention shares the simulated virtual disk partition to the terminal, thereby realizing the purpose that the two sharing ends can access the file at the same time.
Example two
Referring to fig. 2, a flowchart illustrating steps of a method for reading and writing a disk file according to an embodiment of the present invention is shown, where the method for reading and writing a disk file can be applied to a mobile terminal, and specifically includes the following steps:
step 201: all files on the physical disk partition are obtained.
In the embodiment of the present invention, the mobile terminal may be a mobile electronic device such as a mobile phone, a PDA (personal digital Assistant), a tablet computer, and the like.
The embodiment of the present invention may simulate each physical disk partition of the mobile terminal (i.e. all physical disk partitions of the mobile terminal) to obtain a virtual disk partition, which is not limited in this respect.
When all the physical disk partitions of the mobile terminal are simulated, all the files on each physical disk partition may be acquired, and step 202 is performed.
Step 202: and acquiring the file size corresponding to each file and the physical logic address of each file on the physical disk partition.
After all the files on the physical disk partition are obtained, the file size of each file may be obtained, such as the file size of 8kb, 10kb, and so on.
The physical logical address of each file on the physical disk partition, that is, the starting position of each file on the corresponding physical disk partition, the file data length, and the like, may also be obtained.
After the file size corresponding to each file and the physical logical address of each file on the physical disk partition are obtained, step 203 is executed.
Step 203: and generating a virtual file with the same size as the corresponding size of each file according to the size of each file.
After the file sizes of all the files in the physical disk partition are obtained, a virtual file with the same size as that of each file may be generated according to the file size of each file, for example, if the size of a file in a certain physical disk partition is 10kb, a virtual file with the size of 10kb is generated.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
After generating the virtual files having the same size as the size of each file according to the size of each file, step 204 is performed.
Step 204: and establishing and storing the association relationship among each virtual file, each file and each physical logic address.
After generating the virtual files corresponding to the files, association relationships among the virtual files, the files, and the physical logical addresses may be established, for example, the virtual files include a and B, the files include a and B, and the physical logical addresses include 1 and 2, where an association relationship exists among the file a, the virtual file B, and the physical logical address 1, and an association relationship exists among the file B, the virtual file a, and the physical logical address 2, that is, when obtaining the virtual file B, the corresponding file a and the physical logical address 1 may be determined according to the association relationships.
The association relationship may be stored in a mobile terminal system in a form of a list, as shown in table 2 below:
table 2:
document Virtual file Physical logical addresses
A b 1
B a 2
As can be seen from table 2, there is an association between the file a, the virtual file B, and the physical logical address 1, and an association between the file B, the virtual file a, and the physical logical address 2.
Of course, a corresponding association relation database may also be created in the mobile terminal system to store the association relation, which may be determined according to actual situations, and the embodiment of the present invention is not limited thereto.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
After the association relationship between each virtual file, each file, and each physical logical address is established and saved, step 205 is executed.
Step 205: and establishing a virtual disk partition corresponding to the physical disk partition according to each virtual file.
After the association relationship among the virtual files, the files, and the physical logical addresses is established and stored, a virtual disk partition corresponding to the physical disk partition may be established according to the virtual files, so as to fill the virtual disk partition with the virtual files, thereby forming a virtual disk partition corresponding to the physical disk partition, so as to implement the simulation of the physical disk partition, and perform step 206.
Step 206: and sharing the virtual disk partition to the terminal through a specified protocol.
In the embodiment of the present invention, the terminal refers to other terminals connected to the mobile terminal, and may be a mobile terminal, such as a mobile phone, or a personal computer, and the like.
When the other terminal and the mobile terminal are connected through a network or a USB, the virtual disk partition can be shared to the terminal through a specified protocol, for example, when the other terminal and the mobile terminal are connected through the USB, the virtual disk partition can be shared to the other terminal through a USB mass storage protocol, and the like.
When different connection modes are adopted, different protocols may be adopted to share the virtual disk partitions, and specifically, the sharing may be determined according to actual situations, which is not limited in the embodiment of the present invention.
After sharing the virtual disk partition to the terminal through the specified protocol, step 207 is performed.
Step 207: acquiring a file read/write request sent by a terminal; the file reading/writing request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written.
In the embodiment of the invention, the file to be read/written refers to a virtual file on a target virtual disk partition.
The terminal refers to other terminals connected to the mobile terminal, and may be a mobile terminal, such as a mobile phone, or a personal computer, and the like, which is not limited in this embodiment of the present invention.
When the mobile terminal shares files with other terminals, the file data may be shared through a network, or the file data may be shared through a USB, which may be determined according to actual situations, and this is not limited in the embodiment of the present invention.
The method comprises the steps that a physical disk partition can be simulated at a mobile terminal side, namely a virtual disk partition is obtained through simulation, the virtual disk partition is shared to other terminals after the mobile terminal is connected with other terminals through a network or a USB, and other terminals can check files on the disk partition according to the virtual disk partition and execute reading, writing and other operations.
When other terminals need to perform read or write operations on files on the virtual disk partitions, a file read/write request can be initiated to the mobile terminal, the file read/write request includes a target virtual disk partition where a file to be read/written is located, that is, a certain partition in the virtual disk partitions, for example, the virtual disk partition displayed on the terminal a includes partition 1, partition 2 and partition 3, and when a read operation on a certain file on partition 3 is performed, partition 3 is the target disk partition.
The file read/write request may further include a virtual logical address of the file to be read/written, that is, a logical address on the target virtual disk partition, and the start position, the read/write length, and the like of the file to be read/written may be specified by the virtual logical address, so that the file may correspond to the physical disk partition of the mobile terminal, and corresponding read/write operations may be performed on the physical disk partition.
After acquiring the file read/write request sent by the terminal, step 208 is executed.
Step 208: and determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition.
The mapping relationship between the virtual disk partition and the physical disk partition is stored in advance in the system of the mobile terminal, for example, the physical disk partition includes partition a, partition b and partition c, the virtual disk partition includes partition 1, partition 2 and partition 3, partition a corresponds to partition 2, partition b corresponds to partition 1, and partition c corresponds to partition 3.
After the target virtual disk partition where the file to be read/written is located is obtained, a target physical disk partition corresponding to the target virtual disk partition may be determined according to a mapping relationship between the virtual disk partition and the physical disk partition, and step 209 is performed.
Step 209: and determining a second actual read/write file corresponding to the file to be read/written according to the target physical disk partition and the virtual logical address.
In an embodiment of the present invention, the second actual read/write file refers to a file on the target physical disk partition.
After the target physical disk partition corresponding to the target virtual disk partition is determined, the second actual read/write file corresponding to the file to be read/written may be determined according to the virtual logical address, specifically, according to the association relationship and the virtual logical address of the file to be read/written on the target virtual disk partition, so as to determine the second actual read/write file and the physical logical address of the second actual read/write file on the target physical disk partition, and then step 210 is performed.
Step 210: and under the condition that the file read/write request meets a preset authentication condition, executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request.
The preset authentication condition may include any one of a read-only condition, a write-only condition, and a read-write condition, for example, when the file a contains only the read-only condition, it indicates that an operation of reading can be performed only on the file a; when the file B only contains the write-only condition, the write-only condition indicates that the write operation can be executed only on the file B; when the file C contains a read-write operation, it means that a read-write operation or the like can be performed on the file C.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
The embodiment of the invention adds the preset authentication condition to each file in advance, thereby preventing the files in the mobile terminal from being changed when the files are shared and ensuring the safety of the files in the mobile terminal.
The preset authentication condition corresponding to the file of the physical disk partition is pre-stored in the system of the mobile terminal, and after the second actual read/write file is obtained, the preset authentication condition corresponding to the second actual read/write file can be searched in a matching manner.
The case that the file read/write request meets the preset authentication condition comprises the following steps: when the preset authentication condition is a read-only condition and the file read/write request is a request for reading file data, the file read/write request is represented to meet the preset authentication condition; or when the preset authentication condition is a write-only condition and the file read/write request is a request for writing data in the file, the file read/write request meets the preset authentication condition; or when the preset authentication condition is a readable and writable condition and the file read/write request is a request for writing data in a file or a request for reading file data, the file read/write request meets the preset authentication condition.
It should be understood that the above-mentioned technical solutions are detailed descriptions for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitations of the embodiments of the present invention.
Under the condition that the file read/write request meets the preset authentication condition, corresponding file read/write operation can be executed in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request, so that file sharing on the physical disk partition of the mobile terminal is realized.
In a preferred embodiment of the present invention, the file read/write request further includes a data read/write length and a data read/write offset, and step 210 may include:
substep A1: determining a target physical logic address on the target physical disk partition according to the virtual logic address and the association relation;
substep A2: determining a first actual read/write file corresponding to the file to be read/write on the target physical disk partition according to the target physical logical address;
substep A3: and executing data read/write operation on the first actual read/write file according to the data read/write length and the data read/write offset.
In the embodiment of the present invention, the file read/write request further includes a data read/write length and a data read/write offset, where the data read/write length refers to a length of reading data from or writing data into the file, and the data read/write offset refers to a starting position of reading data from or writing data into the file.
The first actual read/write file refers to a file on the target physical disk partition.
After the virtual logical address and the association relation are obtained, the target physical logical address on the target physical disk partition can be determined according to the virtual logical address and the association relation, and then a first actual read/write file corresponding to the file to be read/written on the target physical disk partition can be determined according to the target physical logical address.
And then, according to the data reading/writing length and the data reading/writing offset, performing data reading/writing operation on the first actual reading/writing file.
The method for reading and writing the disk file provided by the embodiment of the invention has the beneficial effects of the method for reading and writing the disk file shown in the first embodiment, and can also perform file authentication before the reading and writing operation is executed, so that the file in the mobile terminal can be prevented from being changed, and the safety of the file in the mobile terminal is ensured.
EXAMPLE III
Referring to fig. 3, a schematic structural diagram of a magnetic disk file read-write apparatus provided in an embodiment of the present invention is shown, where the magnetic disk file read-write apparatus may be applied to a mobile terminal, and specifically may include:
a read-write request obtaining module 301, configured to obtain a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written; a physical partition determining module 302, configured to determine, according to a mapping relationship between a virtual disk partition and a physical disk partition, a target physical disk partition corresponding to the target virtual disk partition; a read-write operation execution module 303, configured to execute a corresponding file read/write operation in the target physical disk partition according to the virtual logical address of the file to be read/written and the file read/write request.
The disk file read-write device provided by the embodiment of the invention is characterized in that a file read/write request sent by a terminal is obtained, wherein the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written, a target physical disk partition corresponding to the target virtual disk partition is determined according to the mapping relation between the virtual disk partition and the physical disk partition, and corresponding file read/write operation is executed in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request. The embodiment of the invention shares the simulated virtual disk partition to the terminal, thereby realizing the purpose that the two sharing ends can access the file at the same time.
Example four
Referring to fig. 4, a schematic structural diagram of a magnetic disk file reading and writing device provided in an embodiment of the present invention is shown, where the magnetic disk file reading and writing device may be applied to a mobile terminal, and specifically may include:
a file obtaining module 401, configured to obtain all files on a physical disk partition; a file size physical address obtaining module 402, configured to obtain a file size corresponding to each file, and a physical logical address of each file on the physical disk partition; a virtual file generating module 403, configured to generate, according to the size of each file, a virtual file having the same size as that of each file; an association relationship establishing module 404, configured to establish and store an association relationship among each virtual file, each file, and each physical logical address; a virtual disk partition establishing module 405, configured to establish a virtual disk partition corresponding to the physical disk partition according to each virtual file; a virtual disk partition sharing module 406, configured to share the virtual disk partition to the terminal through a specified protocol; a read-write request obtaining module 407, configured to obtain a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written; a physical partition determining module 408, configured to determine, according to a mapping relationship between a virtual disk partition and a physical disk partition, a target physical disk partition corresponding to the target virtual disk partition; a second read/write file determining module 409, configured to determine, according to the target physical disk partition and the virtual logical address, a second actual read/write file corresponding to the file to be read/written; an authentication success module 410, configured to execute the read-write operation executing module 411 when the file read/write request meets a preset authentication condition; the read-write operation executing module 411 is configured to execute corresponding file read/write operations in the target physical disk partition according to the virtual logical address of the file to be read/written and the file read/write request.
Preferably, the file read/write request further includes a data read/write length and a data read/write offset, and the read/write operation executing module 411 includes: a target physical address determining submodule, configured to determine a target physical logical address on the target physical disk partition according to the virtual logical address and the association relationship; the first read-write file determining submodule is used for determining a first actual read-write file corresponding to the file to be read/written on the target physical disk partition according to the target physical logical address; and the read-write operation execution sub-module is used for executing data read/write operation on the first actual read/write file according to the data read/write length and the data read/write offset.
Preferably, the preset authentication condition includes any one of a read-only condition, a write-only condition and a read-write condition.
The magnetic disk file read-write device provided by the embodiment of the invention not only has the beneficial effects of the magnetic disk file read-write device shown in the third embodiment, but also can perform file authentication before executing read-write operation, thereby preventing the file in the mobile terminal from being changed and ensuring the safety of the file.
EXAMPLE five
Referring to fig. 5, a hardware structure diagram of a mobile terminal for implementing various embodiments of the present invention is shown.
The mobile terminal 500 includes, but is not limited to: radio frequency unit 501, network module 502, audio output unit 503, input unit 504, sensor 505, display unit 506, user input unit 507, interface unit 508, memory 509, processor 510, and power supply 511. Those skilled in the art will appreciate that the mobile terminal architecture illustrated in fig. 5 is not intended to be limiting of mobile terminals, and that a mobile terminal may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. In the embodiment of the present invention, the mobile terminal includes, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted terminal, a wearable device, a pedometer, and the like.
A processor 510, configured to obtain a file read/write request sent by a terminal; the file reading/writing request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written; determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition; and executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request.
In the embodiment of the invention, a file read/write request sent by a terminal is obtained, wherein the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logical address of the file to be read/written, a target physical disk partition corresponding to the target virtual disk partition is determined according to the mapping relation between the virtual disk partition and the physical disk partition, and corresponding file read/write operation is executed in the target physical disk partition according to the virtual logical address of the file to be read/written and the file read/write request. The embodiment of the invention shares the simulated virtual disk partition to the terminal, thereby realizing the purpose that the two sharing ends can access the file at the same time.
It should be understood that, in the embodiment of the present invention, the radio frequency unit 501 may be used for receiving and sending signals during a message sending and receiving process or a call process, and specifically, receives downlink data from a base station and then processes the received downlink data to the processor 510; in addition, the uplink data is transmitted to the base station. In general, radio frequency unit 501 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, and the like. In addition, the radio frequency unit 501 can also communicate with a network and other devices through a wireless communication system.
The mobile terminal provides the user with wireless broadband internet access through the network module 502, such as helping the user send and receive e-mails, browse webpages, access streaming media, and the like.
The audio output unit 503 may convert audio data received by the radio frequency unit 501 or the network module 502 or stored in the memory 509 into an audio signal and output as sound. Also, the audio output unit 503 may also provide audio output related to a specific function performed by the mobile terminal 500 (e.g., a call signal reception sound, a message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, a receiver, and the like.
The input unit 504 is used to receive audio or video signals. The input Unit 504 may include a Graphics Processing Unit (GPU) 5041 and a microphone 5042, and the Graphics processor 5041 processes image data of still pictures or video obtained by an image capturing device (such as a camera) in a video capture mode or an image capture mode. The processed image frames may be displayed on the display unit 506. The image frames processed by the graphic processor 5041 may be stored in the memory 509 (or other storage medium) or transmitted via the radio frequency unit 501 or the network module 502. The microphone 5042 may receive sounds and may be capable of processing such sounds into audio data. The processed audio data may be converted into a format output transmittable to a mobile communication base station via the radio frequency unit 501 in case of the phone call mode.
The mobile terminal 500 also includes at least one sensor 505, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor that adjusts the brightness of the display panel 5061 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 5061 and/or a backlight when the mobile terminal 500 is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), detect the magnitude and direction of gravity when stationary, and can be used to identify the gesture of the mobile terminal (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration identification related functions (such as pedometer and tapping), and the like; the sensor 505 may also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be described in detail herein.
The display unit 506 is used to display information input by the user or information provided to the user. The Display unit 506 may include a Display panel 5061, and the Display panel 5061 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
The user input unit 507 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the mobile terminal. Specifically, the user input unit 507 includes a touch panel 5071 and other input devices 5072. Touch panel 5071, also referred to as a touch screen, may collect touch operations by a user on or near it (e.g., operations by a user on or near touch panel 5071 using a finger, stylus, or any suitable object or attachment). The touch panel 5071 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 510, and receives and executes commands sent by the processor 510. In addition, the touch panel 5071 may be implemented by various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to touch panel 5071, user input unit 507 may include other input devices 5072. In particular, other input devices 5072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail herein.
Further, the touch panel 5071 may be overlaid on the display panel 5061, and when the touch panel 5071 detects a touch operation thereon or nearby, the touch operation is transmitted to the processor 510 to determine the type of the touch event, and then the processor 510 provides a corresponding visual output on the display panel 5061 according to the type of the touch event. Although in fig. 5, the touch panel 5071 and the display panel 5061 are two independent components to implement the input and output functions of the mobile terminal, in some embodiments, the touch panel 5071 and the display panel 5061 may be integrated to implement the input and output functions of the mobile terminal, and is not limited herein.
The interface unit 508 is an interface through which an external device is connected to the mobile terminal 500. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device having an identification module, an audio input/output (I/O) port, a video I/O port, an earphone port, and the like. The interface unit 508 may be used to receive input (e.g., data information, power, etc.) from external devices and transmit the received input to one or more elements within the mobile terminal 500 or may be used to transmit data between the mobile terminal 500 and external devices.
The memory 509 may be used to store software programs as well as various data. The memory 509 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 509 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device.
The processor 510 is a control center of the mobile terminal, connects various parts of the entire mobile terminal using various interfaces and lines, performs various functions of the mobile terminal and processes data by operating or executing software programs and/or modules stored in the memory 509 and calling data stored in the memory 509, thereby integrally monitoring the mobile terminal. Processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 510.
The mobile terminal 500 may further include a power supply 511 (e.g., a battery) for supplying power to various components, and preferably, the power supply 511 is logically connected to the processor 510 through a power management system, so that functions of managing charging, discharging, and power consumption are performed through the power management system.
In addition, the mobile terminal 500 includes some functional modules that are not shown, and thus, are not described in detail herein.
Preferably, an embodiment of the present invention further provides a mobile terminal, which includes a processor 510, a memory 509, and a computer program that is stored in the memory 509 and can be run on the processor 510, and when being executed by the processor 510, the computer program implements each process of the above-mentioned embodiment of the method for reading and writing a disk file, and can achieve the same technical effect, and in order to avoid repetition, details are not described here again.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above-mentioned embodiment of the method for reading and writing a disk file, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a component of' 8230; \8230;" does not exclude the presence of another like element in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (11)

1. A disk file read-write method is applied to a mobile terminal and is characterized by comprising the following steps:
acquiring a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written;
determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition;
executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request;
before the step of obtaining the file read/write request sent by the terminal, the method further includes:
acquiring all files on a physical disk partition;
acquiring the file size corresponding to each file and the physical logic address of each file on the physical disk partition;
generating virtual files with the same size as the corresponding size of each file according to the size of each file;
establishing and storing an association relation among each virtual file, each file and each physical logic address;
establishing a virtual disk partition corresponding to the physical disk partition according to each virtual file; the virtual disk partition is used for simulating a physical disk partition, a mapping relation exists between the physical partition and the virtual partition, and virtual files corresponding to files in the physical disk partition are filled in the virtual disk partition;
sharing the virtual disk partition to the terminal through a designated protocol so that the terminal checks files on the disk partition according to the virtual disk partition and executes read-write operation; the specified protocol includes a USB protocol.
2. The method according to claim 1, wherein the file read/write request further includes a data read/write length and a data read/write offset, and the step of executing a corresponding file read/write operation in the target physical disk partition according to the virtual logical address of the file to be read/written and the file read/write request includes:
determining a target physical logic address on the target physical disk partition according to the virtual logic address and the association relation;
determining a first actual read/write file corresponding to the file to be read/write on the target physical disk partition according to the target physical logical address;
and executing data read/write operation on the first actual read/write file according to the data read/write length and the data read/write offset.
3. The method according to claim 1, wherein before the step of performing the corresponding file read/write operation in the target physical disk partition according to the virtual logical address of the file to be read/written and the file read/write request, the method further comprises:
determining a second actual read/write file corresponding to the file to be read/write according to the target physical disk partition and the virtual logical address;
and executing the corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request under the condition that the file read/write request meets the preset authentication condition.
4. The method according to claim 3, wherein the preset authentication condition includes any one of a read-only condition, a write-only condition, and a read-write condition.
5. A disk file read-write device is applied to a mobile terminal and is characterized by comprising:
the read-write request acquisition module is used for acquiring a file read/write request sent by a terminal; the file read/write request comprises a target virtual disk partition where a file to be read/written is located and a virtual logic address of the file to be read/written;
the physical partition determining module is used for determining a target physical disk partition corresponding to the target virtual disk partition according to the mapping relation between the virtual disk partition and the physical disk partition; the virtual disk partition is used for simulating a physical disk partition, a mapping relation exists between the physical partition and the virtual partition, and virtual files corresponding to files in the physical disk partition are filled in the virtual disk partition;
the read-write operation execution module is used for executing corresponding file read/write operation in the target physical disk partition according to the virtual logic address of the file to be read/written and the file read/write request;
wherein the apparatus further comprises:
the file acquisition module is used for acquiring all files on the physical disk partition;
a file size physical address obtaining module, configured to obtain a file size corresponding to each file, and a physical logical address of each file on the physical disk partition;
the virtual file generating module is used for generating virtual files with the same size corresponding to each file according to the size of each file;
the association relation establishing module is used for establishing and storing association relations among the virtual files, the files and the physical logic addresses;
the virtual disk partition establishing module is used for establishing a virtual disk partition corresponding to the physical disk partition according to each virtual file; filling virtual files corresponding to the files in the physical disk partition in the virtual disk partition;
the virtual disk partition sharing module is used for sharing the virtual disk partition to the terminal through a specified protocol so that the terminal can check files on the disk partition according to the virtual disk partition and execute read-write operation; the specified protocol includes a USB protocol.
6. The apparatus of claim 5, further comprising:
the file acquisition module is used for acquiring all files on the physical disk partition;
the file size physical address acquisition module is used for acquiring the file size corresponding to each file and the physical logic address of each file on the physical disk partition;
the virtual file generating module is used for generating virtual files with the same size corresponding to the files according to the sizes of the files;
the association relation establishing module is used for establishing and storing association relations among the virtual files, the files and the physical logic addresses;
the virtual disk partition establishing module is used for establishing a virtual disk partition corresponding to the physical disk partition according to each virtual file;
and the virtual disk partition sharing module is used for sharing the virtual disk partition to the terminal through a specified protocol.
7. The apparatus of claim 5, wherein the file read/write request further includes a data read/write length and a data read/write offset, and the read/write operation performing module includes:
a target physical address determining submodule, configured to determine a target physical logical address on the target physical disk partition according to the virtual logical address and the association relationship;
a first read-write file determining submodule, configured to determine, according to the target physical logical address, a first actual read/write file, corresponding to the to-be-read/write file, on the target physical disk partition;
and the read-write operation execution sub-module is used for executing data read/write operation on the first actual read/write file according to the data read/write length and the data read/write offset.
8. The apparatus of claim 5, further comprising:
a second read/write file determining module, configured to determine, according to the target physical disk partition and the virtual logical address, a second actual read/write file corresponding to the file to be read/written;
and the authentication success module is used for executing the read-write operation executing module under the condition that the file read/write request meets the preset authentication condition.
9. The apparatus of claim 8, wherein the preset authentication condition comprises any one of a read-only condition, a write-only condition and a read-write condition.
10. A mobile terminal, characterized by comprising a processor, a memory and a computer program stored on the memory and operable on the processor, the computer program, when executed by the processor, implementing the steps of the method for reading and writing a disk file according to any one of claims 1 to 4.
11. A computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the method for reading and writing a disk file according to any one of claims 1 to 4.
CN201910100744.3A 2019-01-31 2019-01-31 Disk file reading and writing method and device Active CN109885257B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910100744.3A CN109885257B (en) 2019-01-31 2019-01-31 Disk file reading and writing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910100744.3A CN109885257B (en) 2019-01-31 2019-01-31 Disk file reading and writing method and device

Publications (2)

Publication Number Publication Date
CN109885257A CN109885257A (en) 2019-06-14
CN109885257B true CN109885257B (en) 2023-01-03

Family

ID=66927560

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910100744.3A Active CN109885257B (en) 2019-01-31 2019-01-31 Disk file reading and writing method and device

Country Status (1)

Country Link
CN (1) CN109885257B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112000589A (en) * 2020-07-13 2020-11-27 北京奇艺世纪科技有限公司 Data writing method, data reading device and electronic equipment
CN112241394B (en) * 2020-10-15 2022-08-02 浪潮商用机器有限公司 Index node IO statistical method, tool, equipment and storage medium
CN113434470B (en) * 2021-06-24 2024-03-19 华云数据控股集团有限公司 Data distribution method and device and electronic equipment
CN114238232B (en) * 2021-12-15 2024-04-02 南方电网电力科技股份有限公司 Intelligent ammeter file reading and writing system, method, equipment and medium
CN115858407B (en) * 2023-02-16 2023-05-16 浪潮电子信息产业股份有限公司 Data storage method, device, equipment, readable storage medium and server
CN117076337B (en) * 2023-10-17 2024-02-02 北京开源芯片研究院 Data transmission method and device, electronic equipment and readable storage medium
CN117707437A (en) * 2024-02-06 2024-03-15 济南浪潮数据技术有限公司 Virtual disk storage method and device based on distributed storage system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6948044B1 (en) * 2002-07-30 2005-09-20 Cisco Systems, Inc. Methods and apparatus for storage virtualization
CN102622352A (en) * 2011-01-26 2012-08-01 深圳市闪联信息技术有限公司 Method, server and system for achieving shared file
CN106598496A (en) * 2016-12-08 2017-04-26 蓝信工场(北京)科技有限公司 Method and device for constructing virtual magnetic disk and processing data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6948044B1 (en) * 2002-07-30 2005-09-20 Cisco Systems, Inc. Methods and apparatus for storage virtualization
CN102622352A (en) * 2011-01-26 2012-08-01 深圳市闪联信息技术有限公司 Method, server and system for achieving shared file
CN106598496A (en) * 2016-12-08 2017-04-26 蓝信工场(北京)科技有限公司 Method and device for constructing virtual magnetic disk and processing data

Also Published As

Publication number Publication date
CN109885257A (en) 2019-06-14

Similar Documents

Publication Publication Date Title
CN109885257B (en) Disk file reading and writing method and device
CN109768926B (en) Data processing method, terminal equipment and computer readable storage medium
CN108073343B (en) display interface adjusting method and mobile terminal
CN110324489B (en) Method for displaying multiple application windows by mobile terminal and mobile terminal
CN109240577B (en) Screen capturing method and terminal
CN109343788B (en) Operation control method of mobile terminal and mobile terminal
CN108257104B (en) Image processing method and mobile terminal
CN110990172A (en) Application sharing method, first electronic device and computer-readable storage medium
CN108984066B (en) Application icon display method and mobile terminal
US20230014409A1 (en) Detection result output method, electronic device and medium
US20220360709A1 (en) Mobile terminal, shooting mode detection method, and storage medium
CN109144723B (en) Method and terminal for allocating storage space
US20220321120A1 (en) Touch button, control method, and electronic device
CN111651387B (en) Interface circuit and electronic equipment
US11418945B2 (en) Information processing method for RF device and mobile terminal
CN111026674A (en) Data storage method and electronic equipment
CN111061404A (en) Control method and first electronic device
CN111131607A (en) Information sharing method, electronic equipment and computer readable storage medium
CN107729100B (en) Interface display control method and mobile terminal
CN109889568B (en) Data export method, server and system
CN111163227B (en) Sharing method and electronic equipment
CN110796438B (en) Message sending method and mobile terminal
CN111522613A (en) Screen capturing method and electronic equipment
CN115657943A (en) Data processing method, device and equipment for thin volume of storage system and storage medium
CN110825682B (en) USB control method and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant