File cutting method of Linux system and electronic equipment

By finding and cropping redundant files in Linux systems, the problems of slower startup time and poor performance caused by increasing system size and complexity are solved, and system performance improvement and startup time are achieved.

CN119025115APending Publication Date: 2024-11-26HISENSE HOME APPLIANCES GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310596694.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-24
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

With the enhancement and expansion of Linux system functions, its size and complexity increase, resulting in slower system startup time and poor performance.

Method used

By finding the files used by the target program at compile time and runtime in the Linux system, including component files, function implementation files, system files and unused or opened files that make up the target program, determine the minimized target file and based on the These files cut the system, reduce redundant files and reduce system memory usage.

Benefits of technology

It realizes the reduction of the size and complexity of the Linux system, improves system performance and startup time, and ensures the accuracy and efficiency of the target files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025115A_ABST
    Figure CN119025115A_ABST
Patent Text Reader

Abstract

The invention provides a file clipping method of a Linux system and electronic equipment. The method is used for reducing system memory occupation. Comprising the following steps: searching a plurality of first files used when a target program is compiled in a Linux system by utilizing a preset static inspection tool; searching a plurality of second files used during the running of the target program, a plurality of third files not used during the running of the target program and a plurality of fourth files opened during the running of the target program in the Linux system by utilizing a preset dynamic checking tool, the plurality of second files comprise function implementation files for implementing functions in the target program, and the plurality of fourth files at least comprise system files used when the Linux system runs; obtaining a target file of the target program according to the plurality of first files, the plurality of second files, the plurality of third files and the plurality of fourth files; and cutting a root file of the Linux system based on the target file of each target program in the Linux system.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] Linux is a free and open source operating system that is widely used in servers, embedded devices, desktop computers, etc. Due to its openness and flexibility, Linux can be customized and optimized according to different application scenarios to meet the needs of different users.

[0003] However, as the functions of the Linux system continue to be enhanced and expanded, its size and complexity are also increasing, resulting in an increase in system memory usage, so there will be problems such as slow system startup time and poor performance. Summary of the invention

[0004] In an exemplary embodiment of the present disclosure, a file trimming method and electronic device of a Linux system are provided, which are used to trim redundant files in a Linux system, reduce the size and complexity of the Linux system, reduce the system memory usage, so as to improve system performance and speed up system startup time.

[0005] A first aspect of the present disclosure provides a file cutting method for a Linux system, the method comprising:

[0006] In response to a file trimming instruction sent by a user, using a preset static checking tool, searching in a Linux system for a plurality of first files used when a target program is compiled, wherein the plurality of first files at least include component files constituting the target program; and

[0007] Using a preset dynamic checking tool, searching in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files that implement various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running;

[0008] Obtaining a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files;

[0009] The root file of the Linux system is trimmed based on the target files of each target program in the Linux system.

[0010] In this embodiment, by searching for multiple first files used by each target program in the Linux system during compilation, multiple second files used during runtime, multiple third files not used during runtime, and multiple fourth files opened during runtime, the minimized target files used by each target program during runtime are determined respectively, and then the root files of the Linux system are trimmed based on the target files of each target program. Thus, in the embodiment of the present application, the redundant files in the Linux system are trimmed, the volume and complexity of the Linux system are reduced, the system memory usage is reduced, the system performance is improved, and the system startup time is accelerated.

[0011] In one embodiment, obtaining the target file of the target program when it is running according to the multiple first files, the multiple second files, the multiple third files, and the multiple fourth files includes:

[0012] Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set;

[0013] A first other file in the first file set except the plurality of third files is determined as the target file.

[0014] This embodiment removes the files that are not opened when the target program is running from the collections corresponding to the files used when the target program is compiled, the files used when the target program is running, and the files opened when the target program is running, so as to ensure the accuracy of determining the target file.

[0015] In one embodiment, before the root file of the Linux system is trimmed based on the target files of each target program in the Linux system, the method further includes:

