WO2017152526A1 - 外部设备自动挂载和通知的控制方法及系统 - Google Patents

外部设备自动挂载和通知的控制方法及系统 Download PDF

Info

Publication number
WO2017152526A1
WO2017152526A1 PCT/CN2016/084854 CN2016084854W WO2017152526A1 WO 2017152526 A1 WO2017152526 A1 WO 2017152526A1 CN 2016084854 W CN2016084854 W CN 2016084854W WO 2017152526 A1 WO2017152526 A1 WO 2017152526A1
Authority
WO
WIPO (PCT)
Prior art keywords
external device
application
list
information
plug
Prior art date
Application number
PCT/CN2016/084854
Other languages
English (en)
French (fr)
Inventor
陈伟
Original Assignee
深圳Tcl数字技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳Tcl数字技术有限公司 filed Critical 深圳Tcl数字技术有限公司
Publication of WO2017152526A1 publication Critical patent/WO2017152526A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4081Live connection to bus, e.g. hot-plugging

Definitions

  • the present invention relates to the field of embedded technologies, and in particular, to a method and system for controlling automatic mounting and notification of external devices.
  • An object of the present invention is to provide a method and system for automatically mounting and notifying an external device, which is used to automatically mount an external device in an embedded system, and to notify the mounting information that the external device is required to be attached.
  • a control method for automatically mounting and notifying an external device is provided.
  • the control method for automatically mounting and notifying the external device is applied to an embedded system, and the external device is automatically mounted.
  • notification control methods include:
  • the plugging environment variable is parsed, and the corresponding file and path are created or deleted in the sysfs file system according to the parsing result;
  • parsing the plug environment variable and creating or deleting the corresponding file and path in the sysfs file system according to the parsing result include:
  • the control method for automatically mounting and notifying the external device further includes:
  • the cold plug information of the external device obtained after traversing the sysfs file system is encapsulated into an XML message and sent to the core process.
  • the creating or deleting a device node corresponding to the external device in the preset path includes:
  • the sending, by the plugging information of the external device, the application in the application list of the subscribed message includes:
  • the core process communicates with each application of the application list through a socket or a shared memory;
  • the detecting before the insertion or removal of the external device currently includes:
  • the list of peripherals and the list of applications are created.
  • the present invention further provides a method for controlling automatic mounting and notification of an external device, including:
  • the plugging environment variable is parsed, and the corresponding file and path are created or deleted in the sysfs file system according to the parsing result;
  • the plug-in information of the external device is sent to each application in the application list of the subscribed message.
  • parsing the plug environment variable and creating or deleting the corresponding file and path in the sysfs file system according to the parsing result include:
  • the hot plug information of the external device is encapsulated into an XML message and sent to the core process.
  • control method for automatically mounting and notifying the external device further includes:
  • the cold plug information of the external device obtained after traversing the sysfs file system is encapsulated into an XML message and sent to the core process.
  • the creating or deleting a device node corresponding to the external device in the preset path includes:
  • the sending, by the plugging information of the external device, the application in the application list of the subscribed message includes:
  • the core process communicates with each application of the application list through a socket or a shared memory;
  • the detecting before the insertion or removal of the external device currently includes:
  • the list of peripherals and the list of applications are created.
  • a control system for automatically mounting and notifying an external device including:
  • a detecting module configured to detect whether there is currently an external device plugged or unplugged
  • the parsing module is configured to parse the plug-in environment variable when hot plugging of the external device is detected, and create or delete the corresponding file and path in the sysfs file system according to the parsing result;
  • a mounting module configured to create or delete a device node corresponding to the external device in a preset path
  • the notification module is configured to send the plug-in information of the external device to each application in the application list of the subscribed message.
  • the parsing module comprises:
  • a parsing sub-module configured to: when the hot plug of the external device is detected, receive and interpret the plug-in environment variable corresponding to the hot plug event of the external device according to a preset rule;
  • the information change submodule is configured to create or delete a file and a path corresponding to the external device in the sysfs file system according to the hot plug information of the external device obtained by parsing the plugged environment variable;
  • the messaging sub-module is configured to encapsulate the hot plug information of the external device into an XML message and send it to a core process.
  • control system for automatically mounting and notifying the external device further includes:
  • the cold plug detection module is used to traverse the sysfs file system to find cold swap information when booting;
  • the message transmission module is configured to encapsulate the cold plug information of the external device obtained after traversing the sysfs file system into an XML message and send the message to the core process.
  • the mounting module comprises:
  • a message receiving submodule configured to receive the XML message and unpack it
  • a device node management sub-module configured to create or delete a device node corresponding to an external device in a path corresponding to the dev file in the sysfs file system according to the XML message, to complete mounting or uninstalling the external device ;
  • a submodule is mounted for updating the creation or deletion information of the external device to a list of peripherals.
  • the notification module comprises:
  • a sub-module for receiving a subscription message request sent by the application and establishing an application list
  • a notification submodule configured to notify the application in the application list of the updated peripheral list or the update information of the peripheral list; and further configured to receive the unsubscribe message request sent by the application and according to the The unsubscribe message request deletes the corresponding application from the application list.
  • the core process communicates with each application of the application list through a socket or a shared memory;
  • the control system for automatically mounting and notifying the external device further includes:
  • a process writing module configured to write the core process into a boot self-starting script file
  • a list creation module for creating the list of peripherals and the list of applications.
  • the technical solution provided by the embodiment of the present invention may have the following beneficial effects: detecting whether there is currently an external device plugged or unplugged; when detecting the presence of hot plugging of the external device, parsing the plugged environment variable, and according to the parsing result in the sysfs file system Create or delete the corresponding file and path; create or delete the device node corresponding to the external device in the preset path; send the plug-in information of the external device to each application in the application list of the subscribed message.
  • the invention automatically mounts the external device in the embedded system, and realizes the application program that needs to obtain the information about the mounting of the external device by the mounting information, and can save CPU resources and reduce the requirement while satisfying the requirements of the embedded system. Memory usage, which in turn improves user experience.
  • FIG. 1 is a flowchart of a method for controlling automatic device mounting and notification of an external device according to an exemplary embodiment of the present invention
  • FIG. 2 is a flowchart of a step S20 of a method for controlling automatic device mounting and notification of an external device according to an exemplary embodiment of the present invention
  • FIG. 3 is a flowchart of another method for controlling automatic mounting and notification of an external device according to an exemplary embodiment of the present invention
  • FIG. 4 is a flowchart of step S30 of a method for controlling automatic device mounting and notification of an external device according to an exemplary embodiment of the present invention
  • FIG. 5 is a flowchart of a step S40 of a method for controlling automatic device mounting and notification of an external device according to an exemplary embodiment of the present invention
  • FIG. 6 is a flowchart of still another method for controlling automatic device mounting and notification of an external device according to an exemplary embodiment of the present invention.
  • FIG. 7 is a block diagram of a control system for automatic mounting and notification of an external device according to an exemplary embodiment of the present invention.
  • FIG. 8 is a block diagram of a parsing module 62 of a control system for external device automounting and notification according to an exemplary embodiment of the present invention
  • FIG. 9 is a diagram of another control system for automatically mounting and notifying an external device according to an exemplary embodiment of the present invention.
  • FIG. 10 is a block diagram of a mounting module 63 of a control system for automatically mounting and notifying an external device according to an exemplary embodiment of the present invention
  • FIG. 11 is a block diagram of a notification module 64 of a control system for external device automounting and notification according to an exemplary embodiment of the present invention
  • FIG. 12 is a block diagram of still another control system for external device automounting and notification according to an exemplary embodiment of the present invention.
  • the embodiment of the invention provides a method and a system for automatically mounting and notifying an external device, which are used to automatically mount an external device in an embedded system, and notify the installation of the information about the mounting of the external device.
  • Each application while meeting the needs of the embedded system, can save CPU resources, reduce memory usage, and thus improve user experience.
  • the method includes steps S10-S40:
  • step S10 it is detected whether there is currently an external device plugged or unplugged; wherein the plugging (plugging or unplugging) of the external device includes hot plugging and cold plugging, and the plugging and unplugging definition of the external device before the booting is performed For hot swapping, the plugging and unplugging of external devices after booting is defined as hot swapping.
  • step S20 when hot plugging of the external device is detected, the plugging environment variable is parsed, and the corresponding file and path are newly created or deleted in the sysfs file system according to the parsing result; that is, when the booting is detected
  • the external device is inserted or removed.
  • the plug-in environment variable that is configured when the external device is hot-swapped is pre-defined in the embedded system, when an external device is inserted or removed after being turned on, Receive and parse the plug-in environment variable corresponding to the hot plug of the external device, and create or delete the corresponding file and path in the sysfs file system according to the parsed plug-in environment variable.
  • the detection of the plugging and unplugging behavior of the external device is performed by the peripheral sensing process, and the peripheral sensing process performs the following operations: when detecting the insertion of the external device, newly creating a corresponding file and path in the sysfs file system, when detecting When the external device is unplugged, the file and path of the external device that existed in the sysfs file system are deleted, that is, the file and path changes in the file system caused by the hot plugging of the external device are synchronously changed. .
  • the step S20 includes:
  • Step S201 When it is detected that hot plugging of the external device exists, receiving and interpolating the plugging environment variable corresponding to the hot plug event of the external device according to a preset rule; specifically, in an embodiment, when detecting When there is hot plugging of an external device, a preset mechanism (such as the uevent_helper mechanism) in the linux (embedded system) kernel calls the peripheral aware process to receive the plug-in corresponding to the hot plug event of the external device.
  • a preset mechanism such as the uevent_helper mechanism in the linux (embedded system) kernel calls the peripheral aware process to receive the plug-in corresponding to the hot plug event of the external device.
  • the plug-in environment variables are parsed to determine whether the current external device is inserted or removed; for example, the parsed plug-in environment variable ACTION is add , indicates that the external device is inserted, and the parsed plug-in environment variable ACTION is remove, indicating that the external device is unplugged.
  • Step S202 Create or delete a file and a path corresponding to the external device in the sysfs file system according to the hot plug information of the external device obtained by parsing the plugged environment variable; that is, according to parsing the plugged environment variable
  • the obtained hot plug information of the external device synchronously changes the file and path in the sysfs file system, and assigns the path to the path environment variable;
  • the path environment variable is DEVPATH, that is, externally After the path of the device changes, you need to assign it to the DEVPATH to change its path, and the file saved in the path assigned to the DEVPATH (that is, the dev file in the /dev directory) should also be inserted according to the external device. Pull the time to make a simultaneous change.
  • Step S203 Encapsulate the hot plug information of the external device into an XML message and send the message to the core process.
  • the hot plug information of the encapsulated external device includes file and path information corresponding to the hot plug event of the external device, and the plugged environment variable information after parsing.
  • the step S10 further includes a step S70: writing the peripheral aware process and the core process to the boot self-starting script file; creating the peripheral list and the application list.
  • the step S70 is specifically: writing the peripheral aware process and the core process to the boot script file (the self-start script file may be /etc/inittab or /etc/rc.d). /rc.local); wherein the boot process of the core process is prior to the peripheral aware process, and the cold plugging of the external device may be after the booting of the peripheral aware process detected.
  • step S10 further includes step S50 and step S60:
  • step S50 the sysfs file system is traversed to find the cold swap information when booting; specifically, the interface environment variable such as SUBSYSTEM can be set in the embedded system, and the interface environment variable is automatically detected at boot time, thereby obtaining the cold of the external device. Plug and unplug information.
  • the peripheral sensation process traverses the file in the sysfs file system; wherein the files in the sysfs file system traversed include /sys/class, /sys/ Files in the path of block, /sys/device, etc.
  • step S60 the cold plug information of the external device obtained after traversing the sysfs file system is encapsulated into an XML message and sent to the core process.
  • the cold plug information of the encapsulated external device includes file and path information corresponding to a cold plug event of the external device, and information about insertion or removal of the external device.
  • step S30 a device node corresponding to the external device is created or deleted in a preset path.
  • the core process after receiving the encapsulated XML message, the core process unpacks the encapsulated XML message. Finding a preset path and creating/deleting a device node of the external device under the path completes mounting/uninstalling of the external device.
  • the step S30 includes:
  • Step S301 Receive the XML message and unpack it; wherein the XML message includes cold plug information of the external device and hot plug information of the external device, and an XML message may include the plugging and unplugging situation of multiple devices. (For example, including cold swapping of multiple external devices detected at power-on), or only one hot-swappable device.
  • Step S302 Create or delete a device node corresponding to the external device in the path corresponding to the dev file in the sysfs file system according to the XML message, to complete mounting or uninstalling the external device;
  • the path associated with the path environment variable DEVPATH which is the file in the /dev directory of the sysfs file system.
  • Step S303 updating the creation or deletion information of the external device to the peripheral list. That is, if it is hot plugging of an external device, for example, if the plugged environment variable ACTION in the XML information after parsing is add, then a new device node is created under the /dev directory, according to a predetermined rule (for example, Use a regular expression to represent the rule, and the rule can be configured using a configuration file) to be mounted to a directory, and set the read and write permissions and owner, group owner of the external device, and add the external device To the device list, to complete the mounting of the external device; and if the plug-in environment variable ACTION in the XML information after parsing is removed, the device node in the /dev directory needs to be deleted, and the corresponding directory is uninstalled, and The external device device is removed from the device list.
  • a predetermined rule for example, Use a regular expression to represent the rule, and the rule can be configured using a configuration file
  • step S40 the plug-in information of the external device is transmitted to each application in the application list of the subscribed message. That is, in one embodiment, all applications can connect to and send messages to the core process, if an application sends subscription information to the core process indicating that it is interested in plugging and unplugging changes to external devices, this is The application is added to the application list in order to send the plug-in information of the external device to it. At the same time, each application in the application list can also send the unsubscribe information to indicate that it does not want to pay attention to the plug-in change of the external device. At this time, the core process will delete the application from the application list, and Open a connection to the application. Of course, when all applications connect to the core process for the first time, the core process needs to send the device information in the peripheral list to the application at this time, so that the application determines whether it needs to subscribe.
  • the step S40 includes:
  • Step S401 Receive a subscription message request sent by an application (for example, a multimedia scanner, a file browser, etc.) and establish an application list; that is, all applications may connect to and send a message to the core process, if an application pair
  • the core process sends subscription information indicating that it is interested in the plug-in change of the external device, and the application is added to the application list in order to send the plug-in information of the external device to it.
  • step S402 the updated peripheral list or the update information of the peripheral list is notified to each application in the application list; wherein the core process is further configured to receive an unsubscribe message request sent by the application. And deleting the corresponding application from the application list according to the unsubscribing message request.
  • the plug-in information of the external device that is broadcasted is the device information in the peripheral list, and the device information includes cold-plugged external device information and information of all hot-swappable external devices after booting.
  • each application in the application list can also send the unsubscribe information to indicate that it does not want to pay attention to the plug-in change of the external device.
  • the core process will delete the application from the application list, and Open a connection to the application.
  • data is exchanged through a socket (two programs on the network through a two-way communication connection, one end of the connection is called a socket) Or communicating in a shared memory manner; at the same time, the peripheral aware process and the core process also communicate through a socket or a shared memory; wherein communication between the core process and the application list is two-way And the connection between the two can be kept for a long time or disconnected once.
  • a socket two programs on the network through a two-way communication connection, one end of the connection is called a socket
  • the peripheral aware process and the core process also communicate through a socket or a shared memory; wherein communication between the core process and the application list is two-way
  • the connection between the two can be kept for a long time or disconnected once.
  • the step S10 further includes a step S80: in step S80, a peripheral list and an application list are created. After the core process is powered on and started, the peripheral list and application list need to be created by itself, so that the core process cyclically receives information and processes it.
  • the foregoing method provided by the embodiment of the present invention detects whether there is currently an external device plugged or unplugged; when it detects that there is hot plugging of the external device, parses the plugged environment variable, and creates or deletes the corresponding file in the sysfs file system according to the parsing result.
  • the invention automatically mounts the external device in the embedded system, and realizes the application information that needs to obtain the information about the mounting of the external device by the mounting information, and can save CPU resources while satisfying the requirements of the embedded system. Reduce memory usage and increase user experience.
  • the present invention further provides a control system for automatically mounting and notifying an external device according to the method for controlling the automatic mounting and notification of the external device provided by the embodiment of the present invention.
  • the system may include:
  • the detecting module 61 is configured to detect whether there is currently an external device plugged or unplugged;
  • the parsing module 62 is configured to parse the plug-in environment variable when hot plugging of the external device is detected, and create or delete the corresponding file and path in the sysfs file system according to the parsing result;
  • a mounting module 63 configured to create or delete a device node corresponding to the external device in a preset path
  • the notification module 63 is configured to send the plug-in information of the external device to each application in the application list of the subscribed message.
  • the parsing module 62 includes:
  • the parsing sub-module 621 is configured to: when detecting the hot plugging of the external device, receive and parse the plug-in environment variable corresponding to the hot plug event of the external device according to a preset rule;
  • the information change sub-module 622 is configured to create or delete a file and a path corresponding to the external device in the sysfs file system according to the hot plug information of the external device obtained by parsing the plugged environment variable;
  • the message transmission sub-module 623 is configured to encapsulate the hot plug information of the external device into an XML message and send it to a core process.
  • control system for automatically mounting and notifying the external device further includes:
  • the cold plug detection module 65 is configured to traverse the sysfs file system to find cold swap information when booting;
  • the message transmission module 66 is configured to encapsulate the cold plug information of the external device obtained after traversing the sysfs file system into an XML message and send the message to the core process.
  • the mounting module 63 includes:
  • a message receiving submodule 631 configured to receive the XML message and unpack it
  • the device node management sub-module 632 is configured to create or delete a device node corresponding to the external device in the path corresponding to the dev file in the sysfs file system according to the XML message, to complete the mounting of the external device or Unload
  • the mount submodule 633 is configured to update the creation or deletion information of the external device to the peripheral list.
  • the notification module 64 includes:
  • a sub-module 641 configured to receive a subscription message request sent by an application and establish an application list
  • the notification sub-module 642 is configured to notify the application in the application list of the updated peripheral list or the update information of the peripheral list; and is further configured to receive the unsubscribe message request sent by the application according to The unsubscribe message request deletes the corresponding application from the application list.
  • the core process communicates with each application of the application list by means of a socket or a shared memory; as shown in FIG. 12, the control system for automatically mounting and notifying the external device further includes:
  • a process writing module 67 configured to write the core process into a boot self-starting script file
  • the list creation module 68 is configured to create the peripheral list and the application list.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Computer Hardware Design (AREA)

