CN114968121A - Method and device for reading data in storage medium, electronic equipment and medium - Google Patents

Method and device for reading data in storage medium, electronic equipment and medium Download PDF

Info

Publication number
CN114968121A
CN114968121A CN202210631076.9A CN202210631076A CN114968121A CN 114968121 A CN114968121 A CN 114968121A CN 202210631076 A CN202210631076 A CN 202210631076A CN 114968121 A CN114968121 A CN 114968121A
Authority
CN
China
Prior art keywords
partition
file system
identifier
file
storage medium
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.)
Pending
Application number
CN202210631076.9A
Other languages
Chinese (zh)
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.)
Beijing Superred Technology Co Ltd
Original Assignee
Beijing Superred Technology 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 Beijing Superred Technology Co Ltd filed Critical Beijing Superred Technology Co Ltd
Priority to CN202210631076.9A priority Critical patent/CN114968121A/en
Publication of CN114968121A publication Critical patent/CN114968121A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • G06F21/562Static detection
    • G06F21/565Static detection by checking file integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools

Abstract

The method comprises the steps of obtaining the number of logical partitions in the mobile storage medium and the capacity of each logical partition when access of the mobile storage medium is detected, determining the starting physical sector of at least one logical partition based on the number of the logical partitions and the capacity of each logical partition, determining the partition type of at least one logical partition based on the starting physical sector of at least one logical partition, determining the designated physical sector corresponding to at least one logical partition according to the partition type, storing identification information in the designated physical sector, and determining the file system type corresponding to at least one logical partition based on the identification information. The method and the device have the effect of facilitating reading of the file system which cannot be identified by the computer equipment.

Description