[0016] For any target program, use each file in the first file set to start the target program, and determine whether the target program can be successfully started; and,

[0017] If it is determined that the target program can be successfully started using each file in the first file set, restarting the target program using the target file of the target program; and,

[0018] If it is determined that the target program can be successfully started using the target file of the target program, then determining that the target file verification of the target program has passed;

[0019] If the target files of the target programs are verified, it is determined to execute a step of trimming the root files of the Linux system based on the target files of the target programs in the Linux system.

[0020] In this embodiment, the target program is started through the first file set and the target file to verify whether the target file is accurate, thereby ensuring the accuracy of the target file.

[0021] In one embodiment, the method further comprises:

[0022] If it is determined that the target program cannot be successfully started using the files in the first file set, a set of second other files in the root file set of the Linux system except the files in the first file set is determined as a second file set; and

[0023] In response to a first error file instruction sent by a user, determining a first error-associated file in the second file set;

[0024] After adding the first error-associated file to the first file set, return to the step of starting the target program using each file in the first file set until it is determined that the target program can be successfully started using each file in the first file set.

[0025] In this embodiment, if the target program is not successfully started using each file in the first file set, the first file set needs to be updated to ensure the accuracy of the target file determined by the target program.

[0026] In one embodiment, the method further comprises:

[0027] If it is determined that the target program is not successfully started using the target file, a set consisting of third other files in the first file set except the target file is determined as a third file set;

[0028] In response to a second error file instruction sent by a user, searching for a second error-associated file in the third file set;

[0029] The second error-associated file is added to the target file, and the step of restarting the target program using the target file of the target program is returned to until the target program can be successfully started using the target file, and then it is determined that the target file verification of the target program has passed.

[0030] In this embodiment, if it is determined that the target program is not successfully started using the target file, the target file needs to be updated to ensure the accuracy of the determined target file.

[0031] In one embodiment, before obtaining the target file of the target program at runtime according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files, the method further includes:

[0032] File deduplication is performed on the multiple first files, the multiple second files, the multiple third files, and the multiple fourth files respectively.

[0033] This embodiment deduplicates each file to reduce the amount of calculation and improve the efficiency of file cropping.

[0034] A second aspect of the present disclosure provides an electronic device, including a processor and a memory, wherein the processor and the memory are connected via a bus;

[0035] The memory stores a computer program, and the processor is configured to perform the following operations based on the computer program:

[0036] In response to a file trimming instruction sent by a user, using a preset static checking tool, searching in a Linux system for a plurality of first files used when a target program is compiled, wherein the plurality of first files at least include component files constituting the target program; and

[0037] Using a preset dynamic checking tool, searching in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files that implement various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running;

[0038] Obtaining a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files;

[0039] The root file of the Linux system is trimmed based on the target files of each target program in the Linux system.

[0040] In one embodiment, the processor executes the method of obtaining the target file of the target program when it is running according to the multiple first files, the multiple second files, the multiple third files, and the multiple fourth files, and is specifically configured as follows:

[0041] Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set;

[0042] A first other file in the first file set except the plurality of third files is determined as the target file.

[0043] In one embodiment, the processor is further configured to:

[0044] Before the root file of the Linux system is trimmed based on the target files of each target program in the Linux system, for any target program, the target program is started by using each file in the first file set to determine whether the target program can be successfully started; and

[0045] If it is determined that the target program can be successfully started using each file in the first file set, restarting the target program using the target file of the target program; and,

[0046] If it is determined that the target program can be successfully started using the target file of the target program, then determining that the target file verification of the target program has passed;

[0047] If the target files of the target programs are verified, it is determined to execute a step of trimming the root files of the Linux system based on the target files of the target programs in the Linux system.

[0048] In one embodiment, the processor is further configured to:

[0049] If it is determined that the target program cannot be successfully started using the files in the first file set, a set of second other files in the root file set of the Linux system except the files in the first file set is determined as a second file set; and

[0050] In response to a first error file instruction sent by a user, determining a first error-associated file in the second file set;