Abstract

一种外部设备自动挂载和通知的控制方法及系统,所述方法包括:检测当前是否存在外部设备的插拔(S10);当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径(S20);在预设路径下创建或删除与所述外部设备对应的设备节点(S30);将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序(S40)。在嵌入式系统中自动挂载外部设备的同时,实现将该挂载信息通知需要获取外部设备挂载信息的各应用程序,且在满足嵌入式系统的需求的同时,能够节约CPU资源,减少内存占用,进而提升用户体验度。

Description

外部设备自动挂载和通知的控制方法及系统
技术领域
本发明涉及嵌入式技术领域,尤其涉及外部设备自动挂载和通知的控制方法及系统。
背景技术
在嵌入式设备的应用中,经常会出现接入外部设备的需求,其中,典型的外部设备的接入有热插拔U盘、移动硬盘等,毫无疑问,用户希望能自动挂载这些外部设备后直接使用。现有技术中,将外部设备挂载在PC(personal computer:个人电脑)上一般采用udev方案,然而udev作为后台执行程序并不适用于嵌入式系统,其会消耗较多的CPU(中央处理器:Central Processing Unit)资源,同时占用过多的内存,并且,对于嵌入式系统来说,应用层除了自动挂载以外,还希望外部设备在插入后能自动通知,从而使得应用层在获取相关挂载信息后能够使用该外部设备,该方案在现有技术中尚未出现。
发明内容
本发明的目的在于提供一种外部设备自动挂载和通知的控制方法及系统,用以在嵌入式系统中自动挂载外部设备的同时,实现将该挂载信息通知需要获取外部设备挂载信息的各应用程序,且在满足嵌入式系统的需求的同时,能够节约CPU资源,减少内存占用,进而提升用户体验度。
根据本发明实施例的第一方面,提供一种外部设备自动挂载和通知的控制方法,所述外部设备自动挂载和通知的控制方法应用于嵌入式系统中,所述外部设备自动挂载和通知的控制方法包括:
检测当前是否存在外部设备的插拔;
当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
在预设路径下创建或删除与所述外部设备对应的设备节点;
将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序;其中,
所述当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径包括:
当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
将所述外部设备的热插拔信息封装为XML消息并发送至核心进程;
所述外部设备自动挂载和通知的控制方法还包括:
开机时遍历sysfs文件系统以查找冷插拔信息;
将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。
优选地,所述在预设路径下创建或删除与所述外部设备对应的设备节点包括:
接收所述XML消息并将其解包;
根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
将所述外部设备的创建或删除信息更新至外设列表。
优选地,所述将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序包括:
接收应用程序发出的订阅消息请求并建立应用列表;
将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;
接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
优选地,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;
所述检测当前是否存在外部设备的插拔之前还包括:
将所述核心进程写入开机自启动脚本文件中;
创建所述外设列表和所述应用列表。
此外,为了实现上述发明目的,本发明还提供一种外部设备自动挂载和通知的控制方法,包括:
检测当前是否存在外部设备的插拔;
当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
在预设路径下创建或删除与所述外部设备对应的设备节点;
将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。
优选地,所述当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径包括:
当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
将所述外部设备的热插拔信息封装为XML消息并发送至核心进程。
优选地,所述的外部设备自动挂载和通知的控制方法还包括:
开机时遍历sysfs文件系统以查找冷插拔信息;
将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。
优选地,所述在预设路径下创建或删除与所述外部设备对应的设备节点包括:
接收所述XML消息并将其解包;
根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
将所述外部设备的创建或删除信息更新至外设列表。
优选地,所述将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序包括:
接收应用程序发出的订阅消息请求并建立应用列表;
将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;
接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
优选地,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;
所述检测当前是否存在外部设备的插拔之前还包括:
将所述核心进程写入开机自启动脚本文件中;
创建所述外设列表和所述应用列表。
根据本发明实施例的第二方面,还提供一种外部设备自动挂载和通知的控制系统,包括:
检测模块,用于检测当前是否存在外部设备的插拔;
解析模块,用于当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
挂载模块,用于在预设路径下创建或删除与所述外部设备对应的设备节点;
通知模块,用于将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。
优选地,所述解析模块包括:
解析子模块,用于当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
信息变更子模块,用于根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
消息传送子模块,用于将所述外部设备的热插拔信息封装为XML消息并发送至核心进程。
优选地,所述外部设备自动挂载和通知的控制系统还包括:
冷插拔检测模块,用于开机时遍历sysfs文件系统以查找冷插拔信息;
消息传送模块,用于将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。
优选地,所述挂载模块包括:
消息接收子模块,用于接收所述XML消息并将其解包;
设备节点管理子模块,用于根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
挂载子模块,用于将所述外部设备的创建或删除信息更新至外设列表。
优选地,所述通知模块包括:
订阅子模块,用于接收应用程序发出的订阅消息请求并建立应用列表;
通知子模块,用于将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;还用于接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
优选地,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;所述外部设备自动挂载和通知的控制系统还包括:
进程写入模块,用于将所述核心进程写入开机自启动脚本文件中;
列表创建模块,用于创建所述外设列表和所述应用列表。
本发明实施例提供的技术方案可产生以下有益效果:检测当前是否存在外部设备的插拔;当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;在预设路径下创建或删除与所述外部设备对应的设备节点;将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。本发明在嵌入式系统中自动挂载外部设备的同时,实现将该挂载信息通知需要获取外部设备挂载信息的各应用程序,在满足嵌入式系统的需求的同时,能够节约CPU资源,减少内存占用,进而提升用户体验度。
本发明的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点可通过在所写的说明书、权利要求书、以及附图中所特别指出的结构来实现和获得。
下面通过附图和实施例,对本发明的技术方案做进一步的详细描述。
附图说明
图1为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制方法的流程图;
图2为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制方法的步骤S20的流程图;
图3为本发明根据一示例性实施例示出的另一种外部设备自动挂载和通知的控制方法的流程图;
图4为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制方法的步骤S30的的流程图;
图5为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制方法的步骤S40的流程图;
图6为本发明根据一示例性实施例示出的又一种外部设备自动挂载和通知的控制方法的流程图;
图7为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制系统的框图;
图8为本发明根据一示例性实施例示出的外部设备自动挂载和通知的控制系统的解析模块62的框图;
图9为本发明根据一示例性实施例示出的另一种外部设备自动挂载和通知的控制系统的图;
图10为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制系统的挂载模块63的框图;
图11为本发明根据一示例性实施例示出的一种外部设备自动挂载和通知的控制系统的通知模块64的框图;
图12为本发明根据一示例性实施例示出的又一种外部设备自动挂载和通知的控制系统的框图。
具体实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。
本发明实施例提供了一种外部设备自动挂载和通知的控制方法及系统,用以在嵌入式系统中自动挂载外部设备的同时,实现将该挂载信息通知需要获取外部设备挂载信息的各应用程序,且在满足嵌入式系统的需求的同时,能够节约CPU资源,减少内存占用,进而提升用户体验度。如图1所示,该方法包括步骤S10-S40:
在步骤S10中,检测当前是否存在外部设备的插拔;其中,所述外部设备的插拔(插入或拔出)包括热插拔和冷插拔,在开机之前进行的外部设备的插拔定义为冷插拔;而在开机之后进行的外部设备的插拔均被定义为热插拔。
在步骤S20中,当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中新建或删除对应的文件和路径;也即,当检测到在开机之后插入或者拔出了外部设备,此时,由于在嵌入式系统中预先定义了外部设备热插拔时会被配置的插拔环境变量,因此当有外部设备在开机之后插入或者拔出时,会接收并解析外部设备的热插拔所对应的插拔环境变量,并根据解析后的插拔环境变量,在sysfs文件系统中新建或删除对应的文件和路径。其中,对外部设备的插拔行为的检测是由外设感知进程执行的,外设感知进程执行以下操作:当检测到外部设备插入时,在sysfs文件系统中新建对应的文件和路径,当检测到外部设备拔出时,将sysfs文件系统中已存在的该外部设备的文件和路径删除,也即对由该外部设备的热插拔所引起的文件系统中的文件和路径的变化进行同步变更。
在一些实施例中,如图2所示,所述步骤S20包括:
步骤S201、当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;具体的,在一实施例中,当检测到存在外部设备的热插拔时,linux(嵌入式系统)内核中的预设机制(如uevent_helper机制)调用所述外设感知进程,接收与所述外部设备的热插拔事件对应的插拔环境变量,并根据linux系统中预先定义的插拔环境变量的配置规则,解析所述插拔环境变量,以判断当前外部设备是插入或拔出;比如,解析后的插拔环境变量ACTION为add,表示外部设备插入,解析后的插拔环境变量ACTION为remove,则表示外部设备拔出。
步骤S202、根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;也即根据解析所述插拔环境变量后所得到的外部设备的热插拔信息同步变更sysfs文件系统中的文件和路径,并将所述路径赋值给路径环境变量;在一实施例中,所述路径环境变量为DEVPATH,也即,在外部设备的路径发生变化后,需要将其赋值给DEVPATH,以更改其路径,且赋值给DEVPATH后的路径下保存的文件(即为/dev目录下的dev文件)也应该根据所述外部设备的插拔时间进行同步变更。
步骤S203、将所述外部设备的热插拔信息封装为XML消息并发送至核心进程。其中,封装的所述外部设备的热插拔信息包括外部设备的热插拔事件所对应变更的文件和路径信息,还包括解析后的所述插拔环境变量信息。
如图6所示,所述步骤S10之前还包括步骤S70:将外设感知进程和核心进程写入开机自启动脚本文件中;创建所述外设列表和所述应用列表。在一个实施例中,所述步骤S70具体为:将上述外设感知进程与上述核心进程写入开机自启动脚本文件(所述自启动脚本文件可以是/etc/inittab或者/etc/rc.d/rc.local)中;其中,所述核心进程的开机自启动完成时间先于所述外设感知进程,且所述外部设备的冷插拔在开机自运行所述外设感知进程之后可以被检测到。
在一些实施例中,如图3所示,所述步骤S10之后还包括步骤S50和步骤S60:
在步骤S50中,开机时遍历sysfs文件系统以查找冷插拔信息;具体的,可以在嵌入式系统中设置接口环境变量如SUBSYSTEM,在开机时自动检测该接口环境变量,进而获取外部设备的冷插拔信息。同时,在检测到存在外部设备的冷插拔时,通过所述外设感知进程遍历sysfs文件系统中的文件;其中,遍历的所述sysfs文件系统中的文件包括/sys/class、/sys/block、/sys/device等路径下的文件。
在步骤S60中,将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。其中,封装的所述外部设备的冷插拔信息包括外部设备的冷插拔事件所对应的文件和路径信息,还包括所述外部设备的插或拔的信息。
在步骤S30中,在预设路径下创建或删除与所述外部设备对应的设备节点;具体的,在一个实施例中,所述核心进程在接收到封装的XML消息后,将其解包并找寻预设的路径并在该路径下创建/删除所述外部设备的设备节点,完成所述外部设备的挂载/卸载。
在一些实施例中,如图4所示,所述步骤S30包括:
步骤S301、接收所述XML消息并将其解包;其中,所述XML消息包括外部设备的冷插拔信息和外部设备的热插拔信息,且一个XML消息可能包含多个设备的插拔情况(例如包含开机时检测到的多个外部设备的冷插拔),也可能只有一个热插拔设备的情况。
步骤S302、根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;所述dev文件为路径环境变量DEVPATH所关联的路径,也即为sysfs文件系统中/dev目录下的文件。
步骤S303、将所述外部设备的创建或删除信息更新至外设列表。也即,如果是外部设备的热插拔,比如,如果解析后XML信息中的插拔环境变量ACTION为add,那么在/dev目录下面创建新的设备节点,同时根据预定的规则(比如,可以使用正则表达式表示该规则,且该规则可以使用配置文件进行配置)挂载到某个目录下,并且设置该外部设备的读写权限和属主、群属主,同时,将该外部设备添加到设备列表,从而完成所述外部设备的挂载;而如果解析后XML信息中的插拔环境变量ACTION为remove,此时需要删除/dev目录下的设备节点,卸载与其对应的目录,同时把所述外部设备设备从设备列表中移除。可理解的,如果是所述外部设备的冷插拔,也可以参照以上方式,在直接根据检测到的插拔信息将所述外部设备挂载/卸载的同时,创建/删除信息变更至外设列表,完成所述外部设备的挂载/卸载。
在步骤S40中,将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。也即,在一个实施例中,所有应用可以连接至所述核心进程并向其发送消息,如果一个应用对所述核心进程发送订阅信息表示其对外部设备的插拔变化是感兴趣的,此时把该应用加入到应用列表中,以便于向其发送外部设备的插拔信息。同时,应用列表中的各应用也可以发送取消订阅信息来表示其并不想不关注外部设备的插拔变化情况,此时,所述核心进程将从所述应用列表中删除所述应用,并且断开与所述应用的连接。当然,在所有应用第一次连接所述核心进程时,所述核心进程都需要发送此时外设列表中的设备信息给该应用,以便于该应用确定其是否需要订阅。
在一些实施例中,如图5所示,所述步骤S40包括:
步骤S401、接收应用程序(例如多媒体扫描程序、文件浏览器等应用)发出的订阅消息请求并建立应用列表;也即,所有应用可以连接至所述核心进程并向其发送消息,如果一个应用对所述核心进程发送订阅信息表示其对外部设备的插拔变化是感兴趣的,此时把该应用加入到应用列表中,以便于向其发送外部设备的插拔信息。
步骤S402、将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;其中,所述核心进程还用于接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。其中,广播通知的所述外部设备的插拔信息为所述外设列表中的设备信息,所述设备信息包括冷插拔的外部设备信息和开机之后的所有热插拔的外部设备的信息。同时,应用列表中的各应用也可以发送取消订阅信息来表示其并不想不关注外部设备的插拔变化情况,此时,所述核心进程将从所述应用列表中删除所述应用,并且断开与所述应用的连接。
在一些实施例中,所述核心进程与所述应用列表的各应用程序之间,通过socket(网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket)或者共享内存的方式通信;同时,所述外设感知进程与所述核心进程之间也通过socket或者共享内存的方式通信;其中,所述核心进程与所述应用列表之间的通信是双向的,且两者之间可以长时间保持连接也可以连接一次就断开。
如图6所示,所述步骤S10之前还包括步骤S80:在步骤S80中,创建外设列表和应用列表。在所述核心进程开机自启动之后,即需要自行创建所述外设列表和应用列表,以便于所述核心进程循环接收信息并进行处理。
本发明实施例提供的上述方法,检测当前是否存在外部设备的插拔;当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;在预设路径下创建或删除与所述外部设备对应的设备节点;将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。本发明在嵌入式系统中自动挂载外部设备的同时,实现将该挂载信息通知需要获取外部设备挂载信息的各应用程序,且在满足嵌入式系统的需求的同时,能够节约CPU资源,减少内存占用,进而提升用户体验度。
对应本发明实施例提供的外部设备自动挂载和通知的控制方法,本发明还提供一种外部设备自动挂载和通知的控制系统,如图7所示,该系统可包括:
检测模块61,用于检测当前是否存在外部设备的插拔;
解析模块62,用于当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
挂载模块63,用于在预设路径下创建或删除与所述外部设备对应的设备节点;
通知模块63,用于将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。
优选地,如图8所示,所述解析模块62包括:
解析子模块621,用于当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
信息变更子模块622,用于根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
消息传送子模块623,用于将所述外部设备的热插拔信息封装为XML消息并发送至核心进程。
优选地,如图9所示,所述外部设备自动挂载和通知的控制系统还包括:
冷插拔检测模块65,用于开机时遍历sysfs文件系统以查找冷插拔信息;
消息传送模块66,用于将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至核心进程。
优选地,如图10所示,所述挂载模块63包括:
消息接收子模块631,用于接收所述XML消息并将其解包;
设备节点管理子模块632,用于根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
挂载子模块633,用于将所述外部设备的创建或删除信息更新至外设列表。
优选地,如图11所示,所述通知模块64包括:
订阅子模块641,用于接收应用程序发出的订阅消息请求并建立应用列表;
通知子模块642,用于将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;还用于接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
优选地,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;如图12所示,所述外部设备自动挂载和通知的控制系统还包括:
进程写入模块67,用于将所述核心进程写入开机自启动脚本文件中;
列表创建模块68,用于创建所述外设列表和所述应用列表。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。