Method and device for reading data in storage medium, electronic equipment and medium
Technical Field
The present application relates to the field of data storage, and in particular, to a method and an apparatus for reading data in a storage medium, an electronic device, and a medium.
Background
The Windows system and the Linux system are two commonly used systems. However, the file systems that can be recognized by the two systems are different, and when the mobile storage medium is used for storing data, a file system that cannot be recognized by the Windows system or a file system that cannot be recognized by the Linux system may exist in the mobile storage medium.
At present, when a file in a mobile storage medium is read, the mobile storage medium needs to be connected with a computer device, and due to the limitation of a computer device system, the computer device cannot identify a file system which cannot be identified by itself, so that the file in the file system cannot be read.
Disclosure of Invention
In order to facilitate reading of files of a file system which cannot be identified by computer equipment, the application provides a method, a device, electronic equipment and a medium for reading data in a storage medium.
In a first aspect, the present application provides a method for reading data in a storage medium, which adopts the following technical solutions:
a method of reading data in a storage medium, comprising:
when detecting that a mobile storage medium is accessed, acquiring the number of logical partitions in the mobile storage medium and the capacity of each logical partition;
determining a starting physical sector of at least one logical partition based on the number of logical partitions and the capacity of each logical partition;
determining a partition type of the at least one logical partition based on a starting physical sector of the at least one logical partition;
determining a designated physical sector corresponding to the at least one logical partition according to the partition type, wherein identification information is stored in the designated physical sector;
and determining a file system type corresponding to the at least one logical partition based on the identification information.
By adopting the technical scheme, when the access of the mobile storage medium is detected, the file in the mobile storage medium is read or written, so that the number of at least one logic partition and the capacity of at least one logic partition in the mobile storage medium are obtained. After the capacity of the first logical partition is obtained, because the initial physical sector corresponding to the first logical partition starts from the physical sector number 0, the address of the last physical sector corresponding to the first logical partition can be determined according to the capacity of the first logical partition, that is, when the address of the initial physical sector of the current logical partition is determined, the address can be determined according to the last physical sector corresponding to the last logical partition of the current logical partition, so that the corresponding partition type can be determined based on the initial physical sector of each logical partition, and further, the identification information can be obtained according to the specified physical sector of each logical partition, so that the file system type of the logical partition is determined, that is, the file in the file system can be read, and the user can conveniently read the file in the mobile storage medium.
In another possible implementation manner, determining the partition type of any logical partition based on the starting physical sector of the logical partition includes:
reading a starting physical sector corresponding to any logic partition to obtain first data information of the starting physical sector, wherein the first data information at least comprises first specified byte data and second specified byte data;
if the data of the first designated byte belongs to a first preset identifier, reading a next physical sector of the initial physical sector to obtain second data information;
if the data of the specified byte in the second data information belongs to a second preset identifier, judging whether any logic partition has a sub-logic partition;
if yes, determining that any logic partition belongs to the GPT partition;
if the data of the second specified byte does not exist and is not 0, determining that any logic partition belongs to an MBR partition;
if not, and the data of the second designated byte is 0, determining that any one of the logical partitions belongs to the no-partition type.
By adopting the technical scheme, the starting physical sector is read to obtain the first data information of the starting physical sector, the first data information comprises part of data representing the partition type, namely if the data of the first specified byte belongs to the first preset identifier, the logic partition possibly belongs to the GPT partition. And reading the next physical sector of the starting physical sector to obtain second data information, wherein the second data information comprises another part of data representing the partition type, namely if the data of the specified byte in the second data information belongs to a second preset identifier and the data of the first specified byte belongs to a first preset identifier, judging whether the logic partition has a sub logic partition, and if so, determining that the logic partition belongs to a GPT partition.
If there is no child logical partition and the second specified byte of data is not 0, then it is determined that the logical partition belongs to the MBR partition, and if there is no child logical partition and the second specified byte of data is 0, then it is determined that the logical partition does not belong to the MBR partition, i.e., the logical partition belongs to the partition-less type. It is more accurate to determine the partition type by reading the starting physical sector and based on whether there is a child logical partition for that logical partition.
In another possible implementation manner, the first data information includes a first identifier, and a designated physical sector corresponding to any logical partition is determined according to the partition type, where the designated physical sector stores identifier information; determining a file system type corresponding to any one of the logical partitions based on the identification information, including:
if any logical partition belongs to a non-partition type, determining that the starting physical sector is the designated physical sector, and if the first identifier belongs to a first preset file system identifier, determining that the file system type of any logical partition is a file system type corresponding to the first identifier in the first preset file system identifier, where the first preset file system identifier includes: an identifier corresponding to an NTFS file system, an identifier corresponding to a FAT12 file system, an identifier corresponding to a FAT16 file system, an identifier corresponding to a FAT32 file system and an identifier corresponding to an exFAT file system; or the like, or, alternatively,
if any logic partition belongs to the GPT partition or the MBR partition, reading a designated physical sector corresponding to the GPT partition or a designated physical sector corresponding to the MBR partition to obtain the initial logic sector address of at least one sub-logic partition and the capacity of at least one sub-logic partition so as to determine at least one target sub-logic partition;
reading the initial logic sector of each target sub logic partition to obtain a second identifier corresponding to each target sub logic partition;
if the second identifier belongs to the first preset file system identifier, determining the file system type of each target sub-logical partition as the file system type corresponding to the second identifier in the first preset file system identifier;
if the second identifier does not belong to the first preset file system identifier, reading a designated logical sector corresponding to each target sub-logical partition except for the initial logical sector to obtain a third identifier;
if the third identifier belongs to a second preset file system identifier, determining that the file system type of each target sub-logical partition is a file system type corresponding to the third identifier in the second preset file system identifier, where the second preset file system identifier includes: the identifier corresponding to the EXT2 file system, the identifier corresponding to the EXT3 file system and the identifier corresponding to the EXT4 file system.
By adopting the above technical scheme, if the logical partition belongs to the non-partition type, it is indicated that the logical partition does not have a sub-logical partition, and therefore the file system type of the logical partition can be determined according to the first preset file system identifier of the first identifier in the first data information.
If the logical partition belongs to an MBR partition or a GPT partition, reading the appointed physical sector to obtain the initial logical sector address of at least one sub logical partition and the capacity of at least one sub logical partition, thereby being capable of determining at least one target sub logical sector. And if the second identifier belongs to the first preset file system identifier, determining that the target sub-logic partition belongs to one of an identifier corresponding to an NTFS file system, an identifier corresponding to an FAT12 file system, an identifier corresponding to an FAT16 file system, an identifier corresponding to an FAT32 file system and an identifier corresponding to an exFAT file system. If the second identifier does not belong to the first preset file system identifier, reading the specified logical sectors except the initial logical sector to obtain a third identifier, and if the third identifier belongs to the second preset file system identifier, determining that the file system of the target sub-logical partition belongs to one of an EXT2 file system, an EXT3 file system and an EXT4 file system.
In another possible implementation manner, the determining, based on the identification information, a file system type corresponding to the at least one logical partition further includes:
acquiring a file in the at least one logical partition;
storing the file;
and when an instruction for sending the file is received, sending the file.
By adopting the technical scheme, after the file system type is determined, the files in the logic partition are obtained and stored, when the file sending instruction sent by the computer equipment is received, the computer equipment is indicated to allow the files to be sent, the files can be sent, and the files can be sent by receiving the file sending instruction, so that the files in the mobile storage medium can be read more orderly.
In another possible implementation manner, the method further includes:
if the request write-in instruction is detected, key information is obtained;
and if the key information is matched with the preset key information, determining that the state of the mobile storage medium is a writing state.
By adopting the technical scheme, if a request write-in instruction is received, key information transmitted by the computer equipment is acquired, the key information is matched with preset key information, if the matching is successful, the operation of requesting write-in is determined to be legal, and the state of the storage medium is determined to be a write-in state. The method comprises the steps of obtaining the secret key and comparing the obtained secret key with a preset secret key to determine whether to enter a writing state or not, so that the use of the mobile storage medium is safer.
In another possible implementation manner, when the access of the mobile storage medium is detected, the method further includes:
judging whether a target file system type exists in all file system types of the mobile storage medium, wherein the target file system type comprises a file system type which can be identified by a Windows system and a Linux system;
and if so, outputting a signal for indicating that the target file system type exists in the mobile storage medium.
By adopting the technical scheme, after the mobile storage medium is accessed, whether the target file system type exists in all the file system types in the mobile storage medium is judged, if yes, a signal representing the target file system type existing in the mobile storage medium is output, so that the computer equipment can know that the target file system type exists in the mobile storage medium, further, a user can know that the target file system type exists in the mobile storage medium conveniently, the user can store the file through the target file system type conveniently, when the mobile storage medium is accessed into the Windows system computer equipment or the Linux system computer equipment independently subsequently, the file can be read, and the subsequent file reading is more convenient.
In another possible implementation, the method further comprises at least one of:
if the mobile storage medium is in a reading state, acquiring the file name of the file to be read, judging whether the file name of the file to be read is matched with a preset virus name or not, and if so, controlling to stop reading the file to be read;
and if the mobile storage medium is in a writing state, acquiring the file name of the file to be written, judging whether the file name of the file to be written is matched with the preset virus name, and if so, deleting the file to be written.
By adopting the technical scheme, when the mobile storage medium is in a reading state, the file name of the file to be read is obtained, if the file name is successfully matched with the preset virus name, the file to be read is indicated as a virus file, and the reading of the file to be read is controlled to stop, so that the possibility that computer equipment enters viruses is reduced. When the mobile storage medium is in a writing state, the file name to be written is obtained, if the file name preset virus name matching is successful, the file to be written is indicated as a virus file, and the file to be written is controlled to be deleted, so that the file cannot be written into the mobile storage medium, and the risk of virus infection of the mobile storage medium is reduced.
In a second aspect, the present application provides an apparatus for reading data in a storage medium, which adopts the following technical solutions:
an apparatus for reading data in a storage medium, comprising:
the information acquisition module is used for acquiring the number of the logical partitions in the mobile storage medium and the capacity of each logical partition when the access of the mobile storage medium is detected;
a starting physical sector determination module for determining a starting physical sector of at least one logical partition based on the number of logical partitions and the capacity of each logical partition;
a partition type determination module to determine a partition type of the at least one logical partition based on a starting physical sector of the at least one logical partition;
the identification determining module is used for determining a designated physical sector corresponding to the at least one logic partition according to the partition type, and identification information is stored in the designated physical sector;
and the file system determining module is used for determining the file system type corresponding to the at least one logic partition based on the identification information.
By adopting the technical scheme, when the access of the mobile storage medium is detected, the file in the mobile storage medium is read or written, so that the information acquisition module acquires the number of at least one logic partition and the capacity of at least one logic partition in the mobile storage medium. After the capacity of the first logical partition is obtained, because the initial physical sector corresponding to the first logical partition starts from the physical sector number 0, the address of the last physical sector corresponding to the first logical partition can be determined according to the capacity of the first logical partition, that is, the initial physical sector determining module can determine the address of the last physical sector corresponding to the last logical partition of the current logical partition according to the last physical sector corresponding to the last logical partition of the logical partition when determining the address of the initial physical sector of the current logical partition, the partition type determining module can determine the corresponding partition type based on the initial physical sector of each logical partition, and the identification determining module can obtain the identification information according to the specified physical sector of each logical partition, so that the file system determining module can determine the file system type of the logical partition, that is, the file in the file system can be read, and further, the user can read the files in the mobile storage medium conveniently.
In another possible implementation manner, when determining the partition type of any logical partition based on the starting physical sector of any logical partition, the partition type determination module is specifically configured to:
reading a starting physical sector corresponding to any logic partition to obtain first data information of the starting physical sector, wherein the first data information at least comprises first specified byte data and second specified byte data;
if the data of the first designated byte belongs to a first preset identifier, reading a next physical sector of the initial physical sector to obtain second data information;
if the data of the specified byte in the second data information belongs to a second preset identifier, judging whether any logic partition has a sub-logic partition;
if yes, determining that any logic partition belongs to the GPT partition;
if the data of the second specified byte does not exist and is not 0, determining that any logic partition belongs to an MBR partition;
if not, and the data of the second specified byte is 0, determining that any one of the logical partitions belongs to the no-partition type.
In another possible implementation manner, the first data information includes a first identifier, and the identifier determining module and the file system determining module determine, according to the partition type, an assigned physical sector corresponding to any logical partition, where the assigned physical sector stores the identifier information; when determining the file system type corresponding to any logical partition based on the identification information, the method is specifically configured to:
if any logical partition belongs to a non-partition type, determining that the starting physical sector is the designated physical sector, and if the first identifier belongs to a first preset file system identifier, determining that the file system type of any logical partition is a file system type corresponding to the first identifier in the first preset file system identifier, where the first preset file system identifier includes: an identifier corresponding to an NTFS file system, an identifier corresponding to a FAT12 file system, an identifier corresponding to a FAT16 file system, an identifier corresponding to a FAT32 file system and an identifier corresponding to an exFAT file system; or the like, or, alternatively,
if any logic partition belongs to a GPT partition or an MBR partition, reading a designated physical sector corresponding to the GPT partition or a designated physical sector corresponding to the MBR partition, and obtaining the initial logical sector address of at least one sub-logic partition and the capacity of at least one sub-logic partition so as to determine at least one target sub-logic partition;
reading the initial logic sector of each target sub logic partition to obtain a second identifier corresponding to each target sub logic partition;
if the second identifier belongs to the first preset file system identifier, determining the file system type of each target sub-logical partition as the file system type corresponding to the second identifier in the first preset file system identifier;
if the second identifier does not belong to the first preset file system identifier, reading a designated logical sector corresponding to each target sub-logical partition except for the initial logical sector to obtain a third identifier;
if the third identifier belongs to a second preset file system identifier, determining that the file system type of each target sub-logical partition is a file system type corresponding to the third identifier in the second preset file system identifier, where the second preset file system identifier includes: the file system identifier comprises an identifier corresponding to the EXT2 file system, an identifier corresponding to the EXT3 file system and an identifier corresponding to the EXT4 file system.
In another possible implementation manner, the apparatus further includes:
the file acquisition module is used for acquiring files in the at least one logic partition;
the storage module is used for storing the file;
and the file sending module is used for sending the file when receiving the instruction of sending the file.
In another possible implementation manner, the apparatus further includes:
the key obtaining module is used for obtaining key information when a request write instruction is detected;
and the state determining module is used for determining that the state of the mobile storage medium is a writing state when the key information is matched with the preset key information.
In another possible implementation manner, the apparatus further includes:
the judging module is used for judging whether a target file system type exists in all file system types of the mobile storage medium, wherein the target file system type comprises a file system type which can be identified by a Windows system and a Linux system;
and the signal output module is used for outputting a signal for representing the existence of the target file system type in the mobile storage medium when the target file system type exists.
In another possible implementation, the apparatus further includes at least one of a control module and a deletion module:
the control module is used for acquiring the file name of the file to be read when the mobile storage medium is in a reading state, judging whether the file name of the file to be read is matched with a preset virus name or not, and controlling to stop reading the file to be read if the file name of the file to be read is matched with the preset virus name;
and the deleting module is used for acquiring the file name of the file to be written when the mobile storage medium is in a writing state, judging whether the file name of the file to be written is matched with the preset virus name or not, and deleting the file to be written if the file name of the file to be written is matched with the preset virus name.
In a third aspect, the present application provides an electronic device, which adopts the following technical solutions:
an electronic device, comprising:
one or more processors;
a memory;
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, the one or more application programs configured to: a method of reading data from a storage medium according to any one of the possible implementations of the first aspect is performed.
In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solutions:
a computer-readable storage medium, which, when executed in a computer, causes the computer to perform a method of reading data in a storage medium according to any one of the first aspect.
In summary, the present application includes at least one of the following beneficial technical effects:
1. when the access of the mobile storage medium is detected, the file in the mobile storage medium is read or written, so that the number of at least one logical partition and the capacity of at least one logical partition in the mobile storage medium are obtained. After the capacity of the first logical partition is obtained, because the initial physical sector corresponding to the first logical partition starts from the physical sector number 0, the address of the last physical sector corresponding to the first logical partition can be determined according to the capacity of the first logical partition, that is, when the address of the initial physical sector of the current logical partition is determined, the address can be determined according to the last physical sector corresponding to the last logical partition of the current logical partition, so that the corresponding partition type can be determined based on the initial physical sector of each logical partition, and further, the identification information can be obtained according to the specified physical sector of each logical partition, so that the file system type of the logical partition is determined, that is, the file in the file system can be read, and the user can conveniently read the file in the mobile storage medium;
2. when the mobile storage medium is in a reading state, the file name of the file to be read is obtained, if the file name is successfully matched with the preset virus name, the file to be read is indicated as a virus file, and the file to be read is controlled to stop being read, so that the possibility that computer equipment enters viruses is reduced. When the mobile storage medium is in a writing state, the file name to be written is obtained, if the file name preset virus name matching is successful, the file to be written is indicated as a virus file, and the file to be written is controlled to be deleted, so that the file cannot be written into the mobile storage medium, and the risk of virus infection of the mobile storage medium is reduced.
Drawings
Fig. 1 is a flowchart illustrating a method for reading data in a storage medium according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of an apparatus for reading data from a storage medium according to an embodiment of the present application.
Fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a reading system for a removable storage medium according to an embodiment of the present application.
Detailed Description
The present application is described in further detail below with reference to the attached drawings.
A person skilled in the art, after reading the present specification, may make modifications to the present embodiments as necessary without inventive contribution, but only within the scope of the claims of the present application are protected by patent laws.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. 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 application.
In addition, the term "and/or" herein is only one kind of association relationship describing the association object, and means that there may be three kinds of relationships, for example, a and/or B, and may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship, unless otherwise specified.
The embodiments of the present application will be described in further detail with reference to the drawings attached hereto.
The embodiment of the application provides a method for reading data in a storage medium, which is executed by an electronic device, wherein the electronic device is applied between a computer device and a mobile storage medium and is respectively in communication connection with the computer device and the mobile storage medium. As shown in fig. 1, the method includes step S101, step S102, step S103, step S104, and step S105, wherein,
step S101, when the access of the mobile storage medium is detected, the number of the logical partitions in the mobile storage medium and the capacity of each logical partition are acquired.
For the embodiment of the application, two interfaces can be arranged on the electronic equipment. One interface is connected with the mobile storage medium, and the other interface is connected with the computer equipment. The two interfaces can be a USB interface, a T-TYPE interface, a TYPE-C interface and the like. When the portable electronic device is used, one end of the electronic device is connected with the computer device through the interface, and the other end of the electronic device is connected with the mobile storage medium through the interface. The electronic equipment can judge whether the mobile storage medium is accessed to the electronic equipment by detecting the level condition of the interface, and when the electronic equipment detects that the level of the interface changes, the electronic equipment is indicated to be accessed to the mobile storage medium.
After detecting that the mobile storage medium is connected to the electronic device, the electronic device may send a setup instruction to the mobile storage medium to enumerate relevant information of the mobile storage medium. For example, the related information of the mobile storage medium, such as a device descriptor, an interface descriptor, a port descriptor, a string descriptor, setting the configuration of the storage medium and the interface, allocating the address of the storage medium and the configuration descriptor, etc., is obtained by accessing a chip in which the related information is stored in the mobile storage medium.
After the electronic device acquires the information related to the removable storage medium, an instruction to acquire the number of logical partitions may be sent to the removable storage medium, for example, an instruction of a1 FE 000000000100 may be sent to the removable storage medium, so as to acquire the number of logical partitions in the removable storage medium. The electronic device sends standard SCSI commands to the mobile storage medium according to the number of logical partitions to acquire the capacity of each logical partition. After the capacity of each logical partition is obtained, the starting physical address of each logical partition can be conveniently determined by combining the number of the logical partitions subsequently.
Step S102, determining a starting physical sector of at least one logical partition based on the number of logical partitions and the capacity of each logical partition.
For the embodiment of the present application, the starting physical sector address of each logical partition can be obtained according to the capacity of each logical partition and the number of logical partitions. For example, the mobile storage medium has two logical partitions, the first physical sector of the first logical partition is physical sector number 0, and assuming that the capacity of acquiring the first logical partition is 100 physical sectors, the address of the physical sector at the end of the logical partition is physical sector number 99, that is, the first physical sector of the second logical partition is physical sector number 100.
Step S103, determining the partition type of at least one logical partition based on the starting physical sector of the at least one logical partition.
For the embodiment of the application, after the electronic device determines the starting physical sector address of each logical partition, because the data in the starting physical sector and the designated physical sector can represent the partition type of the logical partition, the partition type corresponding to the logical partition can be determined according to the starting physical sector and the designated physical sector. Partition types may include non-partition types, GPT partitions, and MBR partitions. After the partition type corresponding to the logical partition is determined, the file system type in the logical partition can be conveniently determined subsequently.
And step S104, determining the designated physical sector corresponding to at least one logic partition according to the partition type.
Wherein the specified physical sector has an identifier stored therein.
For the embodiment of the application, the data about the file system type is recorded in the designated physical sector corresponding to the logical partition, so that after the partition type is determined, the designated physical sector corresponding to the partition type is determined according to the partition type corresponding to the logical partition, and the identification information about the file system type can be obtained.
Step S105, determining a file system type corresponding to at least one logical partition based on the identification information.
For the embodiment of the application, the identification information is used for representing the file system type, so that after the identification information is obtained, the file system type corresponding to the logical partition can be determined according to the identification information. After the electronic equipment determines the file system type, the electronic equipment can identify the file system type in the mobile storage medium, and then can read files in the file system. The electronic equipment can assist the computer equipment to identify the file system which cannot be identified by the computer equipment in the mobile storage medium, so that the effect of reading files in the file system which cannot be identified is achieved.
A possible implementation manner of the embodiment of the present application, determining a partition type of any logical partition based on a starting physical sector of any logical partition, specifically including step S1031 (not shown in the figure), step S1032 (not shown in the figure), step S1033 (not shown in the figure), step S1034 (not shown in the figure), step S1035 (not shown in the figure), and step S1036 (not shown in the figure), where, when the number of logical partitions is two or more, each logical partition may determine a partition type corresponding to each logical partition in a manner corresponding to the embodiment of steps S1031 to S1035, where,
step S1031, reading the starting physical sector corresponding to any logical partition to obtain the first data information of the starting physical sector.
The first data information at least comprises first specified bytes of data and second specified bytes of data.
For the embodiments of the present application, part of the data for determining the partition type to which the logical partition belongs is recorded in the starting physical sector. The electronic device reads the initial physical sector to obtain all data in the initial physical sector, namely the first data information. For example, the starting physical sector has 512 bytes, and the first data information includes 512 bytes and data corresponding to each byte. The first designated byte and the second designated byte are each a designated byte of a specific length of 512 bytes.
Step S1032, if the data of the first designated byte belongs to the first preset identifier, the next physical sector of the starting physical sector is read to obtain the second data information.
For the embodiment of the present application, taking 512 bytes in total for the starting physical sector as an example, assuming that the first predetermined identifier includes "EE" and "55 AA", the first specified byte is byte number 450 and byte numbers 511 and 512 in the first data information. The electronic device determines whether the data of the first specified byte is "EE, 55 and AA", and if the first specified byte belongs to the first predetermined identifier, it indicates that the partition type of the logical partition may be a GPT partition.
If the partition type of the logical partition is determined to be a GPT partition through the first data information, in order to further judge the partition type more accurately, the electronic device reads the next physical sector of the initial physical sector to obtain second data information. The electronic device further determines whether the partition type of the logical partition is a GPT partition based on the second data information.
Step S1033, if the data in the designated byte in the second data information belongs to the second preset identifier, determining whether any logical partition has a sub logical partition.
Step S1034, if yes, determining that any logic partition belongs to the GPT partition.
For the embodiment of the present application, it is assumed that the second preset identifier is an identifier corresponding to an "EFI PART" character, and the specified bytes of the second data information are the first eight bytes in the second data information. The electronic device determines whether the specified byte in the second data message belongs to the identifier corresponding to the "EFI PART" character. If so, it indicates that the partition type of the logical partition is more likely to be a GPT partition. The electronic equipment judges whether the logical partition has a sub-logical partition, and if so, the partition type of the logical partition is the GPT partition. If the sub-logical partition does not exist, the file system type is not available, and further the logical partition does not belong to the GPT partition.
Wherein, whether the sub-logical partition exists can be judged by reading the appointed physical sector. For example, reading physical sector number 2 to physical sector number 33, if the capacity and the starting physical sector address of the sub logical partition can be read from physical sector number 2 to physical sector number 33, it is determined that the sub logical partition exists, and it can be determined that the partition type is the GPT partition.
In step S1035, if there is no data in the second designated byte and the data in the second designated byte is not 0, it is determined that any logical partition belongs to the MBR partition.
For the embodiment of the present application, if the electronic device determines that the logical partition does not have the sub-logical partition, it determines whether the data of the second designated byte is 0, and if the second designated byte is from byte 459 to byte 462, from byte 475 to byte 478, from byte 491 to byte 494, and from byte 507 to byte 510 in the first data information, if the data of the second designated byte is not 0, that is, if the second designated byte has valid data, it determines that the partition type of the logical partition is the MBR partition.
In step S1036, if the data in the second designated byte is 0, it is determined that any logical partition belongs to the non-partition type.
For the embodiment of the present application, if there is no sub-logical partition in the logical partition, and the data of the second specified byte is 0, it is determined that the logical partition does not belong to the GPT partition, nor does it belong to the MBR partition, that is, the logical partition is a non-partition type, that is, the file system type of the logical partition can be determined by reading the physical sector.
In a possible implementation manner of the embodiment of the application, the first data information includes a first identifier, an assigned physical sector corresponding to any logical partition is determined according to a partition type, and the identifier information is stored in the assigned physical sector; determining a file system type corresponding to any logical partition based on the identification information, specifically including step SA (not shown in the figure), when the number of logical partitions is two or more, each logical partition may determine the designated physical sector corresponding to each logical partition in a manner corresponding to the embodiment of step SA, wherein,
and step SA, if any logical partition belongs to the partition-free type, determining the initial physical sector as the designated physical sector, and if the first identifier belongs to the first preset file system identifier, determining the file system type of any logical partition as the file system type corresponding to the first identifier in the first preset file system identifier.
Wherein, the first preset file system identifier comprises: an identifier corresponding to an NTFS file system, an identifier corresponding to a FAT12 file system, an identifier corresponding to a FAT16 file system, an identifier corresponding to a FAT32 file system, and an identifier corresponding to an exFAT file system.
For the embodiment of the application, if the partition type of the logical partition is a partition-free type, the electronic device determines the starting physical sector as the designated physical sector, and the first identifier representing the file system type is located in the first data information, so that the electronic device determines whether the first identifier belongs to the first preset file system identifier. If the file system belongs to the first identifier, the file system of the logical partition is indicated as the file system corresponding to the first identifier. The first preset file system identifier includes an NTFS file system and an identifier corresponding to the FAT file system. And if the first identifier belongs to an identifier corresponding to an NTFS file system or an identifier corresponding to a FAT file system, determining that the file system of the logical partition is the NTFS file system or the FAT file system.
In a possible implementation manner of the embodiment of the application, an assigned physical sector corresponding to any logical partition is determined according to the partition type, and identification information is stored in the assigned physical sector; determining a file system type corresponding to any logical partition based on the identification information, and specifically including step SB (not shown in the figure), step SC (not shown in the figure), step SD (not shown in the figure), step SE (not shown in the figure), and step SF (not shown in the figure), wherein when the number of logical partitions is two or more, each logical partition can determine the file system type corresponding to each logical partition in a manner corresponding to the embodiment from step SB to step SF, wherein,
and step SB, if any logic partition belongs to the GPT partition or the MBR partition, reading a designated physical sector corresponding to the GPT partition or a designated physical sector corresponding to the MBR partition, and obtaining the initial logic sector address of at least one sub-logic partition and the capacity of at least one sub-logic partition so as to determine at least one target sub-logic partition.
For the embodiment of the present application, if a logical partition belongs to an MBR partition or a GPT partition, the corresponding designated physical sector needs to be read, so as to obtain the starting physical sector address of at least one sub-logical partition and the capacity of each sub-logical partition. For example, the GPT partition reads physical sector number 2 to physical sector number 33, and the MBR partition reads physical sector number 2 to physical sector number 5.
And determining a target sub-logical partition according to the initial physical sector address of each sub-logical partition and the capacity of each sub-logical partition. After the target sub-logical partitions are determined, the file system type corresponding to each target sub-logical partition can be determined.
And step SC, reading the initial logical sector of each target sub-logical partition to obtain a second identifier corresponding to each target sub-logical partition.
For the embodiment of the application, after the target sub-logical partitions are determined, the starting logical sector of any target sub-logical partition is read, and the identifier of the file system type of the target sub-logical partition, that is, the second identifier, is recorded in the starting logical sector.
And step SD, if the second identification belongs to the first preset file system identification, determining the file system type of each target sub-logic partition as the file system type corresponding to the second identification in the first preset file system identification.
For the embodiment of the application, the electronic device determines whether the second identifier belongs to the first preset file system identifier. Assuming that the second identifier belongs to the identifier corresponding to the NTFS file system, the electronic device may determine that the file system of the target sub-logical partition is the NTFS file system.
In the embodiment of the present application, if the identifier of MSDOS5.0 appears in the starting logical sector, it also indicates that the target logical partition belongs to the FAT32 file system. MSDOS5.0 identification serves to assist in determining the FAT32 file system.
And step SE, if the second identifier does not belong to the first preset file system identifier, reading the designated logical sectors corresponding to each target sub-logical partition except the initial logical sector to obtain a third identifier.
For the embodiment of the application, the electronic device determines that the second identifier does not belong to the first preset file system identifier. The file system of the target sub-logical partition is not the file system corresponding to the first preset file system identifier. The electronic device reads the designated logical sector for the third identification, e.g., reads the third logical sector.
And step SF, if the third identification belongs to a second preset file system identification, determining the file system type of each target sub logic partition as the file system type corresponding to the third identification in the second preset file system identification. Wherein the second preset file system identifier includes: the file system identifier comprises an identifier corresponding to the EXT2 file system, an identifier corresponding to the EXT3 file system and an identifier corresponding to the EXT4 file system.
For the embodiment of the application, the electronic device determines whether the third identifier belongs to a second preset file system identifier. The second file system identifier includes an identifier corresponding to the EXT2 file system, an identifier corresponding to the EXT3 file system, and an identifier corresponding to the EXT4 file system. Assuming that the third identifier belongs to the identifier corresponding to the EXT4 file system, the electronic device may determine that the file system of the target sub logical partition is the EXT4 file system.
In the examples of the present application. If the second identifier does not belong to the first preset file system identifier and the third identifier does not belong to the second preset file system identifier, it is indicated that a file system which cannot be identified by the electronic device exists in the mobile storage medium.
In order to transmit the file in the file system that cannot be identified by the computer device, a possible implementation manner of the embodiment of the present application includes, after step S105, step S106 (not shown), step S107 (not shown), and step S108 (not shown), wherein,
step S106, obtaining the file in at least one logic partition.
For the embodiment of the application, after the file system of at least one logical partition is determined, the electronic device may obtain the file from the at least one logical partition according to the path corresponding to the file.
Step S107, storing the file.
For the embodiment of the application, after the electronic device acquires the file in the logical partition, the file is stored, for example, in a local storage of the electronic device. The local Memory may be a Static Random-Access Memory (SRAM), or other types of memories.
And step S108, when receiving the instruction of sending the file, sending the file.
For the embodiment of the application, when the electronic device acquires the file sending instruction transmitted by the computer device, it is stated that a user needs to read the file into the computer device for viewing. The file reading method comprises the steps of obtaining a file sending instruction transmitted by computer equipment, and transmitting files according to the file sending instruction, so that the files are read more orderly.
In a possible implementation manner of the embodiment of the present application, the method further includes step S109 (not shown in the figure) and step S110 (not shown in the figure), wherein the step S109 may be executed after the step S101, wherein
In step S109, if the write request command is detected, key information is obtained.
For the embodiment of the application, the request writing instruction is an instruction for requesting to write a file into the removable storage medium from the computer device, and the request writing instruction may be an instruction triggered by a user through an input device such as a mouse and a keyboard, and is transmitted to the electronic device. And the electronic equipment detects the request writing instruction and acquires the key information transmitted by the computer equipment. The key information is information input by a user through input devices such as a mouse, a keyboard, a touch pad, and the like, and is transmitted from the computer device to the electronic device.
In step S110, if the key information matches the preset key information, it is determined that the state of the removable storage medium is a write state.
For the embodiment of the present application, it is assumed that the preset key information is "ABC 123", the electronic device compares the acquired key information with the preset key information, and if the acquired key information is consistent with the preset key information, it indicates that the requested write operation is legal, and the electronic device determines that the state of the removable storage medium is a write state, so that a file in the computer device can be written in the removable storage medium. And if the key information is inconsistent with the preset key information, the request for writing operation is illegal, and the mobile storage medium is not allowed to enter a writing state.
In the examples of the present application. The preset comparison times can be set in the electronic equipment, and if the preset comparison times are three times and the key information obtained by the electronic equipment for three consecutive times is inconsistent with the preset key information, it indicates that the number of times of requesting the writing operation is too large, and the electronic equipment enters a self-locking state, i.e. the file in the mobile storage medium cannot be read, and the file cannot be written into the mobile storage medium, so that the mobile storage medium is protected, and the possibility of illegally invading the mobile storage medium is reduced.
In the above embodiment, all file system types in the mobile storage medium can be identified, that is, no matter the mobile storage medium is connected with the computer device of the Windows system or the computer device of the Linux system, all file system types in the mobile storage medium can be identified, and then files in the file system can be read.
But some specific file system types can be recognized by both Windows and Linux systems. Therefore, in order to store the file by using the file system which can be identified by both the Windows system and the Linux system, the convenience of reading the file subsequently by using personnel is improved. In a possible implementation manner of the embodiment of the present application, when the access of the mobile storage medium is detected, the method further includes step S111 (not shown in the figure) and step S112 (not shown in the figure), where step S111 may be executed after step S101, where,
step S111, judging whether the target file system type exists in all the file system types of the mobile storage medium.
The target file system type comprises file system types which can be identified by both a Windows system and a Linux system.
For embodiments of the present application, certain specific file system types may be identified by the Windows system and identified by the Linux system, for example, the FAT file system. The target file system in the embodiment of the application takes the FAT file system as an example, and after the mobile storage medium is determined to be accessed into the electronic device, the electronic device determines whether the FAT file system exists in the determined file system.
And step S112, if the target file system exists, outputting a signal for representing that the target file system type exists in the mobile storage medium.
For the embodiment of the application, if the FAT file system exists, the electronic device outputs a signal representing that the FAT file system exists in the mobile storage medium, and transmits the signal to the computer device, so that the computer device can know that the FAT file system exists in the mobile storage medium. And further causing the computer device to output prompt information to prompt a user that the FAT file system exists in the removable storage medium. The user can preferentially write the file into the FAT file system, so that the user can read the file by using the mobile storage medium in the subsequent process of reading the file, and the convenience of reading the file is improved.
In a possible implementation manner of the embodiment of the present application, the method further includes at least one of step S113 (not shown in the figure) and step S114 (not shown in the figure), where step S113 may be executed after step S101, and may also be executed after step S105; step S114 may be performed after step S110, wherein,
step S113, if the mobile storage medium is in a reading state, acquiring the file name of the file to be read, judging whether the file name of the file to be read is matched with the preset virus name, and if so, controlling to stop reading the file to be read.
For the embodiment of the application, certain specific viruses can be disguised as files to be stored in the mobile storage medium, so that the mobile storage medium is infected by the viruses, and further the viruses can infect other computer equipment through the mobile storage medium. When the virus is disguised as a file, a specific file name exists, so that when the file in the mobile storage medium is read, the file name of the file to be read is obtained, and the file name is compared with a preset virus name. Let us assume that the preset virus name is "autorun. And if the file name is consistent with the preset virus name, the electronic equipment determines that the file is a virus file, and the electronic equipment controls to stop reading the virus file. And intercepting the virus file in the electronic equipment. Or removable storage media, thereby reducing the likelihood of computer devices becoming infected with viruses.
Step S114, if the mobile storage medium is in the writing state, acquiring the file name of the file to be written, judging whether the file name of the file to be written is matched with the preset virus name, and if so, deleting the file to be written.
For the embodiment of the application, when the file is written into the mobile storage medium, the virus file may be written into the mobile storage medium. The electronic equipment acquires the file name of the file to be written before storing the file to be written in the mobile storage medium, compares the file name with a preset virus name and judges whether the file name is consistent with the preset virus name or not. If the file is consistent with the virus file, the file is determined to be the virus file, and the electronic equipment deletes the file, so that the virus file cannot be written into the mobile storage medium, and the possibility that the virus file is stored in the mobile storage medium is also reduced.
In the embodiment of the present application, when the file name is consistent with the preset virus name, the file may not belong to the virus. When the electronic device stores the file, recording the path of the file, determining the position of a physical sector of the file stored in the mobile storage medium, and marking or setting the authority of the physical sector. For example, a specific identifier is written in the physical sector as a mark, and the file in the physical sector is determined to be a suspicious file through the specific identifier.
When the mobile storage medium is in a reading state again, a signal indicating that the physical sector is abnormal is output according to the mark. The computer device receives the signal to remind a user that the file in the physical sector is a suspicious file, or the set permission can be permission for limiting the reading of the file in the physical sector, and the electronic device removes the limitation permission of the physical sector when receiving a specific instruction to read the file.
The above embodiments describe a method for reading data in a storage medium from the perspective of a method flow, and the following embodiments describe an apparatus for reading data in a storage medium from the perspective of a virtual module or a virtual unit, which are described in detail in the following embodiments.
As shown in fig. 2, the apparatus 20 for reading data in a storage medium may specifically include:
an information obtaining module 201, configured to obtain, when access to a mobile storage medium is detected, the number of logical partitions in the mobile storage medium and a capacity of each logical partition;
a starting physical sector determination module 202 for determining a starting physical sector of at least one logical partition based on the number of logical partitions and the capacity of each logical partition;
a partition type determination module 203 for determining a partition type of the at least one logical partition based on a starting physical sector of the at least one logical partition;
an identifier determining module 204, configured to determine, according to the partition type, an assigned physical sector corresponding to the at least one logical partition, where identifier information is stored in the assigned physical sector;
and the file system determining module 205 is configured to determine a file system type corresponding to the at least one logical partition based on the identification information.
In an embodiment of the present application, an apparatus 20 for reading data in a storage medium is provided, wherein when access to a mobile storage medium is detected, it indicates that a file in the mobile storage medium is to be read or written, so that an information obtaining module 201 obtains the number of at least one logical partition and the capacity of the at least one logical partition in the mobile storage medium. After obtaining the capacity of the first logical partition, since the starting physical sector corresponding to the first logical partition starts from physical sector number 0, the address of the last physical sector corresponding to the first logical partition can be determined according to the capacity of the first logical partition, that is, the starting physical sector determining module 202 can determine the address of the starting physical sector of the current logical partition according to the last physical sector corresponding to the last logical partition of the logical partition, the partition type determining module 203 can determine the corresponding partition type based on the starting physical sector of each logical partition, and the identifier determining module 204 can further obtain the identifier information according to the designated physical sector of each logical partition, so that the file system determining module 205 can determine the file system type of the logical partition, that is, the file in the file system can be read, and further, the user can read the files in the mobile storage medium conveniently.
In a possible implementation manner of this embodiment of the present application, when determining the partition type of any logical partition based on the starting physical sector of any logical partition, the partition type determining module 203 is specifically configured to:
reading a starting physical sector corresponding to any logic partition to obtain first data information of the starting physical sector, wherein the first data information at least comprises first specified byte data and second specified byte data;
if the data of the first designated byte belongs to the first preset identifier, reading a next physical sector of the initial physical sector to obtain second data information;
if the data of the specified byte in the second data information belongs to a second preset identifier, judging whether any logic partition has a sub-logic partition;
if yes, determining that any logic partition belongs to the GPT partition;
if the data of the second specified byte does not exist, determining that any logic partition belongs to the MBR partition;
if not, and the data of the second specified byte is 0, then it is determined that any logical partition is of the no partition type.
In a possible implementation manner of the embodiment of the present application, the first data information includes a first identifier, and the identifier determining module 204 and the file system determining module 205 determine, according to the partition type, an assigned physical sector corresponding to any logical partition, where the identifier information is stored in the assigned physical sector; when determining the file system type corresponding to any logical partition based on the identification information, the method is specifically configured to:
if any logical partition belongs to the partition-free type, determining that the initial physical sector is the designated physical sector, and if the first identifier belongs to a first preset file system identifier, determining that the file system type of any logical partition is the file system type corresponding to the first identifier in the first preset file system identifier, where the first preset file system identifier includes: identification corresponding to NTFS file system, identification corresponding to FAT12 file system, identification corresponding to FAT16 file system, identification corresponding to FAT32 file system and identification corresponding to exFAT file system; or the like, or, alternatively,
if any logic partition belongs to the GPT partition or the MBR partition, reading a designated physical sector corresponding to the GPT partition or a designated physical sector corresponding to the MBR partition to obtain the initial logic sector address of at least one sub-logic partition and the capacity of at least one sub-logic partition so as to determine at least one target sub-logic partition;
reading the initial logic sector of each target sub logic partition to obtain a second identifier corresponding to each target sub logic partition;
if the second identifier belongs to the first preset file system identifier, determining the file system type of each target sub-logical partition as the file system type corresponding to the second identifier in the first preset file system identifier;
if the second identifier does not belong to the first preset file system identifier, reading a designated logical sector corresponding to each target sub-logical partition except for the initial logical sector to obtain a third identifier;
if the third identifier belongs to a second preset file system identifier, determining that the file system type of each target sub-logical partition is a file system type corresponding to the third identifier in the second preset file system identifier, where the second preset file system identifier includes: the identifier corresponding to the EXT2 file system, the identifier corresponding to the EXT3 file system and the identifier corresponding to the EXT4 file system.
In a possible implementation manner of the embodiment of the present application, the apparatus 20 further includes:
the file acquisition module is used for acquiring files in at least one logic partition;
the storage module is used for storing the file;
and the file sending module is used for sending the file when receiving the instruction of sending the file.
In a possible implementation manner of the embodiment of the present application, the apparatus 20 further includes:
the key obtaining module is used for obtaining key information when a request write instruction is detected;
and the state determining module is used for determining that the state of the mobile storage medium is a writing state when the key information is matched with the preset key information.
In a possible implementation manner of the embodiment of the present application, the apparatus 20 further includes:
the judging module is used for judging whether a target file system type exists in all file system types of the mobile storage medium, and the target file system type comprises a file system type which can be identified by a Windows system and a Linux system;
and the signal output module is used for outputting a signal for representing the existence of the target file system type in the mobile storage medium when the target file system type exists.
In a possible implementation manner of the embodiment of the present application, the apparatus 20 further includes at least one of a control module and a deletion module:
the control module is used for acquiring the file name of the file to be read when the mobile storage medium is in a reading state, judging whether the file name of the file to be read is matched with a preset virus name or not, and controlling to stop reading the file to be read if the file name of the file to be read is matched with the preset virus name;
and the deleting module is used for acquiring the file name of the file to be written when the mobile storage medium is in a writing state, judging whether the file name of the file to be written is matched with a preset virus name or not, and deleting the file to be written if the file name of the file to be written is matched with the preset virus name.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus 20 for reading data from a storage medium described above may refer to the corresponding process in the foregoing method embodiment, and is not described herein again.
In an embodiment of the present application, an electronic device is provided, and as shown in fig. 3, an electronic device 30 shown in fig. 3 includes: a processor 301 and a memory 303. Wherein processor 301 is coupled to memory 303, such as via bus 302. Optionally, the electronic device 30 may also include a transceiver 304. It should be noted that the transceiver 304 is not limited to one in practical applications, and the structure of the electronic device 30 is not limited to the embodiment of the present application.
The Processor 301 may be a CPU (Central Processing Unit), a general-purpose Processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 301 may also be a combination of computing functions, e.g., comprising one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 302 may include a path that transfers information between the above components. The bus 302 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 302 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 3, but this does not represent only one bus or one type of bus.
The Memory 303 may be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic Disc storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to these.
The memory 303 is used for storing application program codes for executing the scheme of the application, and the processor 301 controls the execution. The processor 301 is configured to execute application program code stored in the memory 303 to implement the aspects illustrated in the foregoing method embodiments.
The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
An embodiment of the present application provides a reading system for a removable storage medium, as shown in fig. 4, the system includes: a removable storage medium 401, a reading device 402, and a computer device 403, wherein the reading device 40 is configured to read the removable storage medium 401 (e.g., a usb disk) communicatively connected thereto and send the read file to the computer device 403 (e.g., a personal computer) communicatively connected thereto.
Further, the reading device 402 includes a file reading chip 4021 capable of reading a file, and a forwarding chip 4022, where the forwarding chip 4022 is configured to receive the file sent by the file reading chip 4021 and forward the file to the computer device 403.
Further, the reading device 40 further includes: the isolation device 4023 may be a chip having an isolation function, or may be a circuit having an isolation function, which is not limited herein. The isolator 4023 is disposed between the file reading chip 4021 and the forwarding chip 4022, so that the computer device 403 can only read the file in the removable storage medium 401 and cannot write the file in the removable storage medium 401, thereby making the file in the removable storage medium 401 more secure.
The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, which, when run on a computer, enables the computer to execute the corresponding content in the foregoing method embodiments. Compared with the related art, in the embodiment of the application, when the access of the mobile storage medium is detected, it is stated that a file in the mobile storage medium is to be read or written, and therefore, the number of the at least one logical partition and the capacity of the at least one logical partition in the mobile storage medium are obtained. After the capacity of the first logical partition is obtained, because the initial physical sector corresponding to the first logical partition starts from the physical sector number 0, the address of the last physical sector corresponding to the first logical partition can be determined according to the capacity of the first logical partition, that is, when the address of the initial physical sector of the current logical partition is determined, the address can be determined according to the last physical sector corresponding to the last logical partition of the logical partition, so that the corresponding partition type can be determined based on the initial physical sector of each logical partition, and then the identification information can be obtained according to the designated physical sector of each logical partition, so as to determine the file system type of the logical partition, that is, the file in the file system can be read, and thus, the user can read the file in the mobile storage medium conveniently.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless otherwise indicated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The foregoing is only a few embodiments of the present application and it should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present application, and that these improvements and modifications should also be considered as the protection scope of the present application.

