Device control method and apparatus, electronic device, and readable medium

By using a preset configuration file directory and specified command templates, configuration commands are automatically generated and executed, solving the problems of low efficiency and poor versatility in controlling configuration items of electronic device components, and realizing efficient and easy-to-use modification of configuration items.

CN122309463APending Publication Date: 2026-06-30LOONGSON TECH CORP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
LOONGSON TECH CORP
Filing Date
2026-03-27
Publication Date
2026-06-30

Smart Images

  • Figure CN122309463A_ABST
    Figure CN122309463A_ABST
Patent Text Reader

Abstract

This invention provides a device control method, apparatus, electronic device, and readable medium, relating to the field of computer technology. In this method, the modified content of a target configuration item file and its corresponding identifier are used as the target configuration value and target identifier, respectively. The target configuration item file is any configuration item file in a preset configuration file directory, which includes configuration item files corresponding to each controlled device. Based on the target configuration value, target identifier, and a preset specified command template, a target configuration command is generated and executed to modify the target configuration item corresponding to the target configuration item file, thereby changing the value of the target configuration item to the target configuration value. This improves control efficiency, and the solution is not limited by the application environment and is universally applicable across different operating systems, enhancing its versatility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a device control method, apparatus, electronic device, and readable medium. Background Technology

[0002] Currently, electronic devices are composed of a variety of components, such as network cards, hard drives, graphics cards, sound cards, and so on. When using electronic devices, users sometimes need to modify the configuration values ​​of these components to control their operational status.

[0003] In related technologies, it is necessary to manually find suitable configuration software based on the specific needs of the project and the current operating system, and manually modify the configuration values ​​of the corresponding configuration items for each device component to be controlled. This method has low control efficiency and poor versatility. Summary of the Invention

[0004] This invention provides a device control method, apparatus, electronic device, and readable medium, which can solve the problems of low control efficiency and poor versatility.

[0005] To address the above problems, this invention discloses a device control method, the method comprising: The modified content of the target configuration item file and the corresponding identifier of the target configuration item file are respectively used as the target configuration value and the target identifier; the target configuration item file is any configuration item file in the preset configuration file directory, and the configuration file directory includes the configuration item files corresponding to each controlled device; Based on the target configuration value, the target identifier, and the preset specified command template, a target configuration command is generated and executed to modify the target configuration item corresponding to the target configuration item file, so that the value of the target configuration item is modified to the target configuration value.

[0006] On the other hand, embodiments of the present invention disclose a device control apparatus, the apparatus comprising: The determination module is used to take the modified content of the target configuration item file and the identifier corresponding to the target configuration item file as the target configuration value and the target identifier, respectively; the target configuration item file is any configuration item file in a preset configuration file directory, and the configuration file directory includes configuration item files corresponding to each controlled device; The first processing module is used to generate and execute a target configuration command based on the target configuration value, the target identifier, and a preset specified command template, so as to modify the target configuration item corresponding to the target configuration item file, and modify the value of the target configuration item to the target configuration value.

[0007] In another aspect, embodiments of the present invention disclose an electronic device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, which cause the processor to execute the aforementioned method.

[0008] This invention also discloses a machine-readable medium storing instructions that, when executed by one or more processors, cause the processors to perform the methods described above.

[0009] The embodiments of this invention offer the following advantages: The device control method provided by these embodiments uses the modified content of the target configuration item file and its corresponding identifier as the target configuration value and target identifier, respectively. The target configuration item file is any configuration item file in a preset configuration file directory, which includes configuration item files corresponding to each controlled device. Based on the target configuration value, target identifier, and a preset specified command template, a target configuration command is generated and executed to modify the target configuration item corresponding to the target configuration item file, thereby changing the value of the target configuration item to the target configuration value. In this way, users only need to modify the configuration item files provided in the configuration file directory according to their configuration requirements to change the target configuration item to the target configuration value. This provides users with a standardized operation database, thereby improving control efficiency. Furthermore, this solution is not limited by the application environment and is universally applicable across different types of operating systems, enhancing its versatility. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments of the present invention will be briefly introduced below.

[0011] Figure 1 This is a flowchart of the steps of a device control method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of a processing architecture provided by an embodiment of the present invention; Figure 3 This is a partial schematic diagram of a configuration table provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the processing of a device controller provided in an embodiment of the present invention; Figure 5 This is a block diagram of a device control apparatus provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0012] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0013] First, an application scenario related to an embodiment of the present invention will be described. For a device component, one or more configuration items that can be configured by the user can be provided externally. Each configuration item corresponds to an operating parameter of the device component. The configuration items provided by the device component and the corresponding operating parameters are determined by the hardware design, and this embodiment of the present invention does not impose any limitations on this.

[0014] For example, taking a network interface card (NIC) as an example, the configuration items provided by the NIC may include: mask configuration items, Media Access Control (MAC) address configuration items, state configuration items, Internet Protocol version 4 (IPv4) address configuration items, etc. Taking a hard drive as an example, the configuration items provided by the hard drive may include: hard drive start address configuration items, node configuration items, etc. Taking a hard drive's sub-devices, such as hard drive partitions, as an example, the configuration items provided by the hard drive partitions may include: size configuration items, device file path (dev) configuration items, etc. Taking a graphics card as an example, the configuration items provided by the graphics card may include: resolution configuration items, refresh rate configuration items, etc.

[0015] Furthermore, users sometimes need to modify the configuration values ​​of device components during operation. For example, by modifying the IPv4 address configuration value, the network card can be controlled to operate with the newly configured IPv4 address. In related technologies, for a single device component, there are often multiple available configuration tools. For example, commonly used configuration tools for network cards include ifconfig, ip, ethtool, and sysfs, each with different configurable options. Users first need to manually find suitable configuration software, i.e., find a configuration tool that supports the required modification. This requires users to learn various configuration software to select the appropriate one, resulting in high learning costs and poor usability. Then, commands are manually created to invoke the configuration tool to modify the configuration values ​​of the device component. The entire process is cumbersome, has low control convenience and efficiency, high manual implementation costs, poor versatility, and cannot be ported across different operating systems.

[0016] Therefore, this invention provides a device control method, which will be described in detail below.

[0017] Figure 1This is a flowchart of the steps of a device control method provided in an embodiment of the present invention, as shown below. Figure 1 As shown, the device control method may include the following steps: Step 101: Modify the content of the target configuration item file and the identifier corresponding to the target configuration item file, and use them as the target configuration value and the target identifier, respectively; the target configuration item file is any configuration item file in the preset configuration file directory, and the configuration file directory includes configuration item files corresponding to each controlled device.

[0018] Step 102: Based on the target configuration value, the target identifier, and the preset specified command template, generate a target configuration command and execute it to modify the target configuration item corresponding to the target configuration item file, so that the value of the target configuration item is modified to the target configuration value.

[0019] The device control method provided in this embodiment of the invention can be applied to electronic devices. For example, implementation code for implementing the device control method can be deployed in the electronic device to enable the electronic device to implement the device control method. The electronic device can be a computer, server, or other similar device.

[0020] In this embodiment of the invention, a configuration file directory is pre-created and provided to the user. For example, in one implementation, the configuration file directory can be displayed to the user by the electronic device for user operation. This configuration file directory includes configuration item files corresponding to all configurable device components (i.e., controlled devices) of the electronic device. The number of configuration item files is consistent with the total number of configuration items provided by all controlled devices. For example, assuming the controlled devices of the electronic device include device 1 and device 2, where device 1 and device 2 each provide 2 configuration items, then there are a total of 4 configuration items. Correspondingly, a configuration item file is designed for each of these 4 configuration items, and the 4 configuration item files are respectively associated with the configuration file directory, meaning the preset configuration file directory includes at least 4 configuration item files.