Claims (16)

  1. 一种外部设备自动挂载和通知的控制方法,其特征在于,所述外部设备自动挂载和通知的控制方法应用于嵌入式系统中,所述外部设备自动挂载和通知的控制方法包括:
    检测当前是否存在外部设备的插拔;
    当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
    在预设路径下创建或删除与所述外部设备对应的设备节点;
    将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序;其中,
    所述当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径包括:
    当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
    根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
    将所述外部设备的热插拔信息封装为XML消息并发送至核心进程;
    所述外部设备自动挂载和通知的控制方法还包括:
    开机时遍历sysfs文件系统以查找冷插拔信息;
    将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。
  2. 如权利要求1所述的外部设备自动挂载和通知的控制方法,其特征在于,所述在预设路径下创建或删除与所述外部设备对应的设备节点包括:
    接收所述XML消息并将其解包;
    根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
    将所述外部设备的创建或删除信息更新至外设列表。
  3. 如权利要求2所述的外部设备自动挂载和通知的控制方法,其特征在于,所述将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序包括:
    接收应用程序发出的订阅消息请求并建立应用列表;
    将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;
    接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
  4. 如权利要求3所述的外部设备自动挂载和通知的控制方法,其特征在于,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;所述检测当前是否存在外部设备的插拔之前还包括:
    将所述核心进程写入开机自启动脚本文件中;
    创建所述外设列表和所述应用列表。
  5. 一种外部设备自动挂载和通知的控制方法,其特征在于,包括:
    检测当前是否存在外部设备的插拔;
    当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
    在预设路径下创建或删除与所述外部设备对应的设备节点;
    将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。
  6. 如权利要求5所述的外部设备自动挂载和通知的控制方法,其特征在于,所述当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径包括:
    当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
    根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
    将所述外部设备的热插拔信息封装为XML消息并发送至核心进程。
  7. 如权利要求6所述的外部设备自动挂载和通知的控制方法,其特征在于,还包括:
    开机时遍历sysfs文件系统以查找冷插拔信息;
    将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。
  8. 如权利要求6所述的外部设备自动挂载和通知的控制方法,其特征在于,所述在预设路径下创建或删除与所述外部设备对应的设备节点包括:
    接收所述XML消息并将其解包;
    根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
    将所述外部设备的创建或删除信息更新至外设列表。
  9. 如权利要求8所述的外部设备自动挂载和通知的控制方法,其特征在于,所述将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序包括:
    接收应用程序发出的订阅消息请求并建立应用列表;
    将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;
    接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
  10. 如权利要求9所述的外部设备自动挂载和通知的控制方法,其特征在于,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;
    所述检测当前是否存在外部设备的插拔之前还包括:
    将所述核心进程写入开机自启动脚本文件中;
    创建所述外设列表和所述应用列表。
  11. 一种外部设备自动挂载和通知的控制系统,其特征在于,包括:
    检测模块,用于检测当前是否存在外部设备的插拔;
    解析模块,用于当检测到存在外部设备的热插拔时,解析插拔环境变量,并根据解析结果在sysfs文件系统中创建或删除对应的文件和路径;
    挂载模块,用于在预设路径下创建或删除与所述外部设备对应的设备节点;
    通知模块,用于将外部设备的插拔信息发送至已订阅消息的应用列表中的各应用程序。
  12. 如权利要求11所述的外部设备自动挂载和通知的控制系统,其特征在于,所述解析模块包括:
    解析子模块,用于当检测到存在外部设备的热插拔时,接收并根据预设规则解析与所述外部设备的热插拔事件对应的插拔环境变量;
    信息变更子模块,用于根据解析所述插拔环境变量所得到的外部设备的热插拔信息在sysfs文件系统中创建或删除与外部设备对应的文件和路径;
    消息传送子模块,用于将所述外部设备的热插拔信息封装为XML消息并发送至核心进程。
  13. 如权利要求12所述的外部设备自动挂载和通知的控制系统,其特征在于,所述外部设备自动挂载和通知的控制系统还包括:
    冷插拔检测模块,用于开机时遍历sysfs文件系统以查找冷插拔信息;
    消息传送模块,用于将遍历sysfs文件系统后所得到的外部设备的冷插拔信息封装为XML消息并发送至所述核心进程。
  14. 如权利要求13所述的外部设备自动挂载和通知的控制系统,其特征在于,所述挂载模块包括:
    消息接收子模块,用于接收所述XML消息并将其解包;
    设备节点管理子模块,用于根据所述XML消息在所述sysfs文件系统中的dev文件所对应的路径下创建或删除与外部设备对应的设备节点,以完成所述外部设备的挂载或卸载;
    挂载子模块,用于将所述外部设备的创建或删除信息更新至外设列表。
  15. 如权利要求14所述的外部设备自动挂载和通知的控制系统,其特征在于,所述通知模块包括:
    订阅子模块,用于接收应用程序发出的订阅消息请求并建立应用列表;
    通知子模块,用于将更新后的外设列表或所述外设列表的更新信息通知所述应用列表中的各应用程序;还用于接收所述应用程序发出的取消订阅消息请求并根据所述取消订阅消息请求将对应的应用程序从所述应用列表中删除。
  16. 如权利要求12所述的外部设备自动挂载和通知的控制系统,其特征在于,所述核心进程与所述应用列表的各应用程序之间,通过socket或者共享内存的方式通信;所述外部设备自动挂载和通知的控制系统还包括:
    进程写入模块,用于将所述核心进程写入开机自启动脚本文件中;
    列表创建模块,用于创建所述外设列表和所述应用列表。