Claims (10)

1. A method of reading data from a storage medium, comprising:
when detecting that a mobile storage medium is accessed, acquiring the number of logical partitions in the mobile storage medium and the capacity of each logical partition;
determining a starting physical sector of at least one logical partition based on the number of logical partitions and the capacity of each logical partition;
determining a partition type of the at least one logical partition based on a starting physical sector of the at least one logical partition;
determining a designated physical sector corresponding to the at least one logical partition according to the partition type, wherein identification information is stored in the designated physical sector;
and determining a file system type corresponding to the at least one logical partition based on the identification information.
2. The method of claim 1, wherein determining the partition type of any logical partition based on the starting physical sector of the any logical partition comprises:
reading a starting physical sector corresponding to any logic partition to obtain first data information of the starting physical sector, wherein the first data information at least comprises first specified byte data and second specified byte data;
if the data of the first designated byte belongs to a first preset identifier, reading a next physical sector of the initial physical sector to obtain second data information;
if the data of the specified byte in the second data information belongs to a second preset identifier, judging whether any logic partition has a sub-logic partition;
if yes, determining that any logic partition belongs to the GPT partition;
if the data of the second specified byte does not exist and is not 0, determining that any logic partition belongs to an MBR partition;
if not, and the data of the second designated byte is 0, determining that any one of the logical partitions belongs to the no-partition type.
3. The method according to claim 2, wherein the first data information includes a first identifier, and a designated physical sector corresponding to any logical partition is determined according to the partition type, and the designated physical sector stores the identifier information; determining a file system type corresponding to any one of the logical partitions based on the identification information, including:
if the any logical partition belongs to the non-partition type, determining that the starting physical sector is the designated physical sector, and if the first identifier belongs to a first preset file system identifier, determining that the file system type of the any logical partition is a file system type corresponding to the first identifier in the first preset file system identifier, where the first preset file system identifier includes: an identifier corresponding to an NTFS file system, an identifier corresponding to a FAT12 file system, an identifier corresponding to a FAT16 file system, an identifier corresponding to a FAT32 file system and an identifier corresponding to an exFAT file system; or the like, or, alternatively,
if any logic partition belongs to the GPT partition or the MBR partition, reading a designated physical sector corresponding to the GPT partition or a designated physical sector corresponding to the MBR partition to obtain the initial logic sector address of at least one sub-logic partition and the capacity of at least one sub-logic partition so as to determine at least one target sub-logic partition;
reading the initial logical sector of each target sub logical partition to obtain a second identifier corresponding to each target sub logical partition;
if the second identifier belongs to the first preset file system identifier, determining the file system type of each target sub-logical partition as the file system type corresponding to the second identifier in the first preset file system identifier;
if the second identifier does not belong to the first preset file system identifier, reading a designated logical sector corresponding to each target sub-logical partition except for the initial logical sector to obtain a third identifier;
if the third identifier belongs to a second preset file system identifier, determining that the file system type of each target sub-logical partition is a file system type corresponding to the third identifier in the second preset file system identifier, where the second preset file system identifier includes: the file system identifier comprises an identifier corresponding to the EXT2 file system, an identifier corresponding to the EXT3 file system and an identifier corresponding to the EXT4 file system.
4. The method according to claim 1, wherein determining the file system type corresponding to the at least one logical partition based on the identification information further comprises:
obtaining files in the at least one logical partition;
storing the file;
and when an instruction for sending the file is received, sending the file.
5. A method of reading data from a storage medium according to claim 1, the method further comprising:
if the request write-in instruction is detected, key information is obtained;
and if the key information is matched with the preset key information, determining that the state of the mobile storage medium is a writing state.
6. The method according to claim 1, wherein when the access of the mobile storage medium is detected, the method further comprises:
judging whether a target file system type exists in all file system types of the mobile storage medium, wherein the target file system type comprises a file system type which can be identified by a Windows system and a Linux system;
and if so, outputting a signal for indicating that the target file system type exists in the mobile storage medium.
7. A method of reading data from a storage medium according to claim 1, the method further comprising at least one of:
if the mobile storage medium is in a reading state, acquiring the file name of the file to be read, judging whether the file name of the file to be read is matched with a preset virus name or not, and if so, controlling to stop reading the file to be read;
and if the mobile storage medium is in a writing state, acquiring the file name of the file to be written, judging whether the file name of the file to be written is matched with the preset virus name, and if so, deleting the file to be written.
8. An apparatus for reading data from a storage medium, comprising:
the information acquisition module is used for acquiring the number of the logical partitions in the mobile storage medium and the capacity of each logical partition when the access of the mobile storage medium is detected;
a starting physical sector determination module for determining a starting physical sector of at least one logical partition based on the number of logical partitions and the capacity of each logical partition;
a partition type determination module to determine a partition type of the at least one logical partition based on a starting physical sector of the at least one logical partition;
the identification determining module is used for determining an appointed physical sector corresponding to the at least one logic partition according to the partition type, and identification information is stored in the appointed physical sector;
and the file system determining module is used for determining the file system type corresponding to the at least one logic partition based on the identification information.
9. An electronic device, comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to: a method of reading data in a storage medium according to any one of claims 1 to 7 is performed.
10. A computer-readable storage medium, on which a computer program is stored, which, when the computer program is executed in a computer, causes the computer to carry out a method of reading data in a storage medium according to any one of claims 1 to 7.
CN202210631076.9A 2022-06-06 2022-06-06 Method and device for reading data in storage medium, electronic equipment and medium Pending CN114968121A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210631076.9A CN114968121A (en) 2022-06-06 2022-06-06 Method and device for reading data in storage medium, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210631076.9A CN114968121A (en) 2022-06-06 2022-06-06 Method and device for reading data in storage medium, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN114968121A true CN114968121A (en) 2022-08-30