[0051] After adding the first error-associated file to the first file set, return to the step of starting the target program using each file in the first file set until it is determined that the target program can be successfully started using each file in the first file set.

[0052] In one embodiment, the processor is further configured to:

[0053] If it is determined that the target program is not successfully started using the target file, a set consisting of third other files in the first file set except the target file is determined as a third file set;

[0054] In response to a second error file instruction sent by a user, searching for a second error-associated file in the third file set;

[0055] The second error-associated file is added to the target file, and the step of restarting the target program using the target file of the target program is returned to until the target program can be successfully started using the target file, and then it is determined that the target file verification of the target program has passed.

[0056] In one embodiment, the processor is further configured to:

[0057] Before obtaining the target file of the target program at runtime based on the multiple first files, the multiple second files, the multiple third files and the multiple fourth files, the multiple first files, the multiple second files, the multiple third files and the multiple fourth files are respectively deduplicated.

[0058] According to a third aspect provided by an embodiment of the present disclosure, a computer storage medium is provided, wherein the computer storage medium stores a computer program, and the computer program is used to execute the method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0060] Figure 1 A schematic diagram of an applicable scenario in an embodiment of the present disclosure;

[0061] Figure 2 This is one of the flowcharts of a file cutting method for a Linux system according to an embodiment of the present disclosure;

[0062] Figure 3 The second flowchart of determining the target file of the target program according to one embodiment of the present disclosure;

[0063] Figure 4 is a schematic diagram of a first file set according to an embodiment of the present disclosure;

[0064] Figure 5 A schematic diagram of a target file according to an embodiment of the present disclosure;

[0065] Figure 6 A schematic diagram of a process for verifying a target file of a target program according to an embodiment of the present disclosure;

[0066] Figure 7 is a schematic diagram of a second file set according to an embodiment of the present disclosure;

[0067] Figure 8 The second flowchart of the file cutting method of the Linux system according to an embodiment of the present disclosure is as follows;

[0068] Fig. 9 A file cutting device for a Linux system according to an embodiment of the present disclosure;

[0069] Fig.10 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0071] In the embodiments of the present disclosure, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0072] The application scenarios described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems. In the description of the present disclosure, unless otherwise specified, the meaning of "multiple" is two or more.

[0073] In the prior art, as the functions of the Linux system are continuously enhanced and expanded, its size and complexity are also increasing, resulting in an increase in system memory usage, so there will be problems such as slow system startup time and poor performance.

[0074] Therefore, the present disclosure provides a file clipping method for a Linux system, which determines the minimized target files used by each target program at runtime by searching for multiple first files used by each target program at compile time, multiple second files used at runtime, multiple third files not used at runtime, and multiple fourth files opened during the running process in the Linux system, and then clips the root files of the Linux system based on the target files of each target program. Thus, in the embodiment of the present application, redundant files in the Linux system are clipped, the volume and complexity of the Linux system are reduced, the system memory usage is reduced, the system performance is improved, and the system startup time is accelerated. Below, the scheme of the present disclosure is described in detail in conjunction with the accompanying drawings.

[0075] like Figure 1 As shown, an application scenario of a file cutting method of a Linux system includes a terminal device 110 and a server 120, such as Figure 1 As shown, the application scenario is described by taking the electronic device as a server as an example. However, the embodiment of the present application does not limit the electronic device, and the electronic device can be a server and a terminal device, etc., which can be set according to actual conditions. The server 120 can be implemented by a single server or by multiple servers. The server 120 can be implemented by a physical server or by a virtual server.

