Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules or units, and are not used for limiting the devices, modules or units to be different devices, modules or units, and also for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
To make the objects, technical solutions and advantages of the present disclosure more apparent, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
It should be noted that the reason why the restart is caused by the present disclosure may be that some hardware fails, such as a power supply module is abnormal, or a fault short circuit occurs in some device, which causes an excessive current to restart the mobile phone in the starting process; it is also possible that the restart process is restarted again due to some software error, causing a loop to be stuck in the infinite restart.
Because the system reads and writes the Data subarea when the system is started every time, if the Data subarea is abnormally restarted when write operation is performed on the Data subarea, the Data subarea file system can generate errors, and generally, the abnormal operation of a few times can be repaired by a repair tool, so that the Data on the Data subarea cannot be damaged too much. However, if the Data partition is repeatedly restarted continuously due to hardware or software failure, errors are accumulated continuously, and finally serious errors occur, so that the user Data is completely lost.
The present disclosure provides a data protection method, apparatus, electronic device and computer-readable storage medium, which aim to solve the above technical problems of the prior art.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
The embodiment of the present disclosure provides a method for protecting data, as shown in fig. 1, the method includes:
step S101: before the system is started, acquiring the restart times from a preset address;
optionally, the preset address may be a specific address of a bare partition, and it should be noted that the bare partition is a special block device file that is not formatted and is not read by Unix through a file system. It is up to the application program to read and write it. Without buffering by the file system. It is a device that is not directly managed by the operating system. Saving the number of reboots to the bare partition specific address may allow the number of reboots to be accessed both before and after system boot.
Optionally, the number of restarts includes a first number of restarts and a second number of restarts;
if the first restart times are larger than the second restart times, determining the first restart times as the restart times;
and if the first restart times are not more than the second restart times, determining the second restart times as the restart times.
It is understood that, in order to avoid counting errors caused by abnormal events during the data updating process, a dual backup mode of a first restart time and a second restart time may be adopted for the alternate updating. Specifically, when it is detected that a restart occurs during the startup process, such as some hardware fails, or some software fails, both the first restart time and the second restart time are increased by 1. And a double-backup alternate updating mechanism is adopted, so that misjudgment can not be caused under abnormal conditions.
Step S102: if the restart times are not more than the preset restart threshold, updating the restart times, storing the updated restart times to a preset address, and starting the system;
it can be understood that, in general, several times of reboots may be repaired by the repair tool without causing too much loss to the Data on the Data partition, so that a preset reboot threshold may be set in advance, and when the number of reboots is not greater than the preset reboot threshold, the number of reboots may be updated, for example, the number of reboots may be increased by 1, and then the updated number of reboots may be saved in a specific address of the bare partition again. And finally, starting the application program.
Optionally, the preset restart threshold is stored in a preset address.
It can be understood that the preset address can be stored in a specific address of the bare partition, and the bare partition is responsible for reading and writing the bare partition by the application program and does not undergo buffering of the file system. Saving the preset restart threshold to the bare partition specific address enables the preset restart threshold to be accessible before the system is started and when the system cannot be started.
Optionally, after the system is started for a preset time, the updated restart times stored in the preset address are cleared.
It can be understood that the system may be started repeatedly, for example, the mobile phone is turned off after being started for a period of time, the start may be understood as invalid, the system may be considered to be started effectively after the system is started for a preset time, for example, 5 minutes or 10 minutes, and then the values of the updated first restart times and the updated second restart times stored in the specific address of the bare partition may be cleared based on the specific address of the bare partition, so as to implement the function similar to dog feeding. And then ensures that the restart times for the next cycle are restarted.
Step S103: and if the restart times are larger than a preset restart threshold, displaying fault prompt information.
It can be understood that, if the restart time is greater than the preset restart threshold, the repeated restart time has reached a certain degree, and in order to prevent the Data partition from being accumulated by mistake and causing the loss of user Data, the fault prompt message may be displayed. At this time, the user can maintain the terminal, so that the maintained Data subarea is recovered, and the user Data is protected.
Optionally, if the restart times are greater than a preset restart threshold, a fault prompting interface including fault prompting information may be generated;
and displaying a fault prompt interface.
The fault prompting information may be included in the fault prompting interface, and specifically, when the restart time is greater than a preset restart threshold, the fault prompting interface may be generated and displayed on the terminal to prompt a user of a fault reason of the current terminal. The user can more accurately perform maintenance based on the displayed failure cause, thereby protecting user data.
Optionally, the preset restart threshold may also be changed.
It can be understood that the preset restart threshold may be displayed in the background, or the current restart times may be displayed, and the preset restart threshold may be changed in different scenarios, for example, the preset restart threshold may be changed according to the model or system version of the terminal, so that the modified preset restart threshold is more appropriate to the current terminal, thereby saving subsequent maintenance resources and protecting user data to the greatest extent.
According to the embodiment of the disclosure, the restart times are set in the preset address, so that the restart times can be accessed before and after the system is started, and when the restart times are not more than the preset restart threshold, the system is started without wasting maintenance resources; when the restart times are larger than the preset restart threshold, the fault prompt information is displayed, the Data subarea is prevented from being damaged by repeated restart, and therefore the probability of protecting the user Data is improved.
An embodiment of the present disclosure provides a data protection apparatus, and as shown in fig. 2, the data protection apparatus 20 may include: an acquisition module 201, an update module 202, and a display module 203, wherein,
an obtaining module 201, configured to obtain restart times from a preset address before a system is started;
optionally, the preset address may be a specific address of a bare partition, and it should be noted that the bare partition is a special block device file that is not formatted and is not read by Unix through a file system. It is up to the application program to read and write it. Without buffering by the file system. It is a device that is not directly managed by the operating system. Saving the number of reboots to the bare partition specific address may allow the number of reboots to be accessed both before and after system boot.
Optionally, the number of restarts includes a first number of restarts and a second number of restarts;
if the first restart times are larger than the second restart times, determining the first restart times as the restart times;
and if the first restart times are not more than the second restart times, determining the second restart times as the restart times.
It is understood that, in order to avoid counting errors caused by abnormal events during the data updating process, a dual backup mode of a first restart time and a second restart time may be adopted for the alternate updating. Specifically, when it is detected that a restart occurs during the startup process, such as some hardware fails, or some software fails, both the first restart time and the second restart time are increased by 1. And a double-backup alternate updating mechanism is adopted, so that misjudgment can not be caused under abnormal conditions.
The updating module 202 is configured to update the restart times if the restart times are not greater than a preset restart threshold, store the updated restart times to a preset address, and start the system;
it can be understood that, in general, several times of reboots may be repaired by the repair tool without causing too much loss to the Data on the Data partition, so that a preset reboot threshold may be set in advance, and when the number of reboots is not greater than the preset reboot threshold, the number of reboots may be updated, for example, the number of reboots may be increased by 1, and then the updated number of reboots may be saved in a specific address of the bare partition again. And finally, starting the application program.
Optionally, the preset restart threshold is stored in a preset address.
It can be understood that the preset address can be stored in a specific address of the bare partition, and the bare partition is responsible for reading and writing the bare partition by the application program and does not undergo buffering of the file system. Saving the preset restart threshold to the bare partition specific address enables the preset restart threshold to be accessible before the system is started and when the system cannot be started.
Optionally, the data protection device may further include:
and the zero clearing module is used for carrying out zero clearing treatment on the updated restart times stored in the preset address after the system is started for the preset time.
It can be understood that the system may be started repeatedly, for example, the mobile phone is turned off after being started for a period of time, the start may be understood as invalid, the system may be considered to be started effectively after the system is started for a preset time, for example, 5 minutes or 10 minutes, and then the values of the updated first restart times and the updated second restart times stored in the specific address of the bare partition may be cleared based on the specific address of the bare partition, so as to implement the function similar to dog feeding. And then ensures that the restart times for the next cycle are restarted.
The display module 203 is configured to display the fault notification information if the restart time is greater than a preset restart threshold.
It can be understood that, if the restart time is greater than the preset restart threshold, the repeated restart time has reached a certain degree, and in order to prevent the Data partition from being accumulated by mistake and causing the loss of user Data, the fault prompt message may be displayed. At this time, the user can maintain the terminal, so that the maintained Data subarea is recovered, and the user Data is protected.
Optionally, the display module 203 further includes:
the display submodule is used for generating a fault prompt interface comprising fault prompt information if the restart times are larger than a preset restart threshold;
display fault prompt interface
The fault prompting information may be included in the fault prompting interface, and specifically, when the restart time is greater than a preset restart threshold, the fault prompting interface may be generated and displayed on the terminal to prompt a user of a fault reason of the current terminal. The user can more accurately perform maintenance based on the displayed failure cause, thereby protecting user data.
Optionally, the data protection device may further include:
and the changing module is used for changing the preset restarting threshold value.
It can be understood that the preset restart threshold may be displayed in the background, or the current restart times may be displayed, and the preset restart threshold may be changed in different scenarios, for example, the preset restart threshold may be changed according to the model or system version of the terminal, so that the modified preset restart threshold is more appropriate to the current terminal, thereby saving subsequent maintenance resources and protecting user data to the greatest extent.
According to the embodiment of the disclosure, the restart times are set in the preset address, so that the restart times can be accessed before and after the system is started, and when the restart times are not more than the preset restart threshold, the system is started without wasting maintenance resources; when the restart times are larger than the preset restart threshold, the fault prompt information is displayed, the Data subarea is prevented from being damaged by repeated restart, and therefore the probability of protecting the user Data is improved.
Referring now to FIG. 3, a block diagram of an electronic device 300 suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. 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 disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as a processing device 301 described below, and the memory may include at least one of a Read Only Memory (ROM)302, a Random Access Memory (RAM)303, and a storage device 308, which are described below:
as shown in fig. 3, the electronic device 300 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage means 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device 300 to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device 300 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer media described above in this disclosure may be computer signal media or computer readable storage media or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, a computer signal medium may include a propagated data signal with program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer signal medium may also be any computer signal medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer medium may be one contained in the electronic device; or may exist separately without being assembled into the electronic device.
The computer medium carries one or more programs that, when executed by the electronic device, cause the electronic device to:
before the system is started, acquiring the restart times from a preset address;
if the restart times are not more than the preset restart threshold, updating the restart times, storing the updated restart times to a preset address, and starting the system;
and if the restart times are larger than a preset restart threshold, displaying fault prompt information.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the designation of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine medium may be a machine signal medium or a machine storage medium. A machine medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a data protection method including:
before the system is started, acquiring the restart times from a preset address;
if the restart times are not more than the preset restart threshold, updating the restart times, storing the updated restart times to a preset address, and starting the system;
and if the restart times are larger than a preset restart threshold, displaying fault prompt information.
Optionally, after the system is started for a preset time, the updated restart times stored in the preset address are cleared.
Optionally, if the number of restarts is greater than a preset restart threshold, displaying fault notification information, including:
if the restarting times are larger than a preset restarting threshold value, generating a fault prompting interface comprising fault prompting information;
and displaying a fault prompt interface.
Optionally, after displaying the fault notification interface, the method includes:
the preset restart threshold is changed.
Optionally, the number of restarts includes a first number of restarts and a second number of restarts;
if the first restart times are larger than the second restart times, determining the first restart times as the restart times;
and if the first restart times are not more than the second restart times, determining the second restart times as the restart times.
Optionally, the preset restart threshold is stored in a preset address.
According to one or more embodiments of the present disclosure, there is provided a data protection apparatus including:
the acquisition module is used for acquiring the restart times from a preset address before the system is started;
the updating module is used for updating the restarting times if the restarting times are not larger than a preset restarting threshold value, storing the updated restarting times to a preset address and starting the system;
and the display module is used for displaying a fault prompt interface if the restart times are greater than a preset restart threshold.
Optionally, the data protection device further includes:
and the zero clearing module is used for carrying out zero clearing treatment on the updated restart times stored in the preset address after the system is started for the preset time.
Optionally, the display module includes:
the display submodule is used for generating a fault prompt interface comprising fault prompt information if the restart times are larger than a preset restart threshold;
and displaying a fault prompt interface.
Optionally, the data protection device further includes:
and the changing module is used for changing the preset restarting threshold value.
According to one or more embodiments of the present disclosure, there is provided an electronic device including:
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 programs configured to perform the data protection method described above.
According to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium for storing computer instructions which, when executed on a computer, cause the computer to perform the above-described data protection method.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.