[0021] The identifier corresponding to the configuration item file can be the identifier of the configuration item represented by the configuration item file. One configuration item file represents a configuration item of the controlled device that is installed in the electronic device. Specifically, different configuration item files have different identifiers. Correspondingly, different identifiers can distinguish different configuration items. For example, assuming that the electronic device has two network cards: enp13s0f0 and enp13s0f1, then the configuration item file representing the mask address configuration item of network card enp13s0f0 (hereinafter referred to as configuration item file 1) has a different identifier than the configuration item file representing the mask address configuration item of network card enp13s0f1 (hereinafter referred to as configuration item file 2). The file content of configuration item file 1 can represent the configuration value of the mask address configuration item of network card enp13s0f0 (that is, the mask address of network card enp13s0f0), and the file content of configuration item file 2 can represent the configuration value of the mask address configuration item of network card enp13s0f1 (that is, the mask address of network card enp13s0f1).

[0022] When a user needs to modify a configuration item of a controlled device, they only need to modify the contents of the configuration file corresponding to that configuration item in the configuration file directory. The target configuration item refers to the configuration item that the user needs to modify, and the target configuration item file refers to the configuration file in the configuration file directory that represents that target configuration item. Accordingly, the configuration file whose contents are being modified by the user is the target configuration item file.

[0023] In this embodiment, in response to a modification operation on the target configuration item file, the electronic device automatically uses the modified file content as the target configuration value of the target configuration item and the identifier corresponding to the target configuration item file as the target identifier of the target configuration item file. Here, the target configuration item is the configuration item corresponding to the target configuration item file, and the controlled device corresponding to the target configuration item file is called the target controlled device.

[0024] For example, assume the target configuration file is configuration file 1, and the target configuration is the subnet mask address configuration for network card enp13s0f0; assume the target configuration file is configuration file 2, and the target configuration is the subnet mask address configuration for network card enp13s0f1.

[0025] Furthermore, a specified command template is automatically found through identifier matching, and a target configuration command is generated based on the target configuration value, the target identifier, and the specified command template. The target configuration command is used to modify the target configuration item to the target configuration value. By executing this target configuration command, the controlled target device is controlled to operate according to the target configuration value in the target configuration item file.

[0026] Furthermore, the specified command template is pre-generated based on the configuration commands of the target configuration tool, which is a configuration tool that supports the target configuration items. Since the specified command template is generated based on the configuration commands of the configuration tool that supports the target configuration items, the target configuration command can be executed smoothly through the target configuration tool, thereby ensuring rapid configuration of the target configuration items.

[0027] In summary, the device control method provided by this invention uses the modified content of the target configuration item file and its corresponding identifier as the target configuration value and target identifier, respectively. The target configuration item file is any configuration item file in a preset configuration file directory, which includes configuration item files corresponding to each controlled device. Based on the target configuration value, target identifier, and a preset specified command template, a target configuration command is generated and executed to modify the target configuration item corresponding to the target configuration item file, thereby changing the value of the target configuration item to the target configuration value. In this way, users only need to modify the configuration item files provided in the configuration file directory according to their configuration requirements to change the target configuration item to the target configuration value. This provides users with a standardized operation database, thereby improving control efficiency. Furthermore, this solution is not limited by the application environment and is universally applicable across different types of operating systems, enhancing its versatility.

[0028] Furthermore, in this embodiment of the invention, by modifying the configuration item file provided in the configuration file directory, the user can trigger the electronic device to automatically determine the target configuration value and target identifier. Based on the target configuration value, target identifier, and preset specified command template, the electronic device automatically generates and executes the target configuration command, thereby modifying the target configuration item to the target configuration value. The user does not need to manually select a configuration tool and create a command to call the configuration tool to modify the configuration value. Therefore, the user does not need to learn how to use different configuration tools. This simplifies the user operation, reduces the learning cost of the configuration method, makes the solution more user-friendly, and reduces the cumbersomeness of the operation process.

[0029] Optionally, in this embodiment of the invention, the method may further include the following steps: Step S21, loading the description information of a predefined category directory, a device directory, and a configuration item file located at the next level below the device directory, and generating and displaying the configuration file directory based on the description information; the device directory represents a controlled device; the configuration item file at the next level below the device directory represents the configuration item corresponding to the controlled device; the category directory represents the device type corresponding to the controlled device, and the next level below the category directory is the device directory corresponding to the device type to which the controlled device belongs.

[0030] In this embodiment of the invention, the configuration file directory adopts a multi-level structure. The preset configuration file directory can also be called a device and configuration item list, or simply a configuration table. Through the multi-level configuration table, each controlled device in the electronic device and the configuration items supported by each controlled device are described hierarchically. Specifically, the configuration file directory includes at least: a device directory and configuration item files located at the next level below the device directory. One device directory represents one controlled device, and the directory name can be the device name of the controlled device. A configuration item file at the next level below the device directory represents one configuration item of the controlled device.

[0031] It should be noted that the configuration file directory may also include a root directory, which contains all device directories and serves as the main entry point for the configuration table. In this embodiment of the invention, by setting a root directory, users can easily find the required configuration files by navigating through the hierarchy. Figure 2 This is a schematic diagram of a processing architecture provided by an embodiment of the present invention, such as... Figure 2 As shown in this example, the preset configuration file directory includes a root directory, under which are two device directories: "Device 1" and "Device 2". The next level of "Device 1" includes two configuration file files: "Configuration 1" and "Configuration 2". These two configuration file files, "Configuration 1" and "Configuration 2", represent configuration item 1 and configuration item 2 for device 1, respectively. Similarly, the next level of "Device 2" includes two configuration file files: "Configuration 1" and "Configuration 2". These two configuration file files, "Configuration 1" and "Configuration 2", represent configuration item 1 and configuration item 2 for device 2, respectively.

[0032] In this embodiment of the invention, the configuration item file provided in the configuration file directory can be a regular file, which allows users to read and write the file content. The electronic device can also deploy a configuration table monitor and a device controller. When the configuration table monitor detects a modification operation on the target configuration item file in the configuration table, it can execute step 101 above, transmitting the target configuration value and target identifier to the device controller. The device controller then executes step 102 above, thereby modifying the target configuration item to the target configuration value and achieving control over the target controlled device.

[0033] Furthermore, the multi-level configuration file directory also includes category directories. Each category directory represents a device type, and the controlled devices represented by the next level of the category directory belong to the device type represented by that category directory. That is, in this embodiment of the invention, the configuration table is organized in a directory format, containing members including: a root directory, device directories, category directories, and configuration item files. A category directory represents a specific type of device, such as a network device, storage device, or display device. The directory name of the category directory can be the name of that device type; for example, the directory name can be "Network Device (net)," "Storage Device (block)," or "Display Device," etc. A category directory includes: linked files of all device directories representing controlled devices belonging to the device type represented by that category directory. For example, the controlled devices represented by the device directories representing enp13s0f0 and enp13s0f1 are both network interface cards (NICs), and both belong to network devices. Therefore, a link file pointing to the device directory representing enp13s0f0 and a link file pointing to the device directory representing enp13s0f1 can be set in the category directory representing network devices. This allows users to access the corresponding device directory through the link files, thus setting the device directory representing the controlled device of that device type as the next level in that category directory. The link file can be a symbolic link, also known as a soft link; essentially, a link file is a pointer to another file or directory.

[0034] In this embodiment of the invention, by setting up a category directory, users can first locate the category directory that matches the type of device they represent and the type of device to be modified. They can then search for and enter the device directory of the device to be modified from that category directory, and quickly find the configuration file corresponding to the configuration item to be modified, thereby ensuring the user's operational efficiency.

[0035] For example, if a user needs to modify the mask address of enp13s0f0, meaning the device to be modified is enp13s0f0, specifically, the configuration item to be modified is the mask address of enp13s0f0. Without a category directory, it would be necessary to traverse all device directories from the configuration file directory to find the device directory representing enp13s0f0. Since category directories are fewer than all device directories, the user only needs to find the category directory representing the type of device to be modified (in this example, the category directory representing "network devices") from a small number of category directories, and then find the device directory representing enp13s0f0 from the device directories included in that category directory. Because a single category directory often contains fewer device directories, the search efficiency is higher.