[0076] In a possible application scenario, a user sends a file clipping instruction to a server 120 through a terminal device 110. In response to the file clipping instruction sent by the user, the server 120 uses a preset static checking tool to search for multiple first files used by a target program when compiling in a Linux system, wherein the multiple first files at least include component files constituting the target program, and uses a preset dynamic checking tool to search for multiple second files used by the target program when running, multiple third files not used by the target program when running, and multiple fourth files opened by the target program during running in the Linux system, wherein the multiple second files include function implementation files for implementing each function in the target program, and the multiple fourth files at least include system files used by the Linux system when running. The server 120 obtains the target file of the target program when running according to the multiple first files, the multiple second files, the multiple third files, and the multiple fourth files; finally, the server 120 clips the root file of the Linux system based on the target files of each target program in the Linux system.

[0077] in, Figure 1The server 120 and the terminal device 110 can exchange information through a communication network, wherein the communication mode adopted by the communication network can be divided into a wireless communication mode or a wired communication mode.

[0078] Exemplarily, the server 120 can access the network through cellular mobile communication technology to communicate with the terminal device 110, wherein the cellular mobile communication technology, for example, includes the fifth generation mobile communication (5th Generation Mobile Networks, 5G) technology.

[0079] Optionally, the server 120 may access the network and communicate with the terminal device 110 via short-range wireless communication, wherein the short-range wireless communication method, for example, includes Wireless Fidelity (Wi-Fi) technology.

[0080] Among them, only a single server 120 and a single terminal device 110 are described in detail in the description of this application, but those skilled in the art should understand that the server 120 and the terminal device 110 shown are intended to represent the operations of the server 120 and the terminal device 110 involved in the technical solution of this application. It does not imply any limitation on the number, type or location of the server 120 and the terminal device 110. It should be noted that if additional modules are added to the illustrated environment or individual modules are removed therefrom, the underlying concepts of the exemplary embodiments of this application will not be changed.

[0081] It should be noted that the file cutting method of the Linux system proposed in this application is not only applicable to Figure 1 The application scenario shown is also applicable to any identification device with a bus passenger flow corridor.

[0082] The following describes the file cropping method of the Linux system in an exemplary embodiment of the present application in combination with the application scenario described above and with reference to the accompanying drawings. It should be noted that the above application scenario is only shown to facilitate understanding of the method and principle of the present application, and the implementation of the present application is not limited in this respect.

[0083] like Figure 2 FIG. 1 is a flowchart of a file cutting method for a Linux system disclosed in the present invention, which may include the following steps:

[0084] Step 201: In response to a file cropping instruction sent by a user, a preset static checking tool is used to search in a Linux system for a plurality of first files used when a target program is compiled, wherein the plurality of first files at least include component files constituting the target program;

[0085] Among them, the static checking tool used in the embodiment of the present application is the ldd command tool to search for multiple first files used by the target program when compiling in the Linux system. However, the static checking tool in the embodiment of the present application can be set according to actual conditions, and the embodiment of the present application does not limit the static checking tool here.

[0086] It should be noted that the target program in the embodiment of the present application may be one or more, which are pre-set and can be set according to actual conditions, and the embodiment of the present application is not limited here.

[0087] Step 202: using a preset dynamic checking tool, searching in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files for implementing various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running;

[0088] In the embodiment of the present application, the dynamic inspection tool used to search for multiple second files used by the target program during runtime in the Linux system is the strace command tool, the dynamic inspection tool used to search for multiple third files not used by the target program during runtime in the Linux system is the find command tool, and the dynamic inspection tool used to search for multiple fourth files that have been opened by the target program during operation in the Linux system is the slof command tool.

[0089] It should be noted that the various dynamic inspection tools described above are only used for illustration, but do not limit the dynamic inspection tools in the embodiments of the present application. The dynamic inspection tools in the embodiments of the present application can be set according to actual conditions.

[0090] Step 203: Obtaining a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files;

[0091] like Figure 3 As shown, it is a flowchart for determining the target file of the target program, which includes the following steps:

[0092] Step 301: Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set;

[0093] like Figure 4, which is a schematic diagram of a first file set. From the figure, it can be seen that the first file set includes each first file, each second file and each fourth file.

[0094] Step 302: Determine a first other file in the first file set except the plurality of third files as the target file.