Family

ID=82958837

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210631076.9A Pending CN114968121A (en) 2022-06-06 2022-06-06 Method and device for reading data in storage medium, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN114968121A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115509465A (en) * 2022-11-21 2022-12-23 杭州字节方舟科技有限公司 Sector management method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115509465A (en) * 2022-11-21 2022-12-23 杭州字节方舟科技有限公司 Sector management method and device, electronic equipment and storage medium
CN115509465B (en) * 2022-11-21 2023-03-28 杭州字节方舟科技有限公司 Sector management method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US7941579B2 (en) Communication system for authenticating authority of host device for accessing storage medium set to periphery device
US8745277B2 (en) Command portal for securely communicating and executing non-standard storage subsystem commands
JP4322021B2 (en) Memory card
EP2389645B1 (en) Removable memory storage device with multiple authentication processes
JP2001337864A5 (en)
US7797398B2 (en) Communication system, and peripheral device having trigger generating device and computer program product that monitors whether a trigger has been generated
EP3115921A1 (en) Method and device for secure access control based on on-chip bus protocol
US20090138969A1 (en) Device and method for blocking autorun of malicious code
CN114968121A (en) Method and device for reading data in storage medium, electronic equipment and medium
US8706997B2 (en) Storage device, access control program recording medium, and control method of storage device
CN114564158B (en) Method, device, equipment and medium for controlling document printing under Linux system
CN112507319A (en) Data security protection method and device oF NVMe-oF storage system
KR20110095261A (en) Copy safe storage
US20110271064A1 (en) Storage device and method for accessing the same
TWI463328B (en) Detecting method and apparatus for hot swapped sd card
CN110086836B (en) Method and device for acquiring metadata
EP4006758A1 (en) Data storage apparatus with variable computer file system
CN106796644B (en) Access control system and access control method
KR20180001990A (en) Operation method of storage medium, operation method of host controlling storage medium, and operation method of user system including storage medium and host
US11868620B2 (en) Read-write method and apparatus, electronic device, and readable memory medium
CN110941843B (en) Encryption implementation method, device, equipment and storage medium
EP3814910B1 (en) Hardware protection of files in an integrated-circuit device
CN109254953A (en) A kind of data-erasure method based on FAT file, data storage device and system
WO2024060193A1 (en) Operation method and apparatus applied to computer device, and computer device
TWI681296B (en) Apparatus and method and computer program product for accessing a memory card

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