PCT/CN2016/084854 2016-03-09 2016-06-04 外部设备自动挂载和通知的控制方法及系统 WO2017152526A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610133038.5A CN105808299B (zh) 2016-03-09 2016-03-09 外部设备自动挂载和通知的控制方法及系统
CN201610133038.5 2016-03-09

Publications (1)

Publication Number Publication Date
WO2017152526A1 true WO2017152526A1 (zh) 2017-09-14

Family

ID=56467007

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/084854 WO2017152526A1 (zh) 2016-03-09 2016-06-04 外部设备自动挂载和通知的控制方法及系统

Country Status (2)

Country Link
CN (1) CN105808299B (zh)
WO (1) WO2017152526A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113032165A (zh) * 2021-03-24 2021-06-25 中国邮政储蓄银行股份有限公司 外设的调用方法、装置、处理器与电子设备

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542805A (zh) * 2018-11-22 2019-03-29 北京奇安信科技有限公司 Usb存储设备控制方法、装置、电子设备及存储介质
CN110111790B (zh) * 2019-05-09 2022-01-28 海信视像科技股份有限公司 智能设备的外部设备接入的处理方法、装置及设备
CN112231761B (zh) * 2020-12-14 2021-07-30 统信软件技术有限公司 一种设备挂载方法、计算设备及可读存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001037105A1 (en) * 1999-11-17 2001-05-25 Granite Microsystems, Inc. Device bay system with surprise removal prevention for supporting and controlling usb and ieee 1394 peripheral devices
CN101520792A (zh) * 2008-12-17 2009-09-02 康佳集团股份有限公司 一种自动挂载与识别系统文件的方法及其系统
CN102830970A (zh) * 2012-08-10 2012-12-19 深圳市共进电子股份有限公司 一种适用于Linux嵌入式系统的热插拔处理方法
CN103186373A (zh) * 2011-12-29 2013-07-03 盛乐信息技术(上海)有限公司 实现输入设备热插拔的系统及方法
CN103186487A (zh) * 2011-12-31 2013-07-03 青岛海尔软件有限公司 实时识别插拔usb设备的方法
US8839193B1 (en) * 2011-06-06 2014-09-16 The Mathworks, Inc. Control surfaces for a technical computing environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001037105A1 (en) * 1999-11-17 2001-05-25 Granite Microsystems, Inc. Device bay system with surprise removal prevention for supporting and controlling usb and ieee 1394 peripheral devices
CN101520792A (zh) * 2008-12-17 2009-09-02 康佳集团股份有限公司 一种自动挂载与识别系统文件的方法及其系统
US8839193B1 (en) * 2011-06-06 2014-09-16 The Mathworks, Inc. Control surfaces for a technical computing environment
CN103186373A (zh) * 2011-12-29 2013-07-03 盛乐信息技术(上海)有限公司 实现输入设备热插拔的系统及方法
CN103186487A (zh) * 2011-12-31 2013-07-03 青岛海尔软件有限公司 实时识别插拔usb设备的方法
CN102830970A (zh) * 2012-08-10 2012-12-19 深圳市共进电子股份有限公司 一种适用于Linux嵌入式系统的热插拔处理方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113032165A (zh) * 2021-03-24 2021-06-25 中国邮政储蓄银行股份有限公司 外设的调用方法、装置、处理器与电子设备