[0095] like Figure 5 As shown, it is a schematic diagram for determining a target file, the third file in the first file set is deleted to obtain a first other file, and the first other file is determined as the target file.

[0096] In order to reduce the amount of calculation, in one embodiment, before executing step 203, the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files are deduplicated.

[0097] Step 204: tailoring the root file of the Linux system based on the target files of each target program in the Linux system.

[0098] In order to ensure the accuracy of the target file corresponding to the target program, in one embodiment, before executing step 204, the target file of the target program needs to be verified, such as Figure 6 The above is a flow chart of verifying the target file of the target program, which includes the following steps:

[0099] Step 601: for any target program, use each file in the first file set to start the target program, and determine whether the target program can be successfully started. If yes, execute step 605; if no, execute step 602;

[0100] Among them, whether the target program can be successfully started in the embodiment of the present application is determined based on the return value of the target program. For example, the target program is started using each file in the first file set. When the return value of the target program is 1, it is determined that the target program is successfully started. If the return value of the target program is 0, it is determined that the target program is not successfully started. However, the specific method for determining whether the target program is successfully started can be set according to the actual situation. The embodiment of the present application does not limit the method for determining whether the target program is successfully started.

[0101] Step 602: Determine a set of second other files in the root file set of the Linux system except the files in the first file set as a second file set;

[0102] The root file set of the Linux system in the embodiment of the present application is pre-set. Figure 7As shown, it is a schematic diagram for determining the second file set. After deleting each file belonging to the first file set in the root file set, the second file set is obtained, and the second file set includes a plurality of second other files.

[0103] Step 603: In response to the first error file instruction sent by the user, determining a first error-associated file in the second file set;

[0104] Among them, in the embodiment of the present application, the first error file instruction includes the file name of the first error associated file. Therefore, in the implementation of the present application, step 603 can be implemented as: searching the second file set for each file with the same file name as each file in the first error file instruction, and determining each found file as the first error associated file.

[0105] Step 604: after adding the first error-associated file to the first file set, return to step 601;

[0106] Step 605: Restart the target program using the target file of the target program, and determine whether the target file of the target program can successfully start the target program. If yes, execute step 609; if no, execute step 606;

[0107] Among them, the method of determining whether the target program is successfully started in step 605 is the same as the method of determining whether the target program is successfully started in step 601 described above, and the embodiment of the present application will not be repeated here.

[0108] Step 606: Determine a set consisting of third files other than the target file in the first file set as a third file set;

[0109] In one embodiment, step 606 may be specifically implemented as follows: deleting the target file in the first file set to obtain the third file set, where the third file set includes the third other files.

[0110] Step 607: In response to the second error file instruction sent by the user, searching for a second error-associated file in the third file set;

[0111] Wherein, the second error file instruction includes the file names of each second error associated file, and step 607 can be specifically implemented as: determining each file in the third file set whose file name is the same as the file name included in the second error file instruction as the second error associated file.

[0112] Step 608: Add the second error-associated file to the target file, and return to step 605;

[0113] Step 609: Determine whether the target file of the target program has passed verification.

[0114] In order to further understand the technical solution of the present disclosure, Figure 8 A detailed description may include the following steps:

[0115] Step 801: In response to a file cropping instruction sent by a user, a preset static checking tool is used to search in a Linux system for a plurality of first files used when a target program is compiled, wherein the plurality of first files at least include component files constituting the target program;

[0116] Step 802: using a preset dynamic checking tool, searching in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files for implementing various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running;

[0117] It should be noted that the execution sequence of step 801 and step 802 in the embodiment of the present application is not limited in the embodiment of the present application. Step 801 may be executed first, and then step 802. Step 802 may also be executed first, and then step 801. Step 801 and step 802 may also be executed simultaneously.

[0118] Step 803: Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set;

[0119] Step 804: determining a first other file in the first file set except the plurality of third files as the target file;

[0120] Step 805: for any target program, use each file in the first file set to start the target program, and determine whether the target program can be successfully started. If yes, execute step 809; if no, execute step 806;

