System protection method, apparatus, circuit board assembly, and storage medium
Patent Information
- Application Number
- CN202510532924.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2026-10-30
AI Technical Summary
[0002]在操作系统的运行过程中,极易出现数据(data)分区本身的存储区域未满而导致系统无法启动的情况,例如,在系统运行时,存在应用程序创建大量的小文件,会使得data分区本身未满而其中的例如超级块(super block)满了,此时将会导致系统无法启动,使得系统保护效率较低
[0038]本申请实施例通过在检测到应用程序触发的文件操作事件的情况下,通过虚拟文件系统判断文件操作事件所操作的目标文件是否为指定数据目录下的文件;若目标文件为指定数据目录下的文件,则通过虚拟文件系统在指定数据目录对应的数据分区中对目标存储空间进行空间检查,得到目标存储空间的空闲空间信息;在空闲空间信息触发操作系统保护条件的情况下,进行针对数据分区的存储空间调整操作。以此,通过在检测到应用程序触发的文件操作事件时,判断文件操作事件所操作的目标文件是否为指定数据目录下的文件,从而在目标文件为指定数据目录下的文件时,查询指定数据目录对应的数据分区中的目标存储空间的空闲空间信息,从而在空闲空间信息触发操作系统保护条件的情况下,进行针对数据分区的存储空间调整操作,以对操作系统的正常启动和运行进行保护,避免由于数据分区满了或者数据分区本身未满而其中的目标存储空间满了导致操作系统无法启动或无法正常运行的情况,有效提升操作系统保护效率。
Smart Images