[0036] It should be noted that the next level of the device directory can also include sub-device directories. Sub-device directories represent sub-devices of the controlled device represented by the device directory. The next level of the sub-device directory includes the configuration file corresponding to the sub-device. For example, "hard disk partition" is a sub-device of the controlled device "hard disk". Suppose the electronic device has a controlled device: hard disk nvme0n1, and hard disk nvme0n1 includes two sub-devices: hard disk partition nvme0n1p0 and hard disk partition nvme0n1p1. Then the device directory representing hard disk nvme0n1 includes the hard disk start address (address) configuration file of nvme0n1, the node (node) configuration file, the sub-device directory representing hard disk partition nvme0n1p0, and the sub-device directory representing hard disk partition nvme0n1p1. In this context, a sub-device directory can be considered a special device directory. The next level of a sub-device directory can include configuration file items for the sub-device represented by that sub-device directory. For example, the sub-device directory representing hard disk partition nvme0n1p0 includes a configuration file item indicating the size of hard disk partition nvme0n1p0 and a configuration file item indicating the device file path (dev) where hard disk partition nvme0n1p0 is located. The sub-device directory representing hard disk partition nvme0n1p1 includes a configuration file item indicating the size of hard disk partition nvme0n1p1 and a configuration file item indicating the device file path (dev) where hard disk partition nvme0n1p1 is located.

[0037] In this embodiment of the invention, the filename of the configuration item file can be the name of the configuration item represented by the configuration item file, and the file content of the configuration item file represents the current value of the configuration item represented by the configuration item file. Users can use general file access methods, such as double-clicking the file to trigger the display of the file content interface, modify the original value displayed in the file content interface to the desired value, trigger a write command, and thus modify the file content, thereby enabling the reading and modification of the configuration value of the configuration item represented by the configuration item file. Furthermore, read and write permissions can be set for the configuration item file to control the reading / modification of its file content.

[0038] In this embodiment of the invention, the configuration file directory can adopt a tree structure: root directory - category directory - device directory - configuration item files. Assume the controlled devices include network interface card (NIC) enp13s0f0, NIC enp13s0f1, and hard disk (HDD) nvme0n1. HDD nvme0n1 includes two sub-devices: hard disk partition nvme0n1p0 and hard disk partition nvme0n1p1. Both NICs enp13s0f0 and enp13s0f1 provide configuration items including: mask, IPv4, MAC, and state. HDD nvme0n1 includes address and node configuration items. Both hard disk partitions nvme0n1p0 and nvme0n1p1 include size and dev configuration items. These configuration items are all structured and stored in the configuration file directory in the form of configuration item files.