[0121] Step 806: Determine a set of second other files in the root file set of the Linux system except the files in the first file set as a second file set;

[0122] Step 807: In response to the first error file instruction sent by the user, determining a first error-associated file in the second file set;

[0123] Step 808: After adding the first error-associated file to the first file set, return to step 804;

[0124] Step 809: Restart the target program using the target file of the target program, and determine whether the target file of the target program can successfully start the target program. If yes, execute step 813; if no, execute step 810;

[0125] Step 810: determining a set of other third files in the first file set except the target file as a third file set;

[0126] Step 811: In response to the second error file instruction sent by the user, searching for a second error-associated file in the third file set;

[0127] Step 812: adding the second error-associated file to the target file, and returning to step 809;

[0128] Step 813: Determine whether the target file of the target program has passed verification;

[0129] Step 814: tailoring the root file of the Linux system based on the target files of each target program in the Linux system.

[0130] Based on the same disclosure concept, the file cutting method of the Linux system disclosed above can also be implemented by a file cutting device of the Linux system. The effect of the file cutting device of the Linux system is similar to that of the above method, which will not be described in detail here.

[0131] Fig. 9 The figure is a schematic diagram of the structure of a file clipping device of a Linux system according to an embodiment of the present disclosure.

[0132] like Fig. 9 As shown, the file clipping device 900 of the Linux system of the present disclosure may include a compilation file determination module 910 , a running file determination module 920 , a target file determination module 930 and a file clipping module 940 .

[0133] A compiled file determination module 910 is used to search for a plurality of first files used by the target program when compiling in the Linux system in response to a file clipping instruction sent by a user, using a preset static checking tool, wherein the plurality of first files at least include component files constituting the target program;

[0134] The running file determination module 920 is used to use a preset dynamic checking tool to search in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files for implementing various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running;

[0135] A target file determination module 930, configured to obtain a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files;

[0136] The file trimming module 940 is used to trim the root files of the Linux system based on the target files of each target program in the Linux system.

[0137] In one embodiment, the target file determination module 930 is specifically configured to:

[0138] Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set;

[0139] A first other file in the first file set except the plurality of third files is determined as the target file.

[0140] In one embodiment, the apparatus further comprises:

[0141] The file verification module 950 is used to, before the root file of the Linux system is cut based on the target files of each target program in the Linux system, for any target program, start the target program using each file in the first file set to determine whether the target program can be successfully started; and

[0142] If it is determined that the target program can be successfully started using each file in the first file set, restarting the target program using the target file of the target program; and,

[0143] If it is determined that the target program can be successfully started using the target file of the target program, then determining that the target file verification of the target program has passed;

[0144] If the target files of the target programs are verified, it is determined to execute a step of trimming the root files of the Linux system based on the target files of the target programs in the Linux system.

[0145] In one embodiment, the apparatus further comprises:

[0146] The first file update module 960 is used to determine a set of second other files in the root file set of the Linux system except the files in the first file set as a second file set if it is determined that the target program is not successfully started using the files in the first file set; and

[0147] In response to a first error file instruction sent by a user, determining a first error-associated file in the second file set;

[0148] After adding the first error-associated file to the first file set, return to the step of starting the target program using each file in the first file set until it is determined that the target program can be successfully started using each file in the first file set.

[0149] In one embodiment, the apparatus further comprises:

[0150] The second file update module 970 is used to determine a set consisting of third other files in the first file set except the target file as a third file set if it is determined that the target program is not successfully started using the target file;

[0151] In response to a second error file instruction sent by a user, searching for a second error-associated file in the third file set;

[0152] The second error-associated file is added to the target file, and the step of restarting the target program using the target file of the target program is returned to until the target program can be successfully started using the target file, and then it is determined that the target file verification of the target program has passed.

[0153] In one embodiment, the apparatus further comprises:

