Processing method and electronic device for deletion operation in network file system
By using the security authorization interface function provided by the Linux security module framework in the custom kernel module, custom file operation functions are implemented to intercept and customize file deletion operations, the problem of users in network file systems being unable to recover files and folders accidentally deleted, realizing data recovery function and maintaining system stability.
Patent Information
- Application Number
- CN202411898408.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-20
AI Technical Summary
In the network file system mounted on the client computer, users cannot recover the accidentally deleted files and folders through normal methods, especially without modifying the system call table in the system kernel.
By using the security authorization interface function provided by the Linux security module framework in the custom kernel module, customize file operation functions, intercept and customize file deletion operations, so as to back up before the file or folder is deleted, and the data recovery function is realized.
It realizes the backup of files or folders before they are deleted, thereby realizing the data recovery function, solving the problem that users cannot recover files and folders that have been deleted by mistake, and does not affect the stability of the system kernel.
Smart Images

Figure CN119336715B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to a method and electronic device for processing a deletion operation in a network file system. Background Art
[0002] In the network file system mounted on the client computer, files or folders deleted by users are not sent to the local Recycle Bin. If the network file system server does not dump or back them up to the Recycle Bin, the files or folders are physically deleted, and users cannot recover the accidentally deleted files and folders through normal means.
[0003] To address the above problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a method and electronic device for processing deletion operations in a network file system, which at least solves the problem that in a network file system mounted on a client computer, a user cannot recover accidentally deleted files and folders in a normal manner without modifying the system call table in the system kernel.
[0005] According to one aspect of an embodiment of the present application, a method for processing a delete operation in a network file system is provided, comprising: in a custom file operation function, obtaining a program name of a delete operation currently being executed in the network file system, wherein the custom file operation function is implemented in a custom kernel module through a security authorization interface function provided by a Linux security module framework, the interface function comprising: an inode_rmdir function and an inode_unlink function, and the delete operation is used to delete a folder or file in the network file system; detecting whether the program name meets a preset condition; if the program name meets the preset condition, modifying a default delete function that executes the delete operation to a custom delete function; if the program name does not meet the preset condition, using the default delete function to execute the default delete operation process of the network file system.
[0006] Optionally, detecting whether the program name meets the preset condition includes: if the deletion operation is initiated by a file manager or a command line tool, determining that the program name meets the preset condition; otherwise, determining that the program name does not meet the preset condition.
[0007] Optionally, before detecting whether the program name meets the preset conditions, the above method also includes: defining global variables, global pointer variables and custom deletion functions in the custom kernel module respectively, wherein the global variables are used to store the pointer set of the custom file operation function, and the global pointer variables are used to store the address of the pointer set of the original file operation function.
[0008] Optionally, after calling the custom file operation function to detect whether the program name meets the preset conditions, the above method also includes: obtaining the inode pointer of the parent directory of the folder or file to be deleted when the deletion operation is performed; adding the data in the structure inode_operations pointed to by the data member i_op in the inode structure pointed to by the inode pointer to the global variable; assigning the pointers of the rmdir function and the unlink function stored in the global variable to the custom deletion function; assigning the global pointer variable to the value of the data member i_op in the inode structure pointed to by the inode pointer; and updating the value of the data member i_op in the inode structure pointed to by the inode pointer to the address of the global variable.
[0009] Optionally, the default deletion function that performs the deletion operation is modified to a custom deletion function, including: the custom deletion function does not perform any deletion-related processing, restores the value of the data member i_op in the inode structure pointed to by the inode pointer to the global pointer variable, and returns 0 to notify the system kernel that the deletion operation has been completed.
[0010] Optionally, the above method further includes: after the custom file operation function is called, the custom file operation function returns 0 and returns the execution to the system kernel.
[0011] Optionally, after the default deletion function for executing the deletion operation is modified to a custom deletion function, the method further comprises: using a custom dump program to copy the folder or file to be deleted and then delete or move it to a new storage location.
[0012] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including: a processor, and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes the above method.
[0013] According to another aspect of the embodiments of the present application, a non-transitory machine-readable medium storing computer instructions is also provided, where the computer instructions are used to enable a computer to execute the above method.
[0014] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, which is used to enable the computer to execute the above method when the computer program is executed by a processor of the computer.
[0015] Beneficial effects of the embodiments of the present application:
[0016] In an embodiment of the present application, a program name of a deletion operation currently being executed in a network file system is obtained in a custom file operation function, wherein the custom file operation function is implemented in a custom kernel module through a security authorization interface function provided by a Linux security module framework, and the interface function includes: an inode_rmdir function and an inode_unlink function, and the deletion operation is used to delete folders or files in the network file system; detecting whether the program name meets a preset condition; if the program name meets the preset condition, modifying the default deletion function that performs the deletion operation to a custom deletion function; if the program name does not meet the preset condition, using the default deletion function to execute the default deletion operation process of the network file system, by implementing a custom file operation function in a custom kernel module using a security authorization interface function provided by a Linux security module framework, and using the custom file operation function to implement interception and custom processing of file deletion operations, thereby achieving a technical effect of being able to back up files or folders before they are deleted, thereby achieving a data recovery function.
[0017] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can be obtained based on these drawings without creative work.
[0019] Figure 1 is a flowchart of a method for processing a delete operation in a network file system according to an embodiment of the present application;
[0020] Figure 2 It is a flow structure block diagram of a processing device for a delete operation in a network file system according to an embodiment of the present application;
[0021] Figure 3 Schematic diagram of the structure of the electronic device of this embodiment. DETAILED DESCRIPTION
[0022] Embodiments of the present embodiment will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present embodiment are shown in the accompanying drawings, it should be understood that the present embodiment can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, which are instead provided for a more thorough and complete understanding of the present embodiment. It should be understood that the drawings and embodiments of the present embodiment are only for exemplary purposes and are not intended to limit the scope of protection of the present embodiment.
[0023] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0024] Network File System, or NFS for short, is a distributed file system protocol. NFS allows client computers to access files on a remote server over a network. NFS is widely used in Unix and Unix-like systems (such as Linux).
[0025] Hooking system calls is a technique that allows you to insert custom behaviors before or after a system call is executed. This is usually used to monitor, modify, or enhance the functionality of system calls. Different operating systems have different ways to implement hooking system calls.
[0026] In the related art, in the network file system mounted on the client computer, without modifying the system call table in the system kernel, the user cannot recover the accidentally deleted files and folders through normal means. In order to solve this problem, some existing solutions are as follows:
[0027] Solution 1: Hook the system call at the kernel layer on the client computer, and implement file dumping by hooking the sys_rmdir and sys_unlink system call functions at the kernel layer. Modifying the system call table will cause the stability of related applications or operating systems to decline. Some systems do not disclose the system call table address or add a write protection mechanism to the system call table data, thus limiting the implementation of this hook.
[0028] Solution 2: The network file system server on the server computer supports the file recycling bin mechanism. Some types of network file system servers support the recycling bin mechanism, such as samba and windows shared folders, while some network file systems do not, such as nfs, rclone webdav, etc.
[0029] In order to solve the deficiencies of the prior art, relevant solutions are provided in the embodiments of the present application, which are described in detail below.
[0030] Figure 1is a flowchart of a method for processing a delete operation in a network file system according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0031] Step S102, in the custom file operation function, obtain the program name of the deletion operation currently executed in the network file system, wherein the custom file operation function is implemented in the custom kernel module through the security authorization interface function provided by the Linux security module framework, and the interface function includes: inode_rmdir function and inode_unlink function, and the deletion operation is used to delete folders or files in the network file system.
[0032] When executing step S102, in the custom file operation function, the name of the program currently executing the deletion operation is obtained, where the deletion operation is used to delete a folder or file in the network file system. In an embodiment of the present application, the name of the program currently executing the deletion operation is obtained from a public global variable describing the current execution process in the system kernel, current->group_leader->comm, where comm is a character array used to store the name of the program currently executing the deletion operation.
[0033] The custom file operation function is implemented in the custom kernel module through the security authorization interface function provided by the Linux security module framework. The interface functions include: inode_rmdir function and inode_unlink function.
[0034] In the Linux kernel, the inode_rmdir function and the inode_unlink function are two functions used for file system operations.
[0035] The prototype of the inode_rmdir function is int inode_rmdir(struct inode *dir, structdentry *dentry), where
[0036] The parameter struct inode *dir is a pointer to the inode (index node) structure of the parent directory of the folder to be deleted; the parameter struct dentry *dentry is a pointer to the directory entry to be deleted.
[0037] The prototype of the inode_unlink function is int inode_unlink(struct inode *dir, structdentry *dentry), where
[0038] The parameter struct inode *dir is a pointer to the inode (index node) structure of the parent directory containing the file to be deleted; the parameter struct dentry *dentry is a pointer to the file to be deleted.
[0039] Linux Security Module, also known as Linux Secrity Module, or LSM in short, is a security framework in the Linux kernel that allows different security modules (such as SELinux, AppArmor, Smack, etc.) to coexist in the same kernel. LSM provides a set of common security hooks that can be called when the kernel performs critical operations, allowing security modules to insert their own security policies when these operations occur.
[0040] According to an optional embodiment of the present application, the above-mentioned custom file operation functions are custom inode_rmdir function and inode_unlink function.
[0041] The above-mentioned custom kernel module is different from the system kernel module and is a separately developed module. The module uses the interface function provided by the LSM framework to register the custom inode_rmdir function and inode_unlink function. By implementing the custom inode_rmdir and inode_unlink functions through the custom kernel module, the problem of decreased system kernel stability can be avoided.
[0042] Step S104, detecting whether the program name meets a preset condition.
[0043] According to an optional embodiment of the present application, step S104 is executed to detect whether the program name meets the preset conditions, including the following steps: if the deletion operation is initiated by a file manager or command line tool, determine that the program name meets the preset conditions; otherwise, determine that the program name does not meet the preset conditions.
[0044] When executing step S104, the deletion operation that is not performed by the file manager and the command line to delete the file or folder is filtered out through the customized inode_rmdir function and inode_unlink function. That is, if the deletion operation is initiated by the file manager or the command line tool, it means that the deletion operation is initiated by the user and meets the preset condition. Otherwise, it does not meet the preset condition.
[0045] Step S106: If the program name meets the preset condition, the default deletion function for executing the deletion operation is modified to a custom deletion function.
[0046] In this step, if the deletion operation is initiated by a file manager or a command line tool, the default deletion function that performs the deletion operation is modified to a custom deletion function.
[0047] Step S108: If the program name does not meet the preset condition, a default deletion function is used to execute the default deletion operation flow of the network file system.
[0048] In this step, if the deletion operation is not initiated by the file manager or command line tool, let the system continue to execute the default deletion process.
[0049] The above technical solution provided in the embodiment of the present application realizes a custom file operation function by utilizing the security authorization interface function provided by the Linux security module framework in a custom kernel module, and utilizes the custom file operation function to implement interception and custom processing of file deletion operations, thereby realizing the technical effect of being able to back up files or folders before they are deleted, thereby realizing the data recovery function.
[0050] According to an optional embodiment of the present application, before executing step S104 to detect whether the program name meets the preset conditions, it is also necessary to define global variables, global pointer variables and custom deletion functions in the custom kernel module respectively, wherein the global variables are used to store the pointer set of the custom file operation function, and the global pointer variables are used to store the address of the pointer set of the original file operation function.
[0051] In the embodiment of the present application, a global variable "struct inode_operations g_iops" and a global pointer variable "struct inode_operations *g_ptr_iops_original" are defined.
[0052] The global variable g_iops is used to store a set of custom pointers to file-related operation functions in the inode parameter instance object of the LSM framework interface functions inode_rmdir and inode_unlink (that is, a set of pointers to custom file operation functions, for example, pointers to custom inode_rmdir and inode_unlink functions).
[0053] The global pointer variable g_ptr_iops_original is used to store the memory address of the pointer set of file-related operation functions in the original inode parameter object instance. This pointer is used to save the address of the pointer set of the native file operation function so as to restore the default behavior when custom behavior is not needed.
[0054] In addition, it is also necessary to define a custom deletion function "int stub_rmdir_unlink(struct inode *dir, struct dentry *dentry)" after the hook operation is executed. When a file or folder in the network file system is attempted to be deleted, the system will call the custom deletion function instead of the default deletion function.
[0055] According to another optional embodiment of the present application, after executing step S104 to detect whether the program name meets the preset conditions, the following steps need to be performed:
[0056] 1) Get the inode pointer of the parent directory of the folder or file to be deleted when the delete operation is performed; add the data in the structure inode_operations pointed to by the data member i_op in the inode structure pointed to by the inode pointer to the global variable.
[0057] An inode (index node) is a structure data structure used to store metadata information of files in a file system. In the Linux kernel, an inode structure is used to represent a file or directory in a file system. The inode structure contains a data member named i_op, which is a pointer to a struct inode_operations structure. Struct inode_operations defines a set of file operation function pointers, which are used to handle various operations in the file system, such as creation, deletion, and linking.
[0058] In this step, the parent directory inode pointer parameter of the to-be-deleted folder or file of type struct inode * is obtained from the system, referred to as ptr_parent_dir_inode. Through the data member i_op of ptr_parent_dir_inode, the data in the struct inode_operations structure pointed to in the memory address is copied to the global variable g_iops.
[0059] By copying the original struct inode_operations structure data to the global variable g_iops, specific function pointers (such as rmdir and unlink) can be modified based on g_iops without affecting other file operation functions. This ensures that other file operations (such as lookup, create, etc.) still use the system default implementation, and only specific delete operations are customized.
[0060] 2) Assign the pointers of the rmdir function and unlink function stored in the global variable to the custom deletion function.
[0061] In this step, the rmdir and unlink data members in the global variable g_iops object are assigned to the custom deletion function stub_rmdir_unlink.
[0062] The rmdir function and the unlink function are functions that the system uses to execute the default deletion operation process.
[0063] 3) Assign the global pointer variable to the value of the data member i_op in the inode structure pointed to by the inode pointer.
[0064] In this step, the global pointer variable is assigned the value of the data member i_op in the inode structure pointed to by the inode pointer in order to back up the group file operation function pointer in the struct inode_operations structure pointed to by i_op for recovery processing.
[0065] 4) Update the value of the data member i_op in the inode structure pointed to by the inode pointer to the address of the global variable.
[0066] In this step, the value of the data member i_op of ptr_parent_dir_inode is updated to &g_iop (that is, the address of the global variable g_iops).
[0067] Through the above steps 2) and 4), the system kernel will automatically enter the custom deletion function stub_rmdir_unlink for execution through the deletion function interface pointed to by the i_op pointer set in ptr_parent_dir_inode.
[0068] As an optional embodiment of the present application, after the custom file operation function is called, the custom file operation function returns 0 and returns the execution to the system kernel.
[0069] In some optional embodiments of the present application, step S106 is executed to modify the default deletion function that performs the deletion operation into a custom deletion function, including the following steps: the custom deletion function does not perform any deletion-related processing, restores the value of the data member i_op in the inode structure pointed to by the inode pointer to the global pointer variable, and returns 0 to notify the system kernel that the deletion operation has been completed.
[0070] The custom deletion function stub_rmdir_unlink does not perform any deletion-related processing. It restores the value of the data member i_op in the received parameter struct inode *dir to the global pointer variable g_iops_original, and then returns 0 to inform the system kernel that the deletion operation is successful.
[0071] By restoring the data member i_op in the inode structure to a global pointer variable, it is ensured that other subsequent operations will not be affected.
[0072] In other optional embodiments of the present application, after executing step S106 to modify the default deletion function that performs the deletion operation into a custom deletion function, a custom dump program can be used to copy the folders or files to be deleted and then delete or move them to a new storage location for recovery, thereby solving the problem that in a network file system, users cannot recover accidentally deleted files and folders through normal means.
[0073] The above technical solution proposed in the embodiment of the present application avoids various restrictions on hooking system calls, and only hooks the relevant function interface in the inode object instance in the system kernel at a specific time point when the deletion is executed. The hook is canceled in real time after the deletion operation is completed, which has little intrusion on the system kernel, simple programming implementation logic, and high operation stability.
[0074] Based on the method for processing a delete operation in a network file system provided in the embodiment of the present application, the embodiment of the present application also provides a device for processing a delete operation in a network file system, such as Figure 2 As shown, the device comprises:
[0075] The acquisition module 20 is used to obtain the program name of the deletion operation currently executed in the network file system in the custom file operation function, wherein the custom file operation function is implemented in the custom kernel module through the security authorization interface function provided by the Linux security module framework, and the interface function includes: inode_rmdir function and inode_unlink function, and the deletion operation is used to delete folders or files in the network file system.
[0076] In an embodiment of the present application, in a custom file operation function, the name of the program currently running the deletion operation is obtained, where the deletion operation is used to delete a folder or file in a network file system. The custom file operation function is implemented in a custom kernel module through a security authorization interface function provided by the Linux security module framework, and the interface functions include: inode_rmdir function and inode_unlink function.
[0077] In the Linux kernel, the inode_rmdir function and the inode_unlink function are two functions used for file system operations.
[0078] Linux Security Module, also known as Linux Secrity Module, or LSM in short, is a security framework in the Linux kernel that allows different security modules (such as SELinux, AppArmor, Smack, etc.) to coexist in the same kernel. LSM provides a set of common security hooks that can be called when the kernel performs critical operations, allowing security modules to insert their own security policies when these operations occur.
[0079] According to an optional embodiment of the present application, the above-mentioned custom file operation functions are custom inode_rmdir function and inode_unlink function.
[0080] The above-mentioned custom kernel module is different from the system kernel module and is a separately developed module. The module uses the interface function provided by the LSM framework to register the custom inode_rmdir function and inode_unlink function. By implementing the custom inode_rmdir and inode_unlink functions through the custom kernel module, the problem of decreased system kernel stability can be avoided.
[0081] The detection module 22 is used to detect whether the program name meets the preset conditions.
[0082] In an embodiment of the present application, the deletion operation that is not performed by the file manager and the command line to delete the file or folder is filtered out by the customized inode_rmdir function and inode_unlink function. That is, if the deletion operation is initiated by the file manager or the command line tool, it means that the deletion operation is initiated by the user and meets the preset condition. Otherwise, it does not meet the preset condition.
[0083] The first processing module 24 is used to modify the default deletion function that performs the deletion operation into a custom deletion function when the program name meets the preset condition.
[0084] In an embodiment of the present application, if a deletion operation is initiated by a file manager or a command line tool, the default deletion function for executing the deletion operation is modified to a custom deletion function.
[0085] The second processing module 26 is used to use a default deletion function to execute a default deletion operation flow of the network file system when the program name does not meet the preset conditions.
[0086] In an embodiment of the present application, if the deletion operation is not initiated by a file manager or a command line tool, the system continues to execute the default deletion process.
[0087] The above-mentioned device provided in the embodiment of the present application realizes a custom file operation function by utilizing the security authorization interface function provided by the Linux security module framework in a custom kernel module, and utilizes the custom file operation function to implement interception and custom processing of file deletion operations, thereby realizing the technical effect of being able to back up files or folders before they are deleted, thereby realizing the data recovery function.
[0088] It should be noted that Figure 2 The preferred implementation of the embodiment shown can be referred to Figure 1 The relevant description of the illustrated embodiment will not be repeated here.
[0089] The embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program executable by the at least one processor, and the computer program is used to enable the electronic device to perform the method of the embodiment of the present application when executed by the at least one processor.
[0090] An embodiment of the present application also provides a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiment of the present application.
[0091] The embodiment of the present application also provides a computer program product, including a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiment of the present application.
[0092] refer to Figure 3 , the structural block diagram of the electronic device that can be used as the server or client of the embodiment of the present application will now be described, which is an example of the hardware device that can be applied to various aspects of the present application. The electronic device is intended to represent various forms of digital electronic computer equipment, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described and / or required herein.
[0093] like Figure 3As shown, the electronic device includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 302 or a computer program loaded from a storage unit 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device can also be stored. The computing unit 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 the bus 304.
[0094] Multiple components in the electronic device are connected to the I / O interface 305, including: an input unit 306, an output unit 307, a storage unit 308, and a communication unit 309. The input unit 306 can be any type of device that can input information to the electronic device, and the input unit 306 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device. The output unit 307 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 308 can include but is not limited to a disk, an optical disk. The communication unit 309 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0095] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a CPU, a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 301 performs the various methods and processes described above. For example, in some embodiments, the method embodiments of the present application may be implemented as a computer program, which is tangibly contained in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on an electronic device via a ROM 302 and / or a communication unit 309. In some embodiments, the computing unit 301 may be configured to perform the above method in any other appropriate manner (e.g., by means of firmware).
[0096] The computer program for implementing the method of the embodiment of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0097] In the context of the embodiments of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, or infrared system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0098] It should be noted that the term "including" and its variations used in the embodiments of the present application are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present application are illustrative and not restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0099] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0100] The various steps described in the method implementation methods provided in the embodiments of the present application can be performed in different orders and / or in parallel. In addition, the method implementation methods may include additional steps and / or omit the steps shown. The scope of protection of the present application is not limited in this respect.
[0101] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments refer to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.
[0102] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A method for processing a delete operation in a network file system, characterized in that: include: In the custom file operation function, the program name of the deletion operation currently executed in the network file system is obtained, wherein the custom file operation function is implemented in the custom kernel module through the security authorization interface function provided by the Linux security module framework, and the interface function includes: inode_rmdir function and inode_unlink function, and the deletion operation is used to delete a folder or file in the network file system; Detecting whether the program name meets the preset conditions; If the program name meets the preset condition, the default deletion function for executing the deletion operation is modified to a custom deletion function; After modifying the default deletion function for executing the deletion operation into a custom deletion function, the folder or file to be deleted is copied and deleted or moved to a new storage location using a custom dump program; If the program name does not meet the preset condition, the default deletion function is used to execute the default deletion operation process of the network file system.
2. The method according to claim 1, characterized in that Checking whether the program name meets the preset conditions includes: If the deletion operation is initiated by a file manager or a command line tool, determining that the program name meets a preset condition; Otherwise, it is determined that the program name does not meet the preset condition.
3. The method according to claim 1, characterized in that Before detecting whether the program name meets the preset condition, the method further includes: In the custom kernel module, global variables, global pointer variables and the custom delete function are defined respectively, wherein: The global variable is used to store a pointer set of the custom file operation function. The global pointer variable is used to store the address of the pointer set of the original file operation function.
4. The method according to claim 3, characterized in that After detecting whether the program name meets the preset conditions, the method further includes: Obtaining the inode pointer of the parent directory of the folder or file to be deleted when performing the deletion operation; Add the data in the structure inode_operations pointed to by the data member i_op in the inode structure pointed to by the inode pointer to the global variable; Assigning the pointers of the rmdir function and the unlink function stored in the global variable to the custom deletion function; Assign the global pointer variable to the value of the data member i_op in the inode structure pointed to by the inode pointer; The value of the data member i_op in the inode structure pointed to by the inode pointer is updated to the address of the global variable.
5. The method according to claim 4, characterized in that The default delete function for performing the delete operation is modified to a custom delete function, including: The custom deletion function does not perform any deletion-related processing, restores the value of the data member i_op in the inode structure pointed to by the inode pointer to the global pointer variable, and returns 0 to notify the system kernel that the deletion operation has been completed.
6. The method according to claim 1, characterized in that The method further comprises: After the custom file operation function is called, the custom file operation function returns 0 and returns the execution to the system kernel.
7. An electronic device comprising: A processor and a memory storing a program, wherein the program comprises instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 6.
8. A non-transitory machine-readable medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor of a computer, the computer is used to cause the computer to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
File recovery and recovery method of network file system
CN118093262A