[0039] Figure 3 This is a partial schematic diagram of a configuration table provided in an embodiment of the present invention, such as... Figure 3 As shown, the configuration table includes the root directory (i.e. Figure 3 In "SystemDeviceConfig", the device directories corresponding to the two network cards (i.e., Figure 3 The “enp13s0f0” and “enp13s0f1” in the text refer to the device directory corresponding to the hard drive (i.e., Figure 3 The “nvme0n1” in the text), and the sub-device directories corresponding to the two sub-devices (i.e., Figure 3 The "nvme0n1p0" and "nvme0n1p1" in the text, as well as two categories (i.e. Figure 3The categories "net" and "block" are used to define the network interface card (NIC) enp13s0f0. The "net" category includes linked files for the device directories "enp13s0f0" and "enp13s0f1," while the "block" category includes a linked file for the device directory "nvme0n1." The next level of the "enp13s0f0" device directory includes configuration files for mask, IPv4, MAC, and state configurations. The contents of these files represent the current values ​​of the mask, IPv4, MAC, and state configurations for the enp13s0f0 NIC. For example, the current values ​​of the mask, IPv4, MAC, and state configuration items of the network interface card enp13s0f0 can be 255.255.255.0, 192.168.111.104, 30:09:f9:25:20:05, and UP, respectively. The next level of the device directory "enp13s0f1" includes configuration files representing the mask, IPv4, MAC, and state configuration items. Figure 3 (Not shown in the image). The next level of the device directory "nvme0n1" includes the sub-device directories "nvme0n1p0" and "nvme0n1p1", which represent configuration file files for the address configuration item and configuration file files for the node configuration item. The contents of these two configuration file files represent the current values ​​of the address configuration item and the node configuration item of the hard disk nvme0n1. For example, the current value of the address configuration item of the hard disk nvme0n1 can be 0000:09:00.0, and the current value of the node configuration item of the hard disk nvme0n1 can be 0. The next level of the sub-device directory "nvme0n1p0" includes configuration file files representing the size configuration item and configuration file files representing the dev configuration item. The contents of these two configuration file files represent the current values ​​of the size and dev configuration items for the disk partition nvme0n1p0. For example, the current values ​​of the size and dev configuration items for the disk partition nvme0n1p0 can be 1228800 and 259:1, respectively. The next level of the sub-device directory "nvme0n1p1" also includes configuration file files representing the size configuration item and configuration file files representing the dev configuration item. Figure 3 (Not shown in the image).

[0040] In this embodiment of the invention, the descriptive information used to generate the configuration file directory can be predefined by the developer. The descriptive information can include a predefined first association: [directory name of the root directory - directory name of the device directory; directory name of the category directory], for example: ["SystemDeviceConfig" - "enp13s0f0", "enp13s0f1", "nvme0n1"; "net", "block"], to represent the directory names of the category directories included under the root directory and the directory name of the device directory.

[0041] The description information also includes a predefined second association: [Category Directory Name - Device Directory Name], to indicate the directory names of the device directories included under each category directory. One second association corresponds to one device directory included under a category directory. For example, the second association may include: ["net"-"enp13s0f0", "enp13s0f1"] and ["block"-"nvme0n1"].

[0042] The description information also includes a predefined third association: [Device directory name - Sub-device directory name, Configuration file name], to represent the directory names of the sub-device directories included in each device directory and the file names of the included configuration files. One third association corresponds to the sub-device directories and configuration files included in a device directory. For example, the third association may include: ["enp13s0f0" - "mask", "ipv4", "mac", "state"], ["enp13s0f1" - "mask", "ipv4", "mac", "state"], ["nvme0n1" - "nvme0n1p0", "nvme0n1p1", "address", "node"].

[0043] The description information also includes a predefined fourth association: [directory name of sub-device directory - file name of configuration item file], to indicate the file name of the configuration item file included in each sub-device directory. One fourth association corresponds to one configuration item file included in a sub-device directory. For example, ["nvme0n1p0"-"size", "dev"] and ["nvme0n1p1"-"size", "dev"].

[0044] When generating the configuration file directory, the first association can be loaded from the first specified storage area. A root directory named after the root directory name defined in the first association is created, and a device directory named after the device directory name defined in the first association is created within that root directory. A category directory named after the category directory name defined in the first association is also created. Next, the second association is loaded and traversed. In the category directory corresponding to the category directory name defined in the second association, a link file named after the device directory name defined in the second association is created. Next, the third association is loaded and traversed. In the device directory corresponding to the directory name defined in the third association, a sub-device directory named after the sub-device directory name defined in the third association is created, and a configuration item file named after the configuration item file name defined in the third association is created. Next, the fourth association is loaded and traversed. In the sub-device directory corresponding to the sub-device directory name defined in the fourth association, a configuration item file named after the configuration item file name defined in the fourth association is created, resulting in the preset configuration file directory.

[0045] In this embodiment of the invention, a configuration file directory is established for all controllable controlled devices. By generating and displaying a multi-level configuration file directory to the user, the user can easily find the target configuration file corresponding to the configuration item to be modified through the configuration file directory layer by layer via a GUI interface. This generates a trigger event for the target configuration file, and the user can easily modify the file content of the configuration file by accessing a regular file. In response to the user's trigger event corresponding to the modification of the target configuration file, the target configuration command is automatically generated and executed based on the identifier of the modified configuration file and the modified file content. This realizes the process of converting regular file access into device control. Since regular files are the most basic file type in the file system, used to store data and support modification, and different operating system platforms often support this file type, this ensures that the solution can be widely applied.

[0046] It should be noted that, in another implementation, if the electronic device itself does not have a display function, the configuration table can also be sent to the user's personal terminal for the user to view. Accordingly, the user can send a modification command to the electronic device via their personal terminal to modify the file content of the target configuration item file, and the electronic device will respond to the modification command and perform the modification operation. This embodiment of the invention does not impose any limitations on this approach.

[0047] Optionally, in this embodiment of the invention, the identifier corresponding to the configuration item file is the file path of the configuration item file. Accordingly, the step of using the modified file content of the target configuration item file and the identifier corresponding to the target configuration item file as the target configuration value and the target identifier, respectively, may specifically include: Step 1011: Obtain the file path of the target configuration item file, and use it as the target identifier.

[0048] Step 1012: After performing the modification operation, read the file content of the target configuration item file as the target configuration value.

[0049] In this embodiment of the invention, the file path of the configuration item file consists of the name of the root directory, the names of all levels of directories traversed from the root directory to the configuration item file, and the filename of the configuration item file. For example, for the configuration item file corresponding to the IPv4 configuration item of the network card enp13s0f0 in the aforementioned example, the file path of the configuration item file can be SystemDeviceConfig / enp13s0f0 / ipv4, that is, "SystemDeviceConfig / enp13s0f0 / ipv4" is used as the target identifier of the target configuration item file "ipv4". For the configuration item file corresponding to the size configuration item of nvme0n1p0 in the aforementioned example, the file path of the configuration item file can be SystemDeviceConfig / nvme0n1 / nvme0n1p0 / size, that is, "SystemDeviceConfig / nvme0n1 / nvme0n1p0 / size" is used as the target identifier of the target configuration item file "size".

[0050] Accordingly, the file path of the target configuration file can be constructed based on the name of the root directory, the names of all directories traversed from the root directory to the target configuration file, and the filename of the target configuration file, serving as the target identifier. The modified content of the target configuration file is then read as the target configuration value.

[0051] In this embodiment of the invention, by obtaining the file path of the target configuration item file and reading the file content of the target configuration item file after performing the modification operation, the target identifier and the target configuration value can be obtained, which can ensure processing efficiency to a certain extent.

[0052] In this embodiment of the invention, steps 1011-1012 can be implemented using a configuration table monitor integrated into the code. The configuration table monitor can employ the file system access notification mechanism provided by the operating system to listen to and manage user access to all directories / files under the root directory. Each time an access to a directory / file in the configuration table occurs, the monitor receives a corresponding event through the file system access notification mechanism. Specifically, the monitored events can include user-initiated open events, write events, read events, and completion events. For example, taking a Linux operating system as an example, the monitor can use the Fanotify mechanism provided by the Linux kernel. The Fanotify mechanism has file system event notification functionality, which allows for listening to open, write, read, and completion events. In related technologies, the main uses of the Fanotify mechanism include scanning file content through access control events to prevent malicious operations, monitoring and recording file access behavior for file auditing. Therefore, in this embodiment of the invention, the use of the Fanotify mechanism, which supports multi-monitor management, can avoid conflicts with other programs using the Fanotify mechanism.

[0053] Optionally, embodiments of the present invention may further include the following steps: Step S21: When a user triggers the target configuration file, open the target configuration file; Step S22: When a modification operation on the target configuration item file is detected, if the modified file content meets the preset content requirements, the modified file content of the target configuration item file and the identifier corresponding to the target configuration item file are respectively used as the target configuration value and the target identifier.

[0054] In this embodiment of the invention, users can modify configuration file data by triggering open and write events, and read directory names, file names, and file contents by triggering open and read events. For example, when an electronic device displays configuration file data, clicking on a configuration file triggers an open event. The monitor can listen for events through a resident process. Upon detecting an open event, it can be considered that a user has triggered an action on the target configuration file. The monitor can first compare the visitor's user permissions with the access permissions required by the configuration file requested by the open event. User permissions represent the visitor's user level, and the access permissions required by the configuration file / directory in the configuration table represent the user level required to open that configuration file / directory. The required access permissions can be pre-set by developers according to actual needs. The access permissions required by each configuration file and directory in the configuration table can be pre-stored in a mapping between configuration file / directory and access permissions. By looking up this mapping, the access permissions required by the target configuration file can be obtained. Furthermore, the user's user permissions can be obtained from background user data.

[0055] For example, suppose a user wants to change the IPv4 address of network card enp13s0f0 to 192.168.203.221. The user needs to first open the configuration file SystemDeviceConfig / enp13s0f0 / ipv4. At this time, the monitor will receive an open event for this configuration file. For example, a regular expression matching command defining the identifier of the configuration file requested by this open event (e.g., a grep command defined with "SystemDeviceConfig / enp13s0f0 / ipv4") can be used to find the corresponding access permission identifier from the access permission mapping. Further, the user's user permission identifier can be compared character by character with the found corresponding access permission identifier. If the characters match, it is determined that the user's permissions match the access permissions required by the target configuration file; otherwise, it is determined that the user's permissions do not match the access permissions required by the target configuration file, thus achieving permission verification. Assuming the access permission required by the found configuration file is "Registered user," then if the visitor's user permissions are also "Registered user," the two are completely identical. Therefore, it can be determined that the user permissions match the access permission required by the target configuration file, indicating that the access is legitimate. If the visitor's user permissions are those of a guest user, it can be determined that the user permissions do not match the access permission required by the target configuration file, and accordingly, the access can be denied. If the user permissions do not match the access permission required by the configuration file, then opening the file should be refused to prevent unauthorized users from modifying the configuration items.

[0056] Furthermore, if the user's permissions match the access permissions required by the target configuration file, it can be further determined whether the target configuration file is not in an accessed state, thus indicating that the target configuration file can be modified. Specifically, it can be detected whether there are other processes accessing the target configuration file. If so, it is determined that the target configuration file is in an accessed state, and the open event can be allowed only after the access is completed. If not, it is determined that the target configuration file is in an inaccessible state, indicating that the device currently supports the user directly modifying the configuration item. The open event can then be allowed directly.

[0057] In this embodiment of the invention, the monitor is a file system event notification framework provided by the operating system kernel. Essentially, it is a kernel component. The monitor, through a resident process, detects that the user's permissions match the access permissions required by the target configuration file, and that the target configuration file is not currently in an accessed state. If so, it submits an open event to the operating system to allow the open event. After the monitor allows the open event, the subsequent opening process is completed by the operating system. Specifically, the operating system executes the open event, and after the operating system executes the open event, the target configuration file is opened. It should be noted that the operating system can perform operating system-level authentication before executing the open event. If the user's permissions match the access permissions required by the operating system, the open event is executed. If the user's permissions do not match the access permissions required by the operating system, the open event is rejected, and an open failure message is returned to the monitor. The access permissions required by the operating system can be set by the system administrator. Assuming the operating system requires root user access, if the user's permissions are not root user, the operating system will reject the open event.

[0058] After entering the display page of the target configuration file, a read event can be automatically triggered to automatically display the current file content of the target configuration file. Alternatively, the read event can be triggered when the user interacts with the display page of the target configuration file, such as clicking on the display page, to display the current file content of the target configuration file based on the user's action. This embodiment of the invention does not limit this. The monitor can listen for events through a resident process. When a read event is detected, it executes a process identification command, such as the `losf` command, to list the processes that have opened the target configuration file. If the execution result of the `losf` command is empty, it can be assumed that the target configuration file has not been modified by other processes. If the target configuration file has not been modified by other processes, the read event is directly allowed. If the execution result of the `losf` command is not empty, it can be assumed that the target configuration file has been modified by other processes. If the target configuration file has been modified by other processes, the read event is allowed only after the modification is completed. After the monitor allows the read event, the subsequent reading process is completed by the operating system. Specifically, the operating system executes the read event, and after the operating system executes the read event, the current file content of the target configuration file is displayed. It should be noted that operating system-level authentication can be performed before the operating system executes the read event.

[0059] For example, the user permission identifier and the read permission identifier can be compared character by character. If the characters match, it is determined that the user permission matches the read permission required by the operating system; otherwise, the user permission does not match the read permission required by the operating system. If the user permission matches the read permission required by the operating system, the read event is then executed. If the user permission does not match the read permission required by the operating system, the read event is rejected, and a read failure message is returned to the monitor. The read permission required by the operating system can be set by the system administrator; this embodiment of the invention does not impose any restrictions on this.

[0060] It is understood that the embodiments of the present invention also include: when a user's open event on any directory in the configuration table is detected, if the user's permissions match the access permissions required by the directory and the directory is not in an accessed state, then an open event is executed to open the directory. This achieves access control through permission control, realizing fine-grained control. After entering the display page of the directory, a read event can be automatically triggered. Alternatively, the read event can be triggered when the user operates on the display page of the directory, for example, by clicking on the display page of the directory. The processing methods for the open and read events of the directory are the same as those for the open and read events of the target configuration file described above, and will not be repeated here.

[0061] In this embodiment of the invention, when the object of the current open event is the directory where the configuration item file is located, subsequent executable operations on that object only include reading, thus ensuring that the directory name is not modified. When the object of the current open event is the configuration item file itself, subsequent executable operations on that object include reading and writing. Users do not need to operate various tools or system interfaces; they can read or modify the configuration values ​​of the configuration items using ordinary file access methods.

[0062] Furthermore, the modification operation is implemented through write events. When a user writes content to the target configuration file, for example, changing the current value 192.168.100.104 in the target configuration file's display page to 192.168.203.221 (i.e., writing 192.168.203.221), the operating system first determines whether the user has write permissions. For example, the user's permissions can be matched with the write permissions required by the operating system. The write permissions required by the operating system represent the user level required to modify the configuration file. These write permissions can be set by the system administrator and can be the same as or different from the read permissions required by the operating system. If the user's permissions match the write permissions required by the operating system, the modification is executed, completing the writing of the new configuration item set by the user to the target configuration file. Otherwise, an error message is output.

[0063] Furthermore, after the operating system completes the write operation, the monitor receives a corresponding write event. In response to this write event, the monitor can first obtain the modified file content and determine whether the modified file content conforms to the preset content requirements of the target configuration file. The preset content requirements for different configuration files can be pre-set by the developers, representing the format and data range that the target configuration file content must follow. Specifically, it can detect whether the format of the modified file content is consistent with the format in the preset content requirements of the target configuration file, and whether the modified file content falls within the data range defined in the preset content requirements. If so, it is determined that the modified file content conforms to the preset content requirements. For example, assuming the data format defined in the preset content requirements is of type "int" and the data range is 1~4999, and the format of the modified file content is of type "int" and the modified file content is 3000, since the data format is consistent and does not exceed the data range, it can be determined that the modified file content conforms to the preset content requirements. Accordingly, if the modified file content meets the preset requirements, the above-described operation can be performed to use the modified file content of the target configuration item file and the corresponding identifier of the target configuration item file as the target configuration value and target identifier, respectively. The determined target configuration value and target identifier are then notified to the device controller, allowing the device controller to generate and execute the target configuration command. Otherwise, if the modified file content is determined not to meet the preset requirements, an illegal content warning message can be output. For example, the warning message "Illegal content" can be output.

[0064] In this embodiment of the invention, upon detecting a user's open event on a target configuration file, permission verification is performed first. Only if the user's permissions match the access permissions required by the target configuration file and the target configuration file is not in an accessed state is the open event executed to open the target configuration file. This achieves access control and avoids access conflicts. Furthermore, upon detecting a modification operation on the target configuration file, only if the modified file content meets preset requirements is the step executed to use the modified file content and the corresponding identifier of the target configuration file as the target configuration value and target identifier, respectively. This ensures that the target configuration command is generated only when the content is legal, preventing the target configuration item from being modified to an illegal value, which could lead to malfunctions in the controlled device, thus ensuring the legality and security of the device configuration.

[0065] Optionally, embodiments of the present invention may further include the following steps: Step S31: In response to the open event of the target configuration item file, back up the current file content of the target configuration item file to obtain a backup file.

[0066] Step S32: If the feedback information of the target configuration command indicates control failure, or if the modified file content does not meet the preset content requirements, the target configuration item file is restored according to the backup file.

[0067] Step S331: If the feedback information of the target configuration command indicates that the control is successful, delete the backup file.

[0068] In this embodiment of the invention, specifically in response to an open event on the target configuration file, if the user's permissions match the write permissions required by the operating system (i.e., the accessor has write permissions), the current file content of the target configuration file is backed up to obtain a backup file. For example, the current file content of the target configuration file can be stored in a second designated storage area to achieve backup. The second designated storage area is an area accessible to the resident process of the monitor, and is pre-specified by the developers; this embodiment of the invention does not impose any limitations on this.

[0069] Furthermore, the feedback information of the target configuration command is sent from the device controller to the monitor. Specifically, if the feedback information indicates control failure, it means that the device controller failed to generate the target configuration command, or that the target configuration command failed to execute. If the feedback information indicates control success, it means that the device controller successfully generated and executed the target configuration command. Accordingly, if the feedback information indicates control success, the backup file can be deleted to save storage resources.

[0070] In this embodiment of the invention, the monitor can obtain feedback information through an inter-process communication mechanism between a resident process and the process in the device controller responsible for sending feedback information. If the feedback information of the target configuration command indicates a control failure, for example, if the received feedback information is "FALSE", it means that the target configuration item could not be modified to the target configuration value. Therefore, the target configuration item file can be restored to a backup file, that is, the current value of the target configuration item file can be modified to the backup file. For example, the monitor reads the backup file from a specified storage area through the resident process to obtain the original value of the target configuration item file before modification, and modifies the file content of the target configuration item file to the original value, thus achieving restoration. For example, if the file content of the target configuration item file before modification is 3500 and the file content after modification is 4500, then the file content of the target configuration item file can be modified to 3500 to achieve restoration. If the modified file content does not meet the preset requirements, for example, if the preset requirements define the data format as "int" type and the data range as 1~4999, and the modified file content is "int" type but contains 5000, which exceeds the data range, it can be determined that the modified file content does not meet the preset requirements. The monitor will not perform the operation to determine the target configuration value and target identifier, and therefore will not trigger the device controller to generate and execute the target configuration command. Therefore, the target configuration item file can be restored to a backup file to ensure that the current value of the target configuration item file accurately represents the current configuration value of the target configuration item, thus ensuring the accuracy of the file content.

[0071] It should be noted that the monitor can also indicate that the visitor was unable to modify the contents of the target configuration file upon receiving an open failure message. Accordingly, the backup file can be directly deleted via a resident process to save storage resources. For example, the monitor can clear a second specified storage area via a resident process to delete the stored backup file.

[0072] Furthermore, in this embodiment of the invention, the monitor performs a backup in response to an open event of a configuration item file. If no modifications are made subsequently, for example, only a read operation is performed, the backup file still exists when the configuration item file is closed. Accordingly, when a visitor requests to close a configuration item file or directory, a close event is generated. In response to the close event, the monitor can further check whether a backup file of the configuration item file corresponding to the close event exists. If it exists, the backup file is deleted and the close event is allowed to save storage resources and avoid unnecessary storage resource occupation. Otherwise, the close event is allowed directly to close the configuration item file or directory.

[0073] Optionally, in this embodiment of the invention, the step of generating and executing the target configuration command may specifically include: Step 1021: Find the command template corresponding to the target identifier from the preset configuration item identifier and command template correspondence table, and use it as the specified command template; the command template is generated according to the configuration command of the configuration tool that supports the configuration item represented by the configuration item identifier.

[0074] Step 1022: Based on the specified command template, the target configuration value, and the target identifier, generate the target configuration command, and call the target configuration tool to execute the target configuration command.

[0075] In this embodiment of the invention, steps 1021-1022 can be executed by a device controller. The device controller includes a preset configuration item identifier and command template mapping table and a converter. The monitor parses the user's access to and writing behavior of the configuration item file into a configuration request for setting the configuration item. Specifically, when the monitor detects a modification operation on the target configuration item file, and the modified file content meets preset content requirements, it uses the modified file content and the identifier corresponding to the target configuration item file as the target configuration value and target identifier, respectively. Next, a request sending event is executed: a configuration request carrying the target configuration value and target identifier is sent to the converter to trigger the device controller to respond to the configuration request, generate a target configuration command, and execute it, thereby realizing the user's modification behavior of the target configuration item file and modifying the configuration value of the target configuration item accordingly. For example, the configuration request includes a configuration file path and a data portion, where the configuration file path portion is the target identifier and the data portion is the target configuration value. Suppose that the configuration file corresponding to the IPv4 configuration item of network card enp13s0f0 is detected to have been modified to 192.168.203.221 / 24, then an execution request sending event can be triggered: a configuration request carrying the target identifier: SystemDeviceConfig / enp13s0f0 / ipv4 and the target configuration value: 192.168.203.221 / 24 is sent. Accordingly, the converter can first look up the specified command template based on the target identifier carried in the request.

[0076] Among them, the correspondence table includes multiple configuration item identifiers corresponding to their respective command templates, and one configuration item identifier corresponds to one or more command templates. The preset correspondence table between configuration item identifiers and command templates can be simply referred to as an operation table. The operation table can be in the form of a hash table. The operation table includes multiple key-value pairs. The key in a key-value pair represents a configuration item identifier, and the value in a key-value pair represents the command template corresponding to this configuration item identifier. Correspondingly, the value in a key-value pair can be a command template list, and a command template list can include one or more command templates. The data form of a key-value pair can be <configuration item identifier, command template list>. For each configuration item corresponding to different controlled devices, the configuration item identifier and its corresponding command template list are stored in this key-value pair form.

[0077] Correspondingly, the specified command template refers to the command templates included in the command template list in the key-value pair where the configuration item identifier is the same as the target identifier. The command templates corresponding to this configuration item identifier can include the configuration command templates provided by all configuration tools that support the configuration item corresponding to this configuration item identifier. Among them, the configuration tools that support the configuration item corresponding to this configuration item identifier refer to the tools used to configure the configuration item corresponding to this configuration item identifier, and the configuration command template represents the command format of the configuration commands provided by this configuration tool. Suppose the configuration item file modified by the user represents the ipv4 configuration item of the network card enp13s0f0, that is, the target configuration item is the ipv4 configuration item of the network card enp13s0f0. Then, the command templates stored in the key-value pair with the configuration item identifier of SystemDeviceConfig / enp13s0f0 / ipv4 are the templates followed by the configuration commands provided by the tools that support the configuration of the ipv4 configuration item of the network card enp13s0f0.

[0078] Exemplarily, suppose the ipv4 configuration item of the network card enp13s0f0 can be configured through the configuration tools: ifconfig and ip. Then, the templates followed by the configuration commands provided by the ifconfig and ip tools for configuring the ipv4 configuration item of the network card can be obtained (exemplarily, taking the ifconfig command template and the ip command template as examples). Taking the identifier of the configuration item file representing the ipv4 configuration item of enp13s0f0 (SystemDeviceConfig / enp13s0f0 / ipv4) as a key and the obtained templates as values, a key-value pair is formed. Exemplarily, this key-value pair is <SystemDeviceConfig / enp13s0f0 / ipv4, ifconfig command template; ip command template>. Correspondingly, the target identifier can be compared with each configuration item identifier in the operation table. The command template corresponding to the configuration item identifier that is the same as the target identifier is determined as the specified command template. Next, the device name can be extracted from the target identifier, and the device name and target configuration items can be written into the specified configuration template to generate the target configuration command. Since the specified command template used is generated based on the configuration command of the target configuration tool (i.e., a configuration tool that supports target configuration items), and the target configuration tool is a configuration tool that supports target configuration items, meaning that the target configuration tool can be used to configure target configuration items, the target configuration tool can be invoked to execute the target configuration command.

[0079] In this embodiment of the invention, the specified command template can be obtained by searching for the command template corresponding to the target identifier in a preset configuration item identifier and command template correspondence table. Based on the specified command template, the target configuration value, and the target identifier, the target configuration command is generated, and the target configuration tool is invoked to execute the target configuration command, which can ensure the efficiency of command generation and execution to a certain extent.

[0080] Optionally, in one implementation, the step of generating the target configuration command based on the specified command template, the target configuration value, and the target identifier may specifically include: Step 1022a: Fill in the target configuration value and the device name carried in the target identifier into all the specified command templates to obtain the target configuration command.

[0081] The steps for executing the target configuration command described above may specifically include: Step 1022b: Select one of the target configuration commands as the command to be executed, and call the target configuration tool corresponding to the command to be executed to execute the command to modify the value of the target configuration item to the target configuration value.

[0082] Step 1022c: If the execution fails, return to the step of selecting one of the target configuration commands as the command to be executed.

[0083] Step 1022d: If the execution is successful, the process ends.

[0084] In this embodiment of the invention, the device name portion of the target identifier in the target configuration file can be extracted to obtain the device name carried therein, thereby obtaining the information required to generate the target configuration command. For example, the device name portion can be the content between the last two specific symbols in the target identifier. The specific symbol can be " / ". Taking the target identifier as SystemDeviceConfig / enp13s0f0 / ipv4 as an example, the specific symbol can be located through character matching, and the content between the last two specific symbols can be extracted to obtain the device name: enp13s0f0. Furthermore, the target configuration value and the device name carried in the target identifier can be filled into each specified command template to obtain at least one target configuration command.

[0085] Here, the configuration tool corresponding to the configuration command refers to the configuration tool that provides the configuration command, and the configuration command provided by the configuration tool is the configuration command supported by that configuration tool. Since the target configuration command is generated based on the specified command template, and the specified command template is generated based on the configuration command of the target configuration tool, the configuration tool corresponding to the target configuration command is always the target configuration tool. Accordingly, when one of them is selected as the command to be executed, the target configuration tool corresponding to the command to be executed can be called to execute it. For example, the target configuration tool corresponding to the command to be executed can be a configuration tool with the same name as the command name of the command to be executed, and the matching configuration tool can be selected based on the command name of the command to be executed. By calling the target configuration tool corresponding to the command to be executed, the command to be executed is executed, thereby setting the target configuration item of the controlled device indicated by the device name in the command to be executed to the target configuration value defined in the command to be executed. For example, assuming the target configuration item is the IPv4 configuration item of the network card enp13s0f0, and the target configuration value is entered as 192.168.203.221 / 24 in the command to be executed, then the function of the command to be executed is: to set the IPv4 configuration item of the network card enp13s0f0 to 192.168.203.221 / 24.

[0086] For example, the target configuration value can be entered into the $Data section of the specified command template, and the device name can be entered into the $DevName section of the specified command template. Assuming the target configuration value is 192.168.203.221, the specified command template includes: ifconfig $DevName $Data ip addr add $Data dev $DevName Here, ifconfig represents the command name, $DevName represents the name part, which is used to fill in the device name, and $Data represents the data part, which is used to fill in the target configuration value.

[0087] The ip field represents the command name, the addr field indicates the action performed by the command: address writing, and the dev field indicates that the content to be written later is the device name.

[0088] After filling in the information, you will get two target configuration commands: ifconfig enp13s0f0 192.168.203.221 / 24 ip addr add 192.168.203.221 / 24 dev enp13s0f0 When executing a target configuration command, a target configuration command can be selected sequentially as the command to be executed, following a preset order (e.g., from front to back). In this example, `ifconfig enp13s0f0192.168.203.221 / 24` can be selected first. Then, the corresponding target configuration tool, the `ifconfig` tool, is invoked to execute the command. If the `ifconfig` tool is currently installed on the electronic device, the execution will succeed. Otherwise, it will fail. In the event of a failure, if there are still unselected target configuration commands, the process can return to the step of selecting a target configuration command as the command to be executed, i.e., a new target configuration command can be selected. The selected target configuration command will be different each time.

[0089] Specifically, the next target configuration command to be executed can be selected as the new command to be executed (in this example, `ip addr add 192.168.203.221 / 24 dev enp13s0f0`), and the target configuration tool corresponding to this new command to be executed, the `ip` tool, can be invoked again to execute the command. If the `ip` tool is currently installed on the electronic device, the execution will succeed. Otherwise, the execution will fail. In the case of execution failure, if there is no unselected target configuration command, the execution process will end. In the case of execution success, the execution process will end directly to avoid performing unnecessary execution operations.

[0090] In scenarios where configuration tools for controlling devices under different operating systems are numerous, there may be functional overlaps and conflicts between these tools, making them incompatible and unusable. However, when dealing with different electronic devices using different operating systems, even if different configuration tools are installed, the processing method provided in this embodiment of the invention can be used: the target configuration command is selected as the command to be executed, and the target configuration tool corresponding to the selected command is called to execute the command. Through continuous iteration and attempts, it is ensured that a suitable backend configuration tool can be called to complete the specific configuration of the device's configuration items.

[0091] For example, assuming electronic device A has the IP utility installed and electronic device B has the ifconfig utility installed, then for electronic device A, following steps 1022b to 1022d above, the target configuration command is selected as the command to be executed. If `ifconfig enp13s0f0 192.168.203.221 / 24` is selected as the command to be executed, it will fail because electronic device A does not have the ifconfig utility installed. The command `ip addr add 192.168.203.221 / 24 dev enp13s0f0` is then selected as the command to be executed. Since electronic device A has the IP utility installed, this execution is successful, setting the IPv4 configuration item of network card enp13s0f0 to 192.168.203.221 / 24.

[0092] For example, after executing the command to be executed, if the received command exit status code indicates execution failure (e.g., command exit status code = 0), it can be determined that the command to be executed has failed. If the received command exit status code indicates execution success (e.g., command exit status code = 1), it can be determined that the command to be executed has succeeded. For electronic device B, following steps 1022b to 1022d above, the target configuration command is selected as the command to be executed. When `ifconfig enp13s0f0 192.168.203.221 / 24` is used as the command to be executed, since the `ifconfig` tool is installed in electronic device A, the execution will succeed, thus setting the IPv4 configuration item of network card `enp13s0f0` to 192.168.203.221 / 24. This ensures that, even with different configuration tools installed, the appropriate backend configuration tool can be called to complete the specific configuration of the device's configuration items.

[0093] In this embodiment of the invention, target configuration commands are obtained by filling in the target configuration value and the device name carried in the target identifier into all specified command templates. The target configuration commands are then executed one by one by iterating through them until a particular target configuration command is successfully executed, or all target configuration commands are executed. This eliminates the need to identify which specific target configuration tool is installed in the electronic device. By executing the target configuration commands sequentially, when the command corresponding to the specific configuration tool installed in the electronic device is executed, the configuration item of the target configuration item can be modified to the target configuration value, ensuring execution efficiency.

[0094] Of course, one can also first find the command template of the corresponding target configuration tool that is currently installed on the electronic device, and use it as the target command template; fill the target configuration value and the device name into the target command template to obtain the target configuration command and execute it. This embodiment of the invention does not limit this.

[0095] It should be noted that, in this embodiment of the invention, multiple backend configuration tool sets can also be coupled in the implementation code of the device control method. If all target configuration commands fail to execute, the target configuration tool corresponding to the target configuration command can be called from the backend configuration tool set and executed to improve the execution success rate.

[0096] Optionally, embodiments of the present invention may further include the following steps: Step S41: If the target configuration command is not successfully generated or all target configuration commands fail to be executed, generate feedback information indicating control failure.

[0097] Step S42: If the target configuration command is successfully executed, generate feedback information indicating successful control.

[0098] In this embodiment of the invention, after the monitor sends a configuration request, it waits for feedback information from the device controller. The device controller may directly generate feedback information indicating control failure and return it to the device controller if the target configuration command is not successfully generated (e.g., if the corresponding command template is not found). Alternatively, if all target configuration commands are selected, and each selected target configuration command fails to execute, feedback information indicating control failure is generated and returned to the device controller.

[0099] If the command to be executed is successfully executed and the execution process ends, i.e., if a target configuration command is successfully executed, feedback information indicating successful control is generated and returned to the device controller. The specific forms of the feedback information indicating control failure and the feedback information indicating control success can be set as needed. For example, the feedback information indicating control failure and the feedback information indicating control success can be FALSE and TRUE, respectively, or 0 and 1, respectively. This embodiment of the invention does not impose any limitations on this.

[0100] The monitor can delete backup files or restore the target configuration file to a backup file based on feedback information through a resident process. If TRUE is received, the backup file is deleted. If FALSE is received, the monitor restores the target configuration file to a backup file. After deleting or restoring the backup file based on feedback information, the monitor can terminate the current listen for write events.

[0101] In this embodiment of the invention, feedback information indicating control failure is generated when a target configuration command is not successfully generated or all target configuration commands fail to execute. Conversely, feedback information indicating successful control is generated when a target configuration command is successfully executed. This allows the monitor to selectively delete backup files or restore the target configuration file to a backup file, thereby saving storage resources and ensuring the accuracy of the target configuration file's content.

[0102] Figure 4 This is a schematic diagram of the processing of a device controller provided in an embodiment of the present invention, such as... Figure 4 As shown, the configuration request sent by the monitor is sent to the device controller. The device controller can query the operation table based on the target identifier to obtain the specified command template. Then, it fills the specified command template to obtain the target configuration command, that is, it fills all the specified command templates with the target configuration value and the device name carried in the target identifier to obtain the target configuration command. Finally, the target configuration command can be executed to complete the configuration.

[0103] In one related technology, the Windows Registry is used for standardized management of device configurations. The Windows Registry uses a hierarchical database to record device configuration items and values. Consequently, users need to manually create commands to modify the configuration values ​​of the desired items in the registry, based on database commands. This results in high manual costs, low control convenience, and deep coupling between the Windows Registry and the Windows kernel version. Since registry functionality is provided by a fixed kernel, it's difficult to dynamically add support for new devices and has low cross-system compatibility. Furthermore, the registry is a special file requiring specialized handling, making operations more complex than those for ordinary files.

[0104] The device control method in this invention is decoupled from the operating system kernel version. A pre-built configuration file directory represents the configuration items of all controlled devices in the electronic device as ordinary files. This allows users to read / modify the contents of configuration item files using the same operations as ordinary files, thereby triggering the generation and execution of target configuration commands to modify the target configuration items to the target configuration values. This simplifies the operation. Furthermore, the pre-built configuration file directory provides a standardized configuration file for device configuration under the operating system. For different operating system platforms, only the directory / configuration item files in the configuration file directory need to be adaptively adjusted, facilitating portability between different operating systems and enhancing the versatility of the solution. Since the configuration file directory consists of ordinary files, it can be flexibly customized through operations such as adding / deleting, resulting in lower costs.

[0105] In another related technology, the Linux system manages a subset of devices through services and service configuration files. System administrators can configure devices by modifying these service configuration files. However, different Linux systems offer a wide variety of services with entirely different service configuration files. For example, there are services for configuring networks such as `network`, `NetworkManager`, and `nmcli`. Furthermore, a service configuration file for one service may not work for another, and each service supports a limited number of configuration items. Each configuration requires a service restart to take effect, resulting in low real-time performance and limited ease of use in practical scenarios. In this embodiment of the invention, different configuration items for different controlled devices can be configured based on a single configuration file directory. By generating and directly executing target configuration commands, target configuration items can be modified to target configuration values ​​without a restart. Therefore, real-time performance and ease of use are significantly improved.

[0106] Reference Figure 5 The diagram illustrates a block diagram of a device control apparatus provided in an embodiment of the present invention, such as... Figure 5 As shown, the device control unit may specifically include: The determination module 201 is used to take the modified file content of the target configuration item file and the identifier corresponding to the target configuration item file as the target configuration value and the target identifier, respectively; the target configuration item file is any configuration item file in the preset configuration file directory, and the configuration file directory includes configuration item files corresponding to each controlled device; The first processing module 202 is used to generate and execute a target configuration command based on the target configuration value, the target identifier, and a preset specified command template, so as to modify the target configuration item corresponding to the target configuration item file, and so that the value of the target configuration item is modified to the target configuration value.

[0107] Optionally, the identifier corresponding to the configuration item file is the file path of the configuration item file; The determining module 201 is specifically used for: Obtain the file path of the target configuration item file, and use it as the target identifier; After performing the modification operation, the file content of the target configuration item file is read as the target configuration value.

[0108] Optionally, the device further includes: Load the description information of the predefined category directory, device directory, and configuration item files located at the next level under the device directory, and generate and display the configuration file directory based on the description information; The device directory represents the controlled devices; the configuration file at the next level of the device directory represents the configuration items corresponding to the controlled devices. The classification directory represents the equipment type corresponding to the controlled device, and the next level of the classification directory is the equipment directory corresponding to the equipment type to which the controlled device belongs.

[0109] Optionally, the device further includes: The second processing module is used to open the target configuration file when it is detected that the user has triggered the target configuration file; The third processing module is used to detect when a modification operation is performed on the target configuration item file, and if the modified file content meets the preset content requirements, to use the modified file content of the target configuration item file and the corresponding identifier of the target configuration item file as the target configuration value and the target identifier, respectively.

[0110] Optionally, the device further includes: The backup module is used to back up the current file content of the target configuration file in response to an open event of the target configuration file, thereby obtaining a backup file; The recovery module is used to restore the target configuration item file based on the backup file when the feedback information of the target configuration command indicates control failure or the modified file content does not meet the preset content requirements. The deletion module is used to delete the backup file if the feedback information from the target configuration command indicates that the control is successful.

[0111] Optionally, the specified command template is pre-generated based on the configuration commands of the target configuration tool, where the target configuration tool is a configuration tool that supports the target configuration item; the first processing module 202 is specifically used for: The command template corresponding to the target identifier is found in the preset configuration item identifier and command template correspondence table and used as the specified command template; the command template is generated according to the configuration command of the configuration tool that supports the configuration item represented by the configuration item identifier; Based on the specified command template, the target configuration value, and the target identifier, the target configuration command is generated, and the target configuration tool is invoked to execute the target configuration command.

[0112] Optionally, the first processing module 202 is further configured to: Fill in the target configuration value and the device name carried in the target identifier into all the specified command templates to obtain the target configuration command; Select one of the target configuration commands as the command to be executed, and call the target configuration tool corresponding to the command to be executed to execute the command to modify the value of the target configuration item to the target configuration value; If the execution fails, return to the step of selecting one of the target configuration commands as the command to be executed; If the execution is successful, the process ends.

[0113] Optionally, the device further includes: The first generation module is used to generate feedback information indicating control failure if the target configuration command is not successfully generated or all target configuration commands fail to be executed. The second generation module is used to generate feedback information indicating successful control if the target configuration command has been successfully executed.

[0114] In summary, in the device control device provided by this embodiment of the invention, the modified content of the target configuration item file and the corresponding identifier of the target configuration item file are respectively used as the target configuration value and the target identifier. The target configuration item file is any configuration item file in a preset configuration file directory, which includes configuration item files corresponding to each controlled device. Based on the target configuration value, the target identifier, and a preset specified command template, a target configuration command is generated and executed to modify the target configuration item corresponding to the target configuration item file, so that the value of the target configuration item is modified to the target configuration value. In this way, the user only needs to modify the configuration item file provided in the configuration file directory according to the configuration requirements to modify the target configuration item to the target configuration value, providing the user with a normalized operation database, thereby improving control efficiency. Moreover, this solution is not limited by the application environment and can be used across different types of operating systems, enhancing the versatility of the solution.

[0115] Reference Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. For example... Figure 6 As shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus.

[0116] The processor, the memory, and the communication interface communicate with each other via the communication bus; the memory stores executable instructions that cause the processor to execute the device control method of the aforementioned embodiment. The executable instructions can form a program.

[0117] This invention provides a machine-readable medium storing instructions that, when executed by one or more processors, enable the processors to perform the device control method described in the foregoing embodiments. The machine-readable medium may be one or more.

[0118] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0119] The above provides a detailed description of a device control method, a device control apparatus, an electronic device, and a readable medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A device control method characterized by, The method includes: The modified content of the target configuration item file and the corresponding identifier of the target configuration item file are respectively used as the target configuration value and the target identifier; the target configuration item file is any configuration item file in the preset configuration file directory, and the configuration file directory includes the configuration item files corresponding to each controlled device; Based on the target configuration value, the target identifier, and the preset specified command template, a target configuration command is generated and executed to modify the target configuration item corresponding to the target configuration item file, so that the value of the target configuration item is modified to the target configuration value.

2. The method of claim 1, wherein, The identifier corresponding to the configuration item file is the file path of the configuration item file; The step of modifying the target configuration item file content and the corresponding identifier of the target configuration item file as the target configuration value and target identifier, respectively, includes: Obtain the file path of the target configuration item file, and use it as the target identifier; After performing the modification operation, the file content of the target configuration item file is read as the target configuration value.

3. The method of claim 1, wherein, The method further includes: Load the description information of the predefined category directory, device directory, and configuration item files located at the next level under the device directory, and generate and display the configuration file directory based on the description information; The device directory represents the controlled devices; the configuration file at the next level of the device directory represents the configuration items corresponding to the controlled devices. The classification directory represents the equipment type corresponding to the controlled device, and the next level of the classification directory is the equipment directory corresponding to the equipment type to which the controlled device belongs.

4. The method of claim 1, wherein, The method further includes: If a user triggers the target configuration file, the target configuration file is opened; When a modification operation on the target configuration item file is detected, if the modified file content meets the preset content requirements, the modified file content of the target configuration item file and the corresponding identifier of the target configuration item file are respectively used as the target configuration value and the target identifier.

5. The method of claim 4, wherein, The method further includes: In response to an open event on the target configuration file, the current file content of the target configuration file is backed up to obtain a backup file; If the feedback information of the target configuration command indicates control failure, or if the modified file content does not meet the preset content requirements, the target configuration file shall be restored according to the backup file. If the feedback information from the target configuration command indicates successful control, the backup file is deleted.

6. The method according to any one of claims 1 to 5, characterized in that, The specified command template is pre-generated based on the configuration commands of the target configuration tool, which is a configuration tool that supports the target configuration item; Then, generating and executing the target configuration command includes: The command template corresponding to the target identifier is found in the preset configuration item identifier and command template correspondence table and used as the specified command template; the command template is generated according to the configuration command of the configuration tool that supports the configuration item represented by the configuration item identifier; Based on the specified command template, the target configuration value, and the target identifier, the target configuration command is generated, and the target configuration tool is invoked to execute the target configuration command.

7. The method of claim 6, wherein, The step of generating the target configuration command based on the specified command template, the target configuration value, and the target identifier includes: Fill in the target configuration value and the device name carried in the target identifier into all the specified command templates to obtain the target configuration command; Then, executing the target configuration command includes: Select one of the target configuration commands as the command to be executed, and call the target configuration tool corresponding to the command to be executed to execute the command to modify the value of the target configuration item to the target configuration value; If the execution fails, return to the step of selecting one of the target configuration commands as the command to be executed; If the execution is successful, the process ends.

8. The method of claim 7, wherein, The method further includes: If the target configuration command is not successfully generated or all target configuration commands fail to execute, a feedback message indicating control failure is generated. If the target configuration command is executed successfully, feedback information indicating successful control is generated.

9. An apparatus control device characterized by comprising: The device includes: The determination module is used to take the modified content of the target configuration item file and the identifier corresponding to the target configuration item file as the target configuration value and the target identifier, respectively; the target configuration item file is any configuration item file in a preset configuration file directory, and the configuration file directory includes configuration item files corresponding to each controlled device; The first processing module is used to generate and execute a target configuration command based on the target configuration value, the target identifier, and a preset specified command template, so as to modify the target configuration item corresponding to the target configuration item file, and modify the value of the target configuration item to the target configuration value.

10. An electronic device, comprising: include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store executable instructions that cause the processor to perform the method as described in any one of claims 1 to 8.

11. A machine-readable medium, characterized in that, It stores instructions that, when executed by one or more processors, cause the processors to perform the method as described in any one of claims 1 to 8.