[0154] The file deduplication module 980 is used to deduplicate the multiple first files, the multiple second files, the multiple third files and the multiple fourth files respectively before obtaining the target files of the target program at runtime based on the multiple first files, the multiple second files, the multiple third files and the multiple fourth files.

[0155] After introducing a file cutting method and device for a Linux system according to an exemplary embodiment of the present disclosure, next, an electronic device according to another exemplary embodiment of the present disclosure is introduced.

[0156] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".

[0157] In some possible implementations, the electronic device according to the present disclosure may include at least one processor and at least one computer storage medium. The computer storage medium stores program code, and when the program code is executed by the processor, the processor executes the steps of the file clipping method of the Linux system according to various exemplary implementations of the present disclosure described above in this specification. For example, the processor may execute the following steps: Figure 2 Steps 201-204 shown in .

[0158] Refer to the following Fig.10 The electronic device 1000 according to this embodiment of the present disclosure is described. Fig.10 The electronic device 1000 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0159] like Fig.10 As shown, the electronic device 1000 is in the form of a general electronic device. The components of the electronic device 1000 may include but are not limited to: the at least one processor 1001, the at least one computer storage medium 1002, and a bus 1003 connecting different system components (including the computer storage medium 1002 and the processor 1001).

[0160] Bus 1003 represents one or more of several types of bus structures, including a computer storage media bus or computer storage media controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0161] The computer storage medium 1002 may include readable media in the form of volatile computer storage media, such as random access computer storage media (RAM) 1021 and / or cache storage media 1022 , and may further include read-only computer storage media (ROM) 1023 .

[0162] The computer storage medium 1002 may also include a program / utility 1025 having a set (at least one) of program modules 1024, such program modules 1024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0163] The electronic device 1000 may also communicate with one or more external devices 1004 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or communicate with any device that enables the electronic device 1000 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1005. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1006. As shown, the network adapter 1006 communicates with other modules for the electronic device 1000 via a bus 1003. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0164] In some possible implementations, various aspects of a file cropping method for a Linux system provided by the present disclosure may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the file cropping method for a Linux system according to various exemplary implementations of the present disclosure described above in this specification.

[0165] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access computer storage medium (RAM), a read-only computer storage medium (ROM), an erasable programmable read-only computer storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only computer storage medium (CD-ROM), an optical computer storage medium, a magnetic computer storage medium, or any suitable combination of the above.

[0166] The program product of file clipping of the Linux system of the embodiment of the present disclosure can adopt a portable compact disk read-only computer storage medium (CD-ROM) and include program code, and can be run on an electronic device. However, the program product of the present disclosure is not limited to this. In this document, the readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0167] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0168] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0169] Program code for performing the disclosed operations may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user electronic device, partially on the user device, as a separate software package, partially on the user electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In the case of a remote electronic device, the remote electronic device may be connected to the user electronic device via any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external electronic device (e.g., via the Internet using an Internet service provider).

[0170] It should be noted that although several modules of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules described above can be embodied in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be embodied.

[0171] In addition, although the operations of the disclosed method are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0172] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk computer storage media, CD-ROM, optical computer storage media, etc.) containing computer-usable program codes.

[0173] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0174] These computer program instructions may also be stored in a computer-readable computer storage medium that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable computer storage medium produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0175] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0176] Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.

Claims

1. A file cutting method for Linux system, It is characterized in that The method comprises: In response to a file trimming instruction sent by a user, using a preset static checking tool, searching in a Linux system for a plurality of first files used when a target program is compiled, wherein the plurality of first files at least include component files constituting the target program; and Using a preset dynamic checking tool, searching in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files that implement various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running; Obtaining a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files; The root file of the Linux system is trimmed based on the target files of each target program in the Linux system.

2. The method according to claim 1, It is characterized in that The step of obtaining a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files comprises: Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set; A first other file in the first file set except the plurality of third files is determined as the target file.