Also Published As

Publication number Publication date
CN105808299A (zh) 2016-07-27
CN105808299B (zh) 2018-07-03

Similar Documents

Publication Publication Date Title
WO2019061612A1 (zh) 贷款产品推广方法、装置及计算机可读存储介质
WO2019061613A1 (zh) 贷款资质筛选方法、装置及计算机可读存储介质
WO2017152526A1 (zh) 外部设备自动挂载和通知的控制方法及系统
WO2019100638A1 (zh) 数据同步方法、装置、设备及存储介质
WO2018120429A1 (zh) 一种资源更新的方法、终端、计算机可读存储介质及资源更新设备
WO2019128174A1 (zh) 音频播放方法、智能电视及计算机可读存储介质
WO2014026526A1 (zh) 自然人信息设置方法及电子设备
WO2019037396A1 (zh) 账户清结算方法、装置、设备及存储介质
WO2016000560A1 (en) File transmission method, file transmission apparatus, and file transmission system
WO2015103864A1 (zh) 内存管理的方法及Linux终端
WO2015158219A1 (en) Remote debugging method and apparatus for mobile terminal
WO2017119746A1 (en) Apparatus and method for transmitting and receiving file in wireless communication system supporting cloud storage service
WO2019051902A1 (zh) 终端控制方法、空调器及计算机可读存储介质
WO2018149190A1 (zh) 组件调试方法、装置、设备和计算机可读存储介质
WO2019080247A1 (zh) 产生保单批文的方法、装置、设备及计算机可读存储介质
WO2018086291A1 (zh) 资源调度方法、装置、设备及计算机可读存储介质
WO2018076875A1 (zh) 备份数据的同步方法、装置、存储介质、电子设备及服务器
WO2018014567A1 (zh) 一种提高虚拟机性能的方法、终端、设备及计算机可读存储介质
EP3338216A1 (en) Apparatus and method for protecting information in communication system
WO2019052164A1 (zh) 一种视频回访方法、装置、设备及存储介质
WO2018006581A1 (zh) 智能电视的播放方法及装置
WO2019143081A1 (ko) 데이터 통신을 제어하는 방법 및 전자 장치
WO2017024877A1 (zh) 电视主界面的切换方法及装置
WO2018201699A1 (zh) 客户评价方法、装置、设备以及计算机可读存储介质
WO2019062102A1 (zh) 磁盘阵列的挂载方法、Android设备和存储介质

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16893173

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 06/02/2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16893173

Country of ref document: EP

Kind code of ref document: A1