Figure CN123011595A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and specifically to a system protection method, apparatus, circuit board assembly, and storage medium. Background Technology
[0002] During the operation of an operating system, it is very easy for the storage area of the data partition itself to be insufficient, which may cause the system to fail to start. For example, when the system is running, an application may create a large number of small files, which may cause the data partition itself to be insufficient while the super block is full. This will cause the system to fail to start, resulting in low system protection efficiency. Summary of the Invention
[0003] This application provides a system protection method, device, circuit board assembly, and storage medium, which can protect the normal startup and operation of the operating system, avoid the situation where the operating system cannot start due to the target storage space in the data partition being full, and effectively improve the operating system protection efficiency.
[0004] This application provides a system protection method, including:
[0005] When a file operation event triggered by an application is detected, the virtual file system is used to determine whether the target file operated on by the file operation event is a file under the specified data directory.
[0006] If the target file is a file under the specified data directory, then the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space;
[0007] If the free space information triggers operating system protection conditions, a storage space adjustment operation is performed on the data partition.
[0008] Accordingly, embodiments of this application also provide a system protection device, including:
[0009] The determining unit is used to determine, in the event of a file operation event triggered by an application, whether the target file operated on by the file operation event is a file under a specified data directory through a virtual file system;
[0010] The checking unit is used to check the space of the target storage space in the data partition corresponding to the specified data directory through the virtual file system if the target file is a file under the specified data directory, so as to obtain the free space information of the target storage space.
[0011] The adjustment unit is used to perform storage space adjustment operations on the data partition when the free space information triggers operating system protection conditions.
[0012] In one embodiment, the target storage space includes a first data block and a second data block in the data partition, and the inspection unit includes:
[0013] If the file operation event is a file creation event or a file open event, the virtual file system performs a space check on the first data block in the data partition corresponding to the specified data directory to obtain the free space information of the first data block;
[0014] If the file operation event is a file write event, the virtual file system performs a space check on the second data block in the data partition corresponding to the specified data directory to obtain the free space information of the second data block.
[0015] In one embodiment, the above-mentioned method of performing a space check on the first data block in the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the first data block is specifically used for:
[0016] The virtual file system calls the first check function to obtain the number of free inodes and the total number of inodes in the superblock of the data partition corresponding to the specified data directory;
[0017] Based on the number of free index nodes and the total number of index nodes, the free space information of the first data block is calculated.
[0018] In one embodiment, the above-mentioned method of performing a space check on the second data block in the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the second data block is specifically used for:
[0019] The second checking function is invoked through the virtual file system to obtain the number of free data blocks and the total number of data blocks of the data partition corresponding to the specified data directory;
[0020] Based on the number of free data blocks and the total number of data blocks, the free space information of the second data block is calculated.
[0021] In one embodiment, the determining unit is configured to:
[0022] Upon detecting a file operation event in the application, obtain the file path information corresponding to the file operation event;
[0023] Based on the file path information, the virtual file system determines whether the target file operated on by the file operation event is a file under the specified data directory.
[0024] In one embodiment, the free space information includes a free space percentage, and the adjustment unit is used to:
[0025] When the percentage of free space is less than a first preset percentage but greater than a second preset percentage, the system will trigger a low storage space mode and remind the user to clear application data in the data partition.
[0026] When the percentage of free space is less than a second preset percentage but greater than a third preset percentage, the system will trigger the entry into ultra-low storage space mode and remind the user to clean up the application data in the data partition. In the case that the file operation event is a specified event type, the system will perform an event restriction operation.
[0027] When the percentage of free space is less than a third preset percentage, an emergency mode is triggered, and application data in the data partition is cleared, and a reset operation is performed on the data partition.
[0028] In one embodiment, the specified event type includes: a file creation event type, and the above-mentioned execution event restriction operation is specifically used for:
[0029] If the system permissions corresponding to the file operation event do not meet the preset permission conditions, the execution of the file operation event is prevented.
[0030] In one embodiment, the above-described actions of clearing application data in the data partition and performing a reset operation on the data partition are specifically used for:
[0031] Through the virtual file system in kernel space, based on the target communication mechanism between kernel space and user space, the listener in user space is notified so that the listener triggers the application in user space to clean up the application data in the data partition, and the listener notifies the operating system so that the operating system performs a reset operation on the data partition.
[0032] In one embodiment, the system protection device further includes a reset unit, used for:
[0033] If the operating system fails to mount the data partition corresponding to the specified data directory during the operating system startup process, it notifies the user space to perform a reset operation through the target communication mechanism.
[0034] Furthermore, embodiments of this application also provide a circuit board assembly, including a circuit board, a processor, and a memory, wherein the processor and the memory are disposed on the circuit board, and the memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of any of the system protection methods provided in embodiments of this application.
[0035] Furthermore, embodiments of this application also provide an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the system protection methods provided in embodiments of this application.
[0036] Furthermore, embodiments of this application also provide a computer-readable storage medium including a computer program, which, when run on an electronic device, causes the electronic device to perform the steps of any of the system protection methods provided in embodiments of this application.
[0037] Furthermore, embodiments of this application also provide a computer program product, including a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the system protection methods provided in embodiments of this application.
[0038] This application embodiment, upon detecting a file operation event triggered by an application, determines whether the target file operated on by the file operation event is a file under a specified data directory through a virtual file system. If the target file is a file under the specified data directory, the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain free space information of the target storage space. If the free space information triggers operating system protection conditions, a storage space adjustment operation is performed on the data partition. Thus, by determining whether the target file operated on by the file operation event triggered by an application is a file under a specified data directory when the target file is a file under the specified data directory, and querying the free space information of the target storage space in the data partition corresponding to the specified data directory when the target file is a file under the specified data directory, and performing a storage space adjustment operation on the data partition when the free space information triggers operating system protection conditions, the normal startup and operation of the operating system are protected. This avoids situations where the operating system cannot start or operate normally due to the data partition being full or the target storage space within the data partition being full even if the data partition itself is not full, effectively improving the efficiency of operating system protection. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a schematic diagram illustrating an implementation scenario of a system protection method provided in this application embodiment;
[0041] Figure 2 This is a flowchart illustrating a system protection method provided in an embodiment of this application;
[0042] Figure 3 This is a schematic diagram illustrating the specific framework of a system protection method provided in the embodiments of this application;
[0043] Figure 4 This is a schematic diagram of the system protection device provided in the embodiments of this application;
[0044] Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0045] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0046] Furthermore, in the description of the embodiments of this application, the terms "first," "second," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0047] During operating system operation, situations can easily arise where the data partition itself is not full, causing the system to fail to boot. For example, during system startup, applications such as video playback applications (Prime Video) create numerous small files, causing the data partition itself to be less than full while its superblock, for instance, becomes full, resulting in system boot failure. Current technologies typically add detection mechanisms at the system application level to alert the user, but these are not effective in preventing malicious or abnormal applications from damaging the data partition. Furthermore, current technologies can only detect abnormal partition sizes, not situations where the data partition itself is full, leading to boot failure. Therefore, the operating system's protection efficiency is relatively low.
[0048] To address the aforementioned technical problems in the prior art, this application provides a system protection method. When a file operation event triggered by an application is detected, the method determines whether the target file of the file operation event is a file in a specified data directory. If the target file is in the specified data directory, the method searches for free space information in the target storage space of the data partition corresponding to the specified data directory within the file system. When the free space information triggers operating system protection conditions, the method performs storage space adjustment operations on the data partition. This protects the normal startup and operation of the operating system, preventing situations where the operating system cannot start or operate normally due to the data partition being full or the target storage space within the data partition being full even if the data partition itself is not full. This effectively improves the efficiency of operating system protection.
[0049] This application provides a system protection method, apparatus, circuit board assembly, electronic device, and storage medium. The system protection apparatus and the circuit board assembly provided in this application embodiment can be integrated into an electronic device, which can be a server, a terminal, or other similar device.
[0050] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) acceleration services, and big data and artificial intelligence platforms. The terminal can include, but is not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited herein.
[0051] Please see Figure 1 Taking the integration of system protection devices into electronic devices as an example, Figure 1 This is a schematic diagram of an implementation scenario of the system protection method provided in this application. The electronic device can be a terminal. When a file operation event triggered by an application is detected, the electronic device can determine whether the target file operated by the file operation event is a file under a specified data directory through a virtual file system. If the target file is a file under a specified data directory, the virtual file system will perform a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space. If the free space information triggers the operating system protection condition, a storage space adjustment operation will be performed on the data partition.
[0052] It should be noted that, Figure 1 The schematic diagram illustrating the implementation environment of the system protection method shown is merely an example. The implementation environment of the system protection method described in this application is intended to more clearly illustrate the technical solutions of the embodiments of this application and does not constitute a limitation on the technical solutions provided in the embodiments of this application. Those skilled in the art will recognize that, with the evolution of data processing and the emergence of new business scenarios, the technical solutions provided in this application are equally applicable to similar technical problems.
[0053] The solutions provided in this application are specifically illustrated through the following embodiments. It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0054] This embodiment will be described from the perspective of a system protection device, which can be integrated into an electronic device, which can be a terminal, and this application does not limit it.
[0055] Please see Figure 2 , Figure 2 This is a flowchart illustrating the system protection method provided in an embodiment of this application. The system protection method may include:
[0056] In step 101, if a file operation event triggered by the application is detected, the virtual file system is used to determine whether the target file operated on by the file operation event is a file under the specified data directory.
[0057] The file operation event can be any event that performs operations on a file, such as write, create, and open operations. The Virtual File System (VFS) is a software layer within the operating system kernel space, providing a unified file system interface for user-space programs while allowing different actual file systems to coexist. The target file is the file operated on by the file operation event. The specified data directory can be the user data directory ( / data directory), which is primarily used to store user and system data, ensuring proper application operation and data isolation.
[0058] When an application-triggered file operation event is detected, there are several ways to determine whether the target file operated on by the file operation event is a file in the specified data directory through the virtual file system. For example, when a file operation event is detected, the file path information corresponding to the file operation event can be obtained; based on the file path information, the virtual file system can be used to determine whether the target file operated on by the file operation event is a file in the specified data directory.
[0059] The file path information can be information indicating the path of the target file operated on by the file operation event. Through the file path information, it can be determined whether the target file operated on by the file operation event is a file under the specified data directory.
[0060] For example, if the target file's file path information is / data / xx, then it can be determined that the target file operated on by the file operation event is a file under the specified data directory. If the target file's file path information is / dev / hidraw, then it can be determined that the target file operated on by the file operation event is not a file under the specified data directory.
[0061] In step 102, if the target file is a file under the specified data directory, the space of the target storage space is checked in the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the target storage space.
[0062] The data partition can be a partition for storing user data and applications. This data partition can also be a partition within a file system, which defines how the operating system organizes files on the storage device or partition. File systems like Ext4 and F2FS define how files are stored, named, and how the storage device is used. The data partition is a logical area on the physical storage device that can contain a file system. This data partition is mounted to a specified data directory in the file system hierarchy, i.e., the / data directory. The target storage space can be the storage space within the data partition, and may include blocks such as the superblock, data blocks, and metadata blocks. The superblock is an important metadata structure in the file system, containing crucial information about the entire file system. For example, it can store detailed file system information, including inodes, the total number of blocks, their usage, remaining space, and the file system format. Data blocks are used to store file data; each file's data is stored in these blocks, and data blocks are the most basic storage unit in the file system. The free space information can be information indicating the amount of remaining usable storage space in the target storage space. Optionally, the free space information can be in numerical form, such as a percentage, fraction, or positive number. The specific numerical form can be set according to the actual situation, and this application embodiment does not limit it.
[0063] There are several ways to obtain the free space information of the target storage space by performing a space check on the data partition corresponding to the specified data directory through the virtual file system. For example, the target storage space may include a first data block and a second data block in the data partition. If the file operation event is a file creation event or a file open event, the space of the first data block can be checked on the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the first data block. If the file operation event is a file write event, the space of the second data block can be checked on the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the second data block.
[0064] The first data block can be a block used to store critical information about the file system, such as a superblock, metadata block, or inode. An inode stores file metadata. The second data block can be the actual area used to store file data, i.e., a data block. The data for each file in the data partition is stored in these blocks. The file creation event can be the event that creates the file, the file open event can be the event that opens the file, and the file write event can be the event that writes to the file.
[0065] Since file write events are stored in data blocks without affecting the superblock or inode area, a space check can be performed on the second data block of the data partition within the file system when the file operation event is a file write event. However, since file creation or file open events may create new files, affecting the superblock or inode area, a space check can be performed on the first data block of the data partition corresponding to the specified data directory within the file system when the file operation event is a file creation or file open event. This allows for space checks on applications within the data partition based on free space information.
[0066] There are several ways to obtain the free space information of the first data block by performing a space check on the first data block in the data partition corresponding to the specified data directory through the virtual file system. For example, the first check function can be called through the virtual file system to obtain the number of free inodes and the total number of inodes in the superblock of the data partition corresponding to the specified data directory; and the free space information of the first data block can be calculated based on the number of free inodes and the total number of inodes.
[0067] The first checking function can be used to check the free space information corresponding to the first data block in the superblock. The number of free inodes can be the number of inodes in the superblock that are in a free state. The total number of inodes can be the total number of inodes contained in the data partition under the file system. An inode can be a data structure in the file system used to store the metadata of a file or directory.
[0068] The superblock stores information such as the total number of inodes in the file system, as well as their usage and remaining quantity. Therefore, the first check function (check_super_block) can be used to query the number of free inodes and the total number of inodes in the superblock.
[0069] There are several ways to calculate the free space information of the first data block based on the number of free index nodes and the total number of index nodes. For example, the ratio of the number of free index nodes to the total number of index nodes can be calculated to obtain the free space information of the first data block.
[0070] Optionally, the space check of the second data block of the data partition corresponding to the specified data directory under the file system can be performed through the virtual file system to obtain the free space information of the second data block. For example, the second check function can be called through the virtual file system to obtain the number of free data blocks and the total number of data blocks of the data partition corresponding to the specified data directory; based on the number of free data blocks and the total number of data blocks, the free space information of the second data block can be calculated.
[0071] The second checking function can be used to determine the free space information corresponding to the second data block in the data partition. The number of free data blocks can be the number of free data blocks in the data partition, and the total number of data blocks can be the total number of data blocks in the data partition.
[0072] There are several ways to calculate the free space information of the second data block based on the number of free data blocks and the total number of data blocks. For example, the ratio of the number of free data blocks to the total number of data blocks can be calculated to obtain the free space information of the second data block.
[0073] Optionally, there are several other ways to calculate the free space information of the second data block based on the number of free data blocks and the total number of data blocks. For example, the number of reserved data blocks can be obtained, the number of free data blocks can be subtracted from the number of reserved data blocks to obtain the difference result, and the ratio of the difference result to the total number of data blocks can be calculated to obtain the free space information of the second data block.
[0074] The number of reserved data blocks can be the number of data blocks to reserve a certain amount of storage space. This can prevent the system from failing to start or operate normally due to the data partition being full, thereby effectively protecting the startup and operation of the operating system and improving system protection efficiency.
[0075] In step 103, when the free space information triggers the operating system protection condition, a storage space adjustment operation is performed on the data partition.
[0076] The operating system protection condition can be a condition used to protect the normal startup and stable operation of the operating system. For example, at least one preset value can be determined. When the free space information is less than the preset value, there is a risk that the storage space of the superblock or data blocks in the data partition is full, which will affect the normal startup and stable operation of the operating system. Therefore, when the free space information is less than the preset value, the operating system protection condition can be triggered to adjust the storage space of the data partition, thereby avoiding the situation where the operating system cannot start and run normally due to the data partition being full, such as the superblock, inode, or data blocks, thereby improving the system protection efficiency.
[0077] In the event that the free space information triggers the operating system's protection conditions, there are several ways to adjust the storage space of the data partition. For example, the free space information may include a free space percentage. When the free space percentage is less than a first preset percentage but greater than a second preset percentage, a low storage space mode is triggered, and the user is reminded to clean up application data in the data partition. When the free space percentage is less than a second preset percentage but greater than a third preset percentage, an ultra-low storage space mode is triggered, and the user is reminded to clean up application data in the data partition. In the case of a file operation event of a specified event type, an event restriction operation is performed. When the free space percentage is less than a third preset percentage, an emergency mode is triggered, and application data in the data partition is cleaned up. A reset operation is performed on the data partition.
[0078] The free space percentage can be a ratio in the form of a percentage between the free storage space corresponding to the first or second data block and the total storage space. The first preset percentage can be a value corresponding to the free space information that has a low impact on the normal startup and stable operation of the operating system, for example, 10%. The second preset percentage can be a value corresponding to the free space information that has a moderate impact on the normal startup and stable operation of the operating system, for example, 5%. The third preset percentage can be a value corresponding to the free space information that has a high impact on the normal startup and stable operation of the operating system, for example, 2%. The application data can be the application-related data stored in the data partition. The low storage space mode can be a mode indicating that the remaining storage space of the data partition is low and has a low risk of affecting the normal startup and operation of the operating system. The ultra-low storage space mode can be a mode indicating that the remaining storage space of the data partition is extremely low and has a moderate risk of affecting the normal startup and operation of the operating system. The emergency mode can be a mode indicating that the remaining storage space of the data partition is extremely low and is highly likely to affect the normal startup and operation of the operating system. The event restriction operation can be an operation that restricts the execution of file operation events. The reset operation can be an operation that resets the data partition. The specified event type can be a pre-defined event type, such as a file creation event.
[0079] There are several ways to restrict the execution of events. For example, the specified event type can include: file creation event type. If the system permissions corresponding to the file operation event do not meet the preset permission conditions, the execution of the file operation event can be prevented.
[0080] The preset permission condition can be a condition for determining whether to block the execution of a file operation event. For example, if the system permission corresponding to the file operation event belongs to the preset system permission, it can indicate that the system permission corresponding to the file operation event meets the preset permission condition. If the system permission corresponding to the file operation event does not belong to the preset system permission, it can indicate that the system permission corresponding to the file operation event does not meet the preset permission condition.
[0081] Optionally, preset system permissions may include system permissions corresponding to the root user group and system permissions corresponding to the System user group. When a file operation event is triggered by either the root user group or the System user group, it indicates that the system permissions corresponding to the file operation event meet the preset permission conditions.
[0082] In this context, "root" is the super administrator user account in the operating system. This account has the highest privileges on the entire system and can easily delete or modify system components. The root user group is a special user group that typically has full access to the operating system. The system user group is a special user group in the operating system, primarily used for running system services and processes.
[0083] Optionally, when an application triggers a file operation event, it can declare the required root user group or system user group, thereby enabling the triggered file operation event to have the system permissions corresponding to the root user group or system user group.
[0084] Optionally, there are several ways to clean up application data in the data partition and perform a reset operation on the data partition. For example, the virtual file system in the kernel space can be used to notify the listener in the user space through the target communication mechanism between the kernel space and the user space. This allows the listener to trigger the application in the user space to clean up the application data in the data partition and to notify the operating system to trigger the operating system to perform a reset operation on the data partition.
[0085] Kernel space is the memory space where the operating system kernel runs. User space is the memory space where ordinary applications run. The target communication mechanism can be a mechanism for communication between kernel space and user space, for example, a network-based communication mechanism (Netlink mechanism). The listener can be a program in user space used to monitor the target communication mechanism, for example, a user-monitored Netlink program (vold).
[0086] In one embodiment, the application data in the data partition to be cleaned can be determined based on the application data stored in the data partition. For example, if it is detected that an application creates a large number of small files after the operating system starts, the application data corresponding to that application can be cleared. If there is a large amount of duplicate data of a certain application in the data partition, the duplicate data can be cleared. In this way, the remaining space of the superblock in the data partition can be increased, reducing the possibility that the operating system cannot start normally or run stably due to the superblock being full, thereby improving the operating system protection efficiency. The specific settings can be made according to the actual situation, and this embodiment of the application does not limit it.
[0087] Optionally, if the operating system fails to mount the data partition corresponding to the specified data directory during the operating system startup process, it can notify the user space to perform a reset operation through the target communication mechanism.
[0088] Therefore, when the operating system fails to boot due to the failure to mount the data partition, the target communication mechanism can be used to notify the user space to reset the data partition, thereby triggering a successful boot of the operating system and achieving boot protection for the operating system.
[0089] In one embodiment, please refer to Figure 3 , Figure 3 This is a schematic diagram illustrating the specific framework of a system protection method provided in this application embodiment. When an application running in user space triggers file operation events such as open, write, or create, it can invoke the virtual file system through a system call interface. The virtual file system then determines, based on the file path information corresponding to the file operation event, whether the target file is a file under the / data directory. When the target file is a file under the / data directory, a superblock check can be performed on the specific file system (e.g., Ext4, F2FS) corresponding to the data partition during open or create events. During write events, a pre-check of the data blocks of the file system corresponding to the data partition can be performed to obtain the percentage of free space corresponding to the data partition. When the free space percentage is less than 10%, a low storage space mode can be triggered, and a message indicating low storage space mode will be sent to the Netlink mechanism. This, in turn, will notify the user to listen to the Netlink program, prompting a reminder to clean up data. Afterward, the user will be reminded to clean up data every 4 hours and once at boot. When the free space percentage is less than 5%, an ultra-low storage space mode can be triggered, reminding the user. Afterward, the user will be reminded to clean up data every hour and once at boot. In this mode, except for the root and system user groups, all other applications will fail to create files, thus ensuring normal system operation. When the free space percentage is less than 2%, an emergency mode can be triggered, reminding the user and notifying the user to listen to the Netlink program via the Netlink mechanism, prompting a forced cleanup and reset of application data. Therefore, this application embodiment uses data such as the percentage of free space for statistical analysis, which can more accurately determine the storage status of the data partition. This can prevent the operating system from failing to boot due to the data partition being full. At the same time, it can predict when written data will overflow the data partition and effectively prevent abnormal behavior of applications from causing the operating system to fail to boot, thus effectively improving the protection efficiency of the operating system startup and operation.
[0090] As described above, this embodiment of the application, upon detecting a file operation event triggered by an application, determines whether the target file operated on by the file operation event is a file under a specified data directory through a virtual file system. If the target file is a file under a specified data directory, the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space. If the free space information triggers the operating system protection condition, a storage space adjustment operation is performed on the data partition. Therefore, by determining whether the target file operated on by the file operation event triggered by an application is a file under a specified data directory when the target file is detected, and querying the free space information of the target storage space in the data partition corresponding to the specified data directory when the target file is a file under a specified data directory, and then performing a storage space adjustment operation on the data partition when the free space information triggers the operating system protection condition, the normal startup and operation of the operating system are protected. This avoids situations where the operating system cannot start or operate normally due to the data partition being full or the target storage space within the data partition being full even if the data partition itself is not full, effectively improving the efficiency of operating system protection.
[0091] To better implement the above methods, embodiments of the present invention also provide a system protection device, which can be integrated into an electronic device, which can be a terminal.
[0092] For example, such as Figure 4 The diagram shown is a structural schematic of a system protection device provided in an embodiment of this application. This system protection device may include a determining unit 201, a checking unit 202, and an adjusting unit 203, as follows:
[0093] The determining unit 201 is used to determine, through the virtual file system, whether the target file operated by the file operation event is a file under the specified data directory when a file operation event triggered by the application is detected.
[0094] The inspection unit 202 is used to check the space of the target storage space in the data partition corresponding to the specified data directory through the virtual file system if the target file is a file under the specified data directory, so as to obtain the free space information of the target storage space.
[0095] The adjustment unit 203 is used to perform storage space adjustment operations on the data partition when the free space information triggers the operating system protection conditions.
[0096] In one embodiment, the target storage space includes a first data block and a second data block, and the inspection unit 202 includes:
[0097] If the file operation event is a file creation event or a file open event, the virtual file system performs a space check on the first data block in the data partition corresponding to the specified data directory to obtain the free space information of the first data block;
[0098] If the file operation event is a file write event, the virtual file system performs a space check on the second data block in the data partition corresponding to the specified data directory to obtain the free space information of the second data block.
[0099] In one embodiment, the above-mentioned method of performing a space check on the first data block in the data partition corresponding to the specified data directory through a virtual file system to obtain the free space information of the first data block is specifically used for:
[0100] The first check function is called through the virtual file system to obtain the number of free inodes and the total number of inodes in the superblock of the data partition corresponding to the specified data directory.
[0101] The free space information of the first data block is calculated based on the number of free index nodes and the total number of index nodes.
[0102] In one embodiment, the above-mentioned method of performing a space check on the second data block in the data partition corresponding to the specified data directory through a virtual file system to obtain the free space information of the second data block is specifically used for:
[0103] The second check function is called through the virtual file system to obtain the number of free data blocks and the total number of data blocks of the data partition corresponding to the specified data directory;
[0104] The free space information of the second data block is calculated based on the number of free data blocks and the total number of data blocks.
[0105] In one embodiment, the determining unit 201 is configured to:
[0106] When a file operation event is detected by the application, the file path information corresponding to the file operation event is obtained;
[0107] Based on file path information, the virtual file system is used to determine whether the target file of a file operation event is a file in the specified data directory.
[0108] In one embodiment, the free space information includes a free space percentage, and the adjustment unit 203 is used to:
[0109] When the percentage of free space is less than the first preset percentage but greater than the second preset percentage, the system will enter low storage space mode and remind the user to clean up application data in the data partition.
[0110] When the percentage of free space is less than the second preset percentage but greater than the third preset percentage, the system will enter the ultra-low storage space mode and remind the user to clean up the application data in the data partition. In the case of a file operation event of a specified event type, the system will perform event restriction operations.
[0111] When the percentage of free space is less than the third preset percentage, emergency mode is triggered, and application data in the data partition is cleared, and a reset operation is performed on the data partition.
[0112] In one embodiment, the specified event type includes: a file creation event type, and the above-mentioned execution event restriction operation is specifically used for:
[0113] If the system permissions corresponding to a file operation event do not meet the preset permission conditions, the execution of the file operation event will be prevented.
[0114] In one embodiment, the above-described actions of clearing application data in the data partition and performing a reset operation on the data partition are specifically used for:
[0115] Through the virtual file system in kernel space, based on the target communication mechanism between kernel space and user space, the listener in user space is notified so that the listener can trigger the application in user space to clean up the application data in the data partition, and the listener can notify the operating system so that the operating system can perform a reset operation on the data partition.
[0116] In one embodiment, the system protection device further includes a reset unit, used for:
[0117] If the operating system fails to mount the data partition corresponding to the specified data directory during the operating system startup process, it will notify the user space to perform a reset operation through the target communication mechanism.
[0118] As described above, in this embodiment, the determining unit 201, upon detecting a file operation event triggered by an application, determines whether the target file operated on by the file operation event is a file under a specified data directory through a virtual file system; the checking unit 202, if the target file is a file under a specified data directory, performs a space check on the target storage space in the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the target storage space; and the adjusting unit 203, if the free space information triggers the operating system protection condition, performs a storage space adjustment operation on the data partition. Thus, by determining whether the target file operated on by the file operation event triggered by an application is a file under a specified data directory when the file operation event is detected, and then, if the target file is a file under a specified data directory, searching for the free space information of the target storage space in the data partition corresponding to the specified data directory, and then, if the free space information triggers the operating system protection condition, performing a storage space adjustment operation on the data partition, the normal startup and operation of the operating system is protected. This avoids situations where the operating system cannot start or operate normally due to the data partition being full or the target storage space within the data partition being full even if the data partition itself is not full, effectively improving the efficiency of operating system protection.
[0119] Accordingly, this application also provides a circuit board assembly, which may include a circuit board, a processor, and a memory. The processor and the memory may be disposed on the circuit board. The memory stores a computer program, and when the computer program is executed by the processor, the processor executes any of the system protection methods provided in this application.
[0120] For example, this circuit board assembly can perform the steps of the following system protection method:
[0121] When a file operation event triggered by an application is detected, the virtual file system determines whether the target file operated on by the file operation event is a file under the specified data directory. If the target file is a file under the specified data directory, the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space. If the free space information triggers the operating system protection condition, the storage space adjustment operation for the data partition is performed.
[0122] Therefore, the circuit board assembly provided in this application embodiment can, upon detecting a file operation event triggered by an application, determine through a virtual file system whether the target file operated by the file operation event is a file under a specified data directory; if the target file is a file under a specified data directory, then through the virtual file system, perform a space check on the target storage space in the data partition corresponding to the specified data directory to obtain free space information of the target storage space; if the free space information triggers operating system protection conditions, perform a storage space adjustment operation on the data partition. Thus, by determining whether the target file operated by the file operation event is a file under a specified data directory when a file operation event triggered by an application is detected, and then, if the target file is a file under a specified data directory, searching for free space information of the target storage space in the data partition corresponding to the specified data directory, and then, if the free space information triggers operating system protection conditions, performing a storage space adjustment operation on the data partition, the normal startup and operation of the operating system is protected. This avoids situations where the operating system cannot start or operate normally due to the data partition being full or the target storage space within the data partition being full even if the data partition is not full, effectively improving the efficiency of operating system protection.
[0123] Optionally, the circuit board may include, but is not limited to, circuit boards for televisions, monitors, interactive smart tablets, commercial display devices, etc.
[0124] Furthermore, the detailed steps of the above method can be found in the description of the foregoing embodiments, and will not be repeated here.
[0125] Accordingly, this application also provides an electronic device, which can be a terminal, such as a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. Alternatively, the electronic device can be a server.
[0126] like Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 300 includes a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 and the memory 302 are electrically connected. Those skilled in the art will understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0127] The processor 301 is the control center of the electronic device 300. It connects various parts of the electronic device 300 through various interfaces and lines. By running or loading software programs and / or units stored in the memory 302, and calling data stored in the memory 302, it executes various functions of the electronic device 300 and processes data. The processor 301 may be a CPU, GPU, network processor (NP), etc., and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0128] In this embodiment, the processor 301 in the electronic device 300 loads the instructions corresponding to the processes of one or more applications into the memory 302 according to the following steps, and the processor 301 runs the applications stored in the memory 302 to realize various functions, such as:
[0129] When a file operation event triggered by an application is detected, the virtual file system determines whether the target file operated on by the file operation event is a file under the specified data directory. If the target file is a file under the specified data directory, the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space. If the free space information triggers the operating system protection condition, the storage space adjustment operation for the data partition is performed.
[0130] This solution, upon detecting a file operation event triggered by an application, uses a virtual file system to determine if the target file is located in a specified data directory. If the target file is in that directory, the virtual file system checks the target storage space within the corresponding data partition to determine its free space. If this free space information triggers operating system protection conditions, storage space adjustments are made to the data partition. This approach protects the normal startup and operation of the operating system, preventing situations where the operating system fails to boot or function properly due to a full data partition or a partially full target storage space. This effectively improves operating system protection efficiency.
[0131] Furthermore, the various functions implemented by running the application stored in memory 302 can also be found in the description of the foregoing embodiments, and will not be repeated here.
[0132] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0133] Optional, such as Figure 5 As shown, the electronic device 300 also includes: a touch display screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch display screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307. Those skilled in the art will understand that... Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0134] The touch display screen 303 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 303 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 301. It can also receive and execute commands from the processor 301. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 301 to determine the type of touch event. Subsequently, the processor 301 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 303 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 303 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 303 can also be used as part of the input unit 306 to achieve input functions.
[0135] The radio frequency circuit 304 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other electronic devices, and to transmit and receive signals with network devices or other electronic devices.
[0136] Audio circuitry 305 can be used to provide an audio interface between a user and an electronic device via a speaker and a microphone. Audio circuitry 305 converts received audio data into electrical signals, transmits them to the speaker, and the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 305, converted back into audio data, and then processed by processor 301 before being transmitted via radio frequency circuitry 304 to, for example, another electronic device, or output to memory 302 for further processing. Audio circuitry 305 may also include an earphone jack to facilitate communication between peripheral headphones and electronic devices.
[0137] The input unit 306 can be used to receive input target video and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0138] Power supply 307 is used to supply power to various components of electronic device 300. Optionally, power supply 307 can be logically connected to processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 307 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0139] although Figure 5 As not shown in the diagram, the electronic device 300 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.
[0140] In the above embodiments, the descriptions of each embodiment have different focuses. Parts not described in detail in a particular embodiment can be found in the relevant descriptions of other embodiments. It should be noted that the electronic device provided in this application's embodiments belongs to the same concept as the system protection method described in the above embodiments, and its specific implementation process is detailed in the above method embodiments, and will not be repeated here.
[0141] As can be seen from the above, the electronic device provided in this application embodiment can, upon detecting a file operation event triggered by an application, determine through a virtual file system whether the target file operated by the file operation event is a file under a specified data directory; if the target file is a file under a specified data directory, the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain free space information of the target storage space; if the free space information triggers operating system protection conditions, a storage space adjustment operation is performed on the data partition. Thus, by determining whether the target file operated by the file operation event is a file under a specified data directory when a file operation event triggered by an application is detected, and then, if the target file is a file under a specified data directory, searching for free space information of the target storage space in the data partition corresponding to the specified data directory, and then, if the free space information triggers operating system protection conditions, performing a storage space adjustment operation on the data partition, the normal startup and operation of the operating system is protected. This avoids situations where the operating system cannot start or operate normally due to the data partition being full or the target storage space within the data partition being full even if the data partition itself is not full, effectively improving the efficiency of operating system protection.
[0142] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0143] Therefore, embodiments of this application provide a computer-readable storage medium, including a computer program, which, when run on an electronic device, causes the electronic device to perform any of the system protection methods provided in embodiments of this application. For example, the computer program can perform the steps of the following system protection method:
[0144] When a file operation event triggered by an application is detected, the virtual file system determines whether the target file operated on by the file operation event is a file under the specified data directory. If the target file is a file under the specified data directory, the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space. If the free space information triggers the operating system protection condition, the storage space adjustment operation for the data partition is performed.
[0145] This solution, upon detecting a file operation event triggered by an application, uses a virtual file system to determine if the target file is located in a specified data directory. If the target file is in that directory, the virtual file system checks the target storage space within the corresponding data partition to determine its free space. If this free space information triggers operating system protection conditions, storage space adjustments are made to the data partition. This approach protects the normal startup and operation of the operating system, preventing situations where the operating system fails to boot or function properly due to a full data partition or a partially full target storage space. This effectively improves operating system protection efficiency.
[0146] Furthermore, the detailed steps of the above method can be found in the description of the foregoing embodiments, and will not be repeated here.
[0147] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0148] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0149] Since the computer program stored in the computer-readable storage medium can execute any of the system protection methods provided in the embodiments of this application, the beneficial effects that any of the system protection methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0150] According to one aspect of this application, a computer program product is also provided, comprising a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the methods provided in various optional implementations of the above embodiments.
[0151] In the above embodiments of system protection devices, computer-readable storage media, circuit board assemblies, electronic devices, and computer program products, the descriptions of each embodiment have different focuses. Parts not described in detail in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes and beneficial effects of the system protection devices, computer-readable storage media, computer program products, circuit board assemblies, electronic devices, and their corresponding units described above can be referred to the description of the system protection method in the above embodiments, and will not be repeated here.
[0152] The foregoing has provided a detailed description of a system protection method, apparatus, circuit board assembly, electronic device, computer-readable storage medium, and computer program product provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A system protection method, characterized in that, include: When a file operation event triggered by an application is detected, the virtual file system is used to determine whether the target file operated on by the file operation event is a file under the specified data directory. If the target file is a file under the specified data directory, then the virtual file system performs a space check on the target storage space in the data partition corresponding to the specified data directory to obtain the free space information of the target storage space; If the free space information triggers operating system protection conditions, a storage space adjustment operation is performed on the data partition.
2. The system protection method as described in claim 1, characterized in that, The target storage space includes a first data block and a second data block in the data partition. The step of performing a space check on the target storage space in the data partition corresponding to the specified data directory using the virtual file system to obtain free space information of the target storage space includes: If the file operation event is a file creation event or a file open event, the virtual file system performs a space check on the first data block in the data partition corresponding to the specified data directory to obtain the free space information of the first data block; If the file operation event is a file write event, the virtual file system performs a space check on the second data block in the data partition corresponding to the specified data directory to obtain the free space information of the second data block.
3. The system protection method as described in claim 2, characterized in that, The step of performing a space check on the first data block in the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the first data block includes: The virtual file system calls the first check function to obtain the number of free inodes and the total number of inodes in the superblock of the data partition corresponding to the specified data directory; Based on the number of free index nodes and the total number of index nodes, the free space information of the first data block is calculated.
4. The system protection method as described in claim 2, characterized in that, The step of performing a space check on the second data block in the data partition corresponding to the specified data directory through the virtual file system to obtain the free space information of the second data block includes: The second checking function is invoked through the virtual file system to obtain the number of free data blocks and the total number of data blocks of the data partition corresponding to the specified data directory; Based on the number of free data blocks and the total number of data blocks, the free space information of the second data block is calculated.
5. The system protection method as described in claim 1, characterized in that, The step of determining whether the target file operated on by the file operation event is a file under the specified data directory through the virtual file system when a file operation event triggered by the application is detected includes: Upon detecting a file operation event in the application, obtain the file path information corresponding to the file operation event; Based on the file path information, the virtual file system determines whether the target file operated on by the file operation event is a file under the specified data directory.
6. The system protection method according to any one of claims 1 to 5, characterized in that, The free space information includes a free space percentage. When the free space information triggers operating system protection conditions, the storage space adjustment operation for the data partition includes: When the percentage of free space is less than a first preset percentage but greater than a second preset percentage, the system will trigger a low storage space mode and remind the user to clear application data in the data partition. When the percentage of free space is less than a second preset percentage but greater than a third preset percentage, the system will trigger the entry into ultra-low storage space mode and remind the user to clean up the application data in the data partition. In the case that the file operation event is a specified event type, the system will perform an event restriction operation. When the percentage of free space is less than a third preset percentage, an emergency mode is triggered, and application data in the data partition is cleared, and a reset operation is performed on the data partition.
7. The system protection method as described in claim 6, characterized in that, The specified event types include: file creation event types, and the execution event restriction operations include: If the system permissions corresponding to the file operation event do not meet the preset permission conditions, the execution of the file operation event is prevented.
8. The system protection method as described in claim 6, characterized in that, The process of cleaning up application data in the data partition and performing a reset operation on the data partition includes: Through the virtual file system in kernel space, based on the target communication mechanism between kernel space and user space, the listener in user space is notified so that the listener triggers the application in user space to clean up the application data in the data partition, and the listener notifies the operating system to trigger the operating system to perform a reset operation on the data partition.
9. The system protection method as described in claim 8, characterized in that, The method further includes: If the operating system fails to mount the data partition corresponding to the specified data directory during the operating system startup process, it notifies the user space to perform a reset operation through the target communication mechanism.
10. A system protection device, characterized in that, include: The determining unit is used to determine, in the event of a file operation event triggered by an application, whether the target file operated on by the file operation event is a file under a specified data directory through a virtual file system; The checking unit is used to check the space of the target storage space in the data partition corresponding to the specified data directory through the virtual file system if the target file is a file under the specified data directory, so as to obtain the free space information of the target storage space. The adjustment unit is used to perform storage space adjustment operations on the data partition when the free space information triggers operating system protection conditions.
11. A circuit board assembly, characterized in that, The system includes a circuit board, a processor, and a memory, the processor and memory being disposed on the circuit board, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of the system protection method according to any one of claims 1 to 9.
12. A storage medium, characterized in that, Includes a computer program, which, when run on an electronic device, causes the electronic device to perform the steps of the system protection method according to any one of claims 1 to 9.