3. The method according to claim 2, It is characterized in that Before the root file of the Linux system is cut based on the target files of each target program in the Linux system, the method further includes: For any target program, use each file in the first file set to start the target program, and determine whether the target program can be successfully started; and, If it is determined that the target program can be successfully started using each file in the first file set, restarting the target program using the target file of the target program; and, If it is determined that the target program can be successfully started using the target file of the target program, then determining that the target file verification of the target program has passed; If the target files of the target programs are verified, it is determined to execute a step of trimming the root files of the Linux system based on the target files of the target programs in the Linux system.

4. The method according to claim 3, It is characterized in that The method further comprises: If it is determined that the target program is not successfully started using the files in the first file set, a set of second other files in the root file set of the Linux system except the files in the first file set is determined as a second file set; and In response to a first error file instruction sent by a user, determining a first error-associated file in the second file set; After adding the first error-associated file to the first file set, return to the step of starting the target program using each file in the first file set until it is determined that the target program can be successfully started using each file in the first file set.

5. The method according to claim 3, It is characterized in that The method further comprises: If it is determined that the target program is not successfully started using the target file, a set consisting of third other files in the first file set except the target file is determined as a third file set; In response to a second error file instruction sent by a user, searching for a second error-associated file in the third file set; The second error-associated file is added to the target file, and the step of restarting the target program using the target file of the target program is returned to until the target program can be successfully started using the target file, and then it is determined that the target file verification of the target program has passed.

6. The method according to claim 1, It is characterized in that Before obtaining the target file of the target program at runtime according to the plurality of first files, the plurality of second files, the plurality of third files and the plurality of fourth files, the method further includes: File deduplication is performed on the multiple first files, the multiple second files, the multiple third files, and the multiple fourth files respectively.

7. An electronic device, It is characterized in that comprising a processor and a memory, wherein the processor and the memory are connected via a bus; The memory stores a computer program, and the processor is configured to perform the following operations based on the computer program: In response to a file trimming instruction sent by a user, using a preset static checking tool, searching in a Linux system for a plurality of first files used when a target program is compiled, wherein the plurality of first files at least include component files constituting the target program; and Using a preset dynamic checking tool, searching in the Linux system for a plurality of second files used by the target program when it is running, a plurality of third files not used by the target program when it is running, and a plurality of fourth files opened during the running of the target program, wherein the plurality of second files include function implementation files that implement various functions in the target program, and the plurality of fourth files include at least system files used by the Linux system when it is running; Obtaining a target file of the target program when it is running according to the plurality of first files, the plurality of second files, the plurality of third files, and the plurality of fourth files; The root file of the Linux system is trimmed based on the target files of each target program in the Linux system.

8. The electronic device according to claim 7, It is characterized in that The processor executes the method of obtaining a target file of the target program when it is running according to the multiple first files, the multiple second files, the multiple third files, and the multiple fourth files, and is specifically configured as follows: Determine a set consisting of the plurality of first files, the plurality of second files, and the plurality of fourth files as a first file set; A first other file in the first file set except the plurality of third files is determined as the target file.

9. The electronic device according to claim 8, It is characterized in that The processor is further configured to: Before the root file of the Linux system is trimmed based on the target files of each target program in the Linux system, for any target program, the target program is started by using each file in the first file set to determine whether the target program can be successfully started; and, If it is determined that the target program can be successfully started using each file in the first file set, restarting the target program using the target file of the target program; as well as, If it is determined that the target program can be successfully started using the target file of the target program, then determining that the target file verification of the target program has passed; If the target files of the target programs are verified, it is determined to execute a step of trimming the root files of the Linux system based on the target files of the target programs in the Linux system.

10. The electronic device according to claim 9, It is characterized in that The processor is further configured to: If it is determined that the target program is not successfully started using the files in the first file set, a set consisting of second other files in the root file set of the Linux system except the files in the first file set is determined as a second file set; and, In response to a first error file instruction sent by a user, determining a first error-associated file in the second file set; After adding the first error-associated file to the first file set, return to the step of starting the target program using each file in the first file set until it is determined that the target program can be successfully started using each file in the first file set.