Method, apparatus and readable storage medium for removable device access

By unmounting the USB drive in the Linux operating system before the user logs out and remounting it after the new user logs in, the problem of the USB drive being inaccessible after a user change is solved, enabling flexible changes to device permissions and ensuring security.

CN116126405BActive Publication Date: 2026-03-27ZHONGKE FANGDE SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In Linux operating systems, USB drives inserted after a user change cannot be accessed by the new user, leading to device mount permission issues.

Method used

Before the first user account is logged out, the removable device is uninstalled and then re-identified and mounted to the second user account after the second user logs in, thus using the default mounting mechanism of the Linux operating system to change permissions.

Benefits of technology

This feature allows devices to have their access permissions removed after a user change, following the login user's change. This avoids the problem of devices becoming inaccessible, while maintaining existing file permissions and device mounting mechanisms, thus ensuring access security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126405B_ABST
    Figure CN116126405B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a removable device access method, device and readable storage medium. The removable device access method is applied to a computer device having a Linux operating system, and the method comprises: after obtaining an account logout instruction of a first user account, unmounting a removable device in a mounted state of the removable device; executing the account logout instruction to log out the first user account; after a second user account is logged in, re-identifying the removable device and mounting the removable device to the second user account. Embodiments of the present application can enable a changed user to continue accessing a U disk inserted before the user is changed after the login user of the operating system is changed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a removable device access method and device and readable storage medium. BACKGROUND

[0002] The Linux operating system is a multi-user multi-task operating system, which supports multiple users to log in an operating system to perform different tasks without affecting each other. When a first user inserts a U disk after logging in the operating system, the operating system will recognize the U disk and perform a mounting task of the U disk to mount the U disk to / media / a / , that is, the directory of the login account a of the first user. After the operating system completes the mounting task of the U disk, the owner of the U disk is the first user, and the first user can access the U disk.

[0003] However, since the U disk is mounted to the directory of the login account of the first user, the U disk is only allowed to be accessed by the super user and the first user. Thus, after the login account of the first user is logged out, a second user who logs in the operating system cannot access the U disk. Therefore, how to avoid the U disk from being inaccessible due to the change of the login user becomes a problem to be solved. SUMMARY

[0004] The embodiments of the present application provide a removable device access method, device and readable storage medium, which can enable the changed user to continue accessing the U disk inserted before the change of the login user of the operating system.

[0005] To solve the above problem, the embodiments of the present application disclose a removable device access method applied to a computer device, wherein the computer device has a Linux operating system, and the method comprises the following steps:

[0006] After obtaining an account logout instruction of a first user account, unmounting a removable device if the removable device is mounted;

[0007] Executing the account logout instruction to log out the first user account;

[0008] After a second user account logs in, re-recognizing the removable device and mounting the removable device to the second user account.

[0009] On the other hand, the embodiments of the present application disclose a removable device access device applied to a computer device, wherein the computer device has a Linux operating system, and the device comprises the following modules:

[0010] An unmounting module, configured to unmount a removable device if the removable device is mounted after obtaining an account logout instruction of a first user account;

[0011] The logging-off module is configured to execute the account logging-off instruction to log off the first user account.

[0012] The mounting module is configured to re-identify the removable device after the second user account is logged in, and mount the removable device to the second user account.

[0013] In another aspect, the embodiments of the present application disclose an access device for a removable device, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, and the one or more programs contain instructions for performing the access method of the removable device as described in one or more of the preceding aspects.

[0014] In another aspect, the embodiments of the present application disclose a readable storage medium, which stores instructions, and when the instructions are executed by one or more processors of a device, the device performs the access method of the removable device as described in one or more of the preceding aspects.

[0015] The embodiments of the present application have the following advantages:

[0016] The computer device with the Linux operating system, after obtaining the account logging-off instruction of the first user account, in the case that the removable device is mounted, unmounts the removable device before logging off the first user account. Thus, after the second user account is logged in, the computer device can re-identify the removable device and mount the removable device to the second user account, so that the second user can access the removable device. In the technical solution, by unmounting the removable device before the first user account is logged off, the computer device can mount the unmounted removable device to the second user account after the second user account is logged in, so that the removable device can be accessed by the second user, the access permission of the removable device is changed along with the change of the logged-in user of the operating system, and the problem that the removable device such as a U disk cannot be accessed due to the change of the logged-in user is avoided. Moreover, in the process of changing the access permission of the removable device, the technical solution of the present application does not need to modify the file permission management mechanism of the Linux operating system, nor does it need to modify the device mounting mechanism of the Linux operating system, and the security of changing the access permission of the removable device is ensured. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0018] Figure 1 is a flowchart of a removable device access method provided by an embodiment of the present application;

[0019] Figure 2 is a flowchart of a mounting condition information acquisition method provided by an embodiment of the present application;

[0020] Figure 3 is a flowchart of another removable device access method provided by an embodiment of the present application;

[0021] Figure 4 is a removable device mounting architecture diagram provided by an embodiment of the present application;

[0022] Figure 5 is a flowchart of a removable device mounting method provided by an embodiment of the present application;

[0023] Figure 6 is a block diagram of a removable device access device provided by an embodiment of the present application;

[0024] Figure 7 is a structural schematic diagram of an electronic device provided by an embodiment of the present application;

[0025] Figure 8 is a structural schematic diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION

[0026] The technical solutions of the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally a class and do not limit the number of objects, for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. The term "multiple" in the embodiments of the present application means two or more, and other quantifiers are similar.

[0028] Please refer to Figure 1 , which shows a flowchart of a removable device access method provided by an embodiment of the present application. The access method can be applied to a computer device having a Linux operating system. The embodiments of the present application do not limit the type of Linux operating system, for example, the Linux operating system can include but is not limited to any one of Debian, Ubuntu, CentOS (Community Enterprise Operating System), UOS (UOS desktop operating system), Kylin operating system, and Fangde operating system. Optionally, the computer device can include but is not limited to any one of the following: a server, a smart phone, a voice recorder, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer, an on-board computer, a desktop computer, a set-top box, a smart TV, a wearable device, etc. As shown in Figure 1 , the removable device access method includes the following steps 101 to 103.

[0029] Step 101, after obtaining the account logout instruction of the first user account, unmounting the removable device in the case of mounting the removable device.

[0030] In this embodiment, the first user account is the login account used by the first user to log in to the Linux operating system. After receiving the account logout command from the first user account, the computer device can determine whether a removable device is mounted on it. Therefore, if a removable device is mounted, it can be unmounted. Optionally, the computer device can call the unmount interface in the file system interface within the operating system to execute an unmount command for the removable device, thereby unmounting it.

[0031] Without a removable device attached, the logout command is executed directly to log out the first user account. A removable device refers to an electronic device that can connect to and be disconnected from a computer device and removed from it. When a removable device is connected to a computer device, the computer device can access the data within the removable device and / or perform operations on it. Optionally, a removable device may include: optical discs, USB flash drives, external hard drives, etc.

[0032] Optionally, when a removable device is attached, the process of unloading the removable device may include: unloading the removable device if it is determined from the attachment information that the electronic device is a removable device.

[0033] The computer device can obtain the mounting information of its attached electronic devices and determine whether the attached electronic devices are removable devices based on the mounting information, thus determining whether the computer device has any removable devices mounted. If the mounting information determines that an electronic device is removable, the removable device can be unmounted. The mounting information reflects whether an electronic device is removable. Therefore, before executing step 101 (unmounting a removable device if it is mounted), the computer device can first perform the process of obtaining the mounting information. Figure 2 As shown, the method for accessing a removable device also includes the following steps:

[0034] Step 201: Obtain the list of mounted devices. The list of mounted devices records the instance identifiers of the mounted electronic devices. The instance identifier indicates the instance of the mount command that manages the mounted electronic devices.

[0035] Optionally, the instance identifier can be the name of the mount command instance (GMount instance), or a pointer to the mount command instance. This pointer indicates the memory address of the mount command instance. The mount command instance is used to manage mounted electronic devices or file systems. Specifically, the mount command instance can be used by computer devices to access mount information of the electronic devices it manages.

[0036] In an optional implementation, a volume manager (GVolumeMonitor) maintains a mounted device list of mounted electronic devices. The computer device identifies an electronic device inserted into the computer device, and generates a mount command instance for the electronic device after performing a mount operation for the electronic device. The volume manager can add an instance identifier of the mount command instance of the electronic device to the mounted device list after the mount operation corresponding to the electronic device is completed. The computer device can obtain the mounted device list by invoking the volume manager.

[0037] In the embodiments of the present application, after obtaining the mounted device list, the computer device can determine whether the mounted device list is empty, to determine whether the electronic device is currently mounted by the operating system. In the case that the mounted device list is empty, it indicates that the computer device does not mount the electronic device, and it is determined that the computer device does not mount the removable device. In the case that the mounted device list is not empty, it indicates that the computer device mounts the electronic device, and the computer device can further perform step 202 to obtain the mount status information of the mounted electronic device, so as to facilitate determining whether the removable device is mounted according to the mount status information.

[0038] In the case that the mounted device list is not empty, the mount status information of the electronic device corresponding to the mount command instance indicated by the instance identifier is obtained.

[0039] In the embodiments of the present application, in the case that the mounted device list includes multiple instance identifiers, the computer device can traverse the mounted device list, and sequentially obtain the multiple instance identifiers recorded in the mounted device list. The computer device can obtain the mount status information of the electronic device corresponding to each instance identifier through the mount command instance indicated by each instance identifier. Correspondingly, after obtaining the mount status information of each mounted electronic device, the computer device can determine whether the electronic device corresponding to each mount status information is a removable device according to each mount status information. Thus, in the case that it is determined that the electronic device corresponding to a mount status information is a removable device according to the mount status information, the removable device is unmounted, to unmount all removable devices determined according to the mount status information.

[0040] In an alternative implementation, a mounted removable device has four characteristics compared to other electronic devices. The four characteristics include: unmountable, ejectable, having a mounted drive instance (GDrive instance), and having a mounted volume instance (GVolume instance). The unmountable means that the mounted device can be unmounted from the operating system. The ejectable means that the mounted device can be unmounted from the operating system and disconnected from the computer device. After the removable device is mounted to the operating system, the removable device has a drive object and a volume object at the operating system level. The mounted drive instance represents the drive object. The drive object, also referred to as a removable media device driver, is used to query the mounting status of the removable device and eject the removable device. The mounted volume instance represents the volume object. The volume object, also referred to as a mounted object, is a visible object of the removable device on the computer device. A user can perform input operations on the volume object to perform access, unmount, eject, and other processes on the removable device.

[0041] Based on this, the mounting status information can include: unmounting status information, ejecting status information, mounted drive instance information, and mounted volume instance information. The unmounting status information is used to indicate whether the electronic device is unmountable. The ejecting status information is used to indicate whether the electronic device is ejectable. The mounted drive instance information is used to indicate whether there is a mounted drive instance corresponding to the electronic device. The mounted volume instance information is used to indicate whether there is a mounted volume instance corresponding to the electronic device.

[0042] The process in which the computer device obtains the mounting status information of the electronic device corresponding to the instance identifier indicated by the mounting command instance can include: the computer device respectively calls four interfaces of the mounting command instance to obtain the unmounting status information, the ejecting status information, the mounted drive instance information, and the mounted volume instance information of the electronic device corresponding to the mounting command instance. The four interfaces are respectively used to output the unmounting status information, the ejecting status information, the mounted drive instance information, and the mounted volume instance information.

[0043] Correspondingly, after the computer device obtains the mounting status information of the electronic device corresponding to the instance identifier, the computer device judges whether the mounting status information satisfies a target condition to determine whether the electronic device corresponding to the mounting status information is a removable device. The target condition is that the unmounting status information indicates that the electronic device is unmountable, the ejecting status information indicates that the electronic device is ejectable, the mounted drive instance information indicates that there is a mounted drive instance, and the mounted volume instance information indicates that there is a mounted volume instance.

[0044] In a case where the mounting status information satisfies the target condition, it is determined that the mounted electronic device corresponding to the mounting status information is a removable device, and the electronic device is unmounted. In a case where the mounting status information does not satisfy the target condition, the computer device can not perform any operation on the electronic device.

[0045] Exemplarily, the four interfaces include a first interface to a fourth interface.

[0046] The first interface is used to output unmounting condition information; for example, a g_mount_can_unmount() function interface. The unmounting condition information is a Boolean value, and when the unmounting condition information is a first value, it indicates that the electronic device can be unmounted. When the unmounting condition information is a second value, it indicates that the electronic device cannot be unmounted. For example, the first value is True, and the second value is False.

[0047] The second interface is used to output ejecting condition information; for example, a g_mount_can_eject() function interface. The ejecting condition information is a Boolean value, and when the ejecting condition information is a first value, it indicates that the electronic device can be ejected. When the ejecting condition information is a second value, it indicates that the electronic device cannot be ejected. For example, the first value is True, and the second value is False.

[0048] The third interface is used to output mounting drive instance information; for example, a g_mount_get_drive() function interface. When the content of the mounting drive instance information is null, it indicates that there is no mounting drive instance corresponding to the electronic device. When the content of the mounting drive instance information is not null, the content is a pointer of the mounting drive instance, which indicates that there is a mounting drive instance corresponding to the electronic device.

[0049] The fourth interface is used to output mounting volume instance information; for example, a g_mount_get_volume() function interface. When the content of the mounting volume instance information is null, it indicates that there is no mounting volume instance corresponding to the electronic device. When the content of the mounting volume instance information is not null, the content is a pointer of the mounting volume instance, which indicates that there is a mounting volume instance corresponding to the electronic device.

[0050] After the computer device obtains the mounting condition information of a mounted electronic device, it respectively judges whether the unmounting condition information in the mounting condition information is the first value, whether the ejecting condition information in the mounting condition information is the first value, whether the mounting drive instance information is not null, and whether the mounting volume instance information is not null. In the case that the mounting condition information satisfies the conditions that the unmounting condition information is the first value, the ejecting condition information is the first value, the mounting drive instance information is not null, and the mounting volume instance information is not null, it is determined that the mounted electronic device is a removable device, and the removable device is unmounted.

[0051] In some embodiments of the present application, the account logout instruction of the first user account can be an instruction generated by the computer device after receiving an account logout operation performed by the user. Alternatively, the account logout instruction can also be an instruction generated by the computer device triggered by other programs when the first user account needs to be logged out. For example, the account logout operation includes an operation of inputting an account logout command. After receiving the account logout command input by the user, the computer device unmounts the removable device if the removable device is mounted.

[0052] Step 102: executing the account logout instruction to log out the first user account.

[0053] In the embodiments of the present application, after the computer device unmounts the removable device, the computer device can execute the account logout instruction to log out the first user account.

[0054] Step 103: after the second user account is logged in, re-identifying the removable device and mounting the removable device to the second user account.

[0055] In the embodiments of the present application, the second user account is a login account of the Linux operating system logged in by the second user, and the second user account is different from the first user account. Since the computer device can identify the electronic device inserted into the computer device and mount the electronic device to the current login account of the operating system, for example, mount the identified electronic device to the directory of “ / media / current login account / directory”. Therefore, after the second user logs in the operating system by using the second user account, the computer device can re-identify the electronic device inserted into the computer device, which includes the aforementioned unmounted removable device. The computer device mounts the identified electronic device to the second user account, so that the second user can access the aforementioned unmounted removable device. It is not difficult to understand that after the computer device remounts the aforementioned unmounted removable device, the user of the aforementioned unmounted removable device is changed to the second user, and the access permission of the removable device is changed to allow the second user to access. For example, the second user account is b. The computer device mounts the aforementioned unmounted removable device to the directory of “ / media / b / directory”. In this way, the second user currently logged in the operating system can access the removable device.

[0056] In an alternative implementation manner, the computer device can also change the access permission only for the removable device of the first user. Alternatively, the process of unmounting the removable device by the computer device can include: obtaining the mounting path of the removable device. When the mounting path is in the directory of the first user account, the computer device unmounts the removable device.

[0057] In the method, the computer device can determine whether the mounting path is under the directory of the first user account after obtaining the mounting path of the removable device, to determine whether the removable device is the electronic device of the first user. When the mounting path is not under the directory of the first user account, it indicates that the removable device is not the electronic device of the first user. Then, the computer device can not perform the unmounting process on the removable device. When the mounting path is under the directory of the first user account, it indicates that the removable device is the electronic device of the first user. Then, the computer device can perform the unmounting process on the removable device, so as to remount the removable device after the user who logs in the operating system is changed, to enable the changed user to access the removable device, and realize that the access permission of the removable device is changed from allowing the first user to access to allowing the second user to access.

[0058] For example, it is assumed that the first user account is a. The process in which the computer device determines whether the mounting path is under the directory of the first user account can include that the computer device can determine whether the first eight characters of the mounting path are " / media / a". If yes, it indicates that the mounting path is under the directory of the first user account. If no, it indicates that the mounting path is not under the directory of the first user account.

[0059] In this way, the computer device can selectively change the access permission of the removable device of part of the users according to the mounting path of the removable device, and improve the flexibility of changing the access permission of the removable device.

[0060] It should be noted that in some embodiments of the present application, the computer device can obtain the mounted device list after obtaining the account logout instruction of the first user account, and obtain the mounting path of the mounted electronic device when the mounted device list is not empty. Then, the electronic device whose mounting path is under the directory of the first user account is determined as a candidate electronic device. After that, the mounting condition information of the candidate electronic device is obtained, and the target removable device in the candidate electronic device is determined according to the mounting condition information. The target removable device is unmounted. After the second user account logs in, the target removable device is re-identified, and the target removable device is mounted to the second user account, to realize the change of the access permission of only the removable device of the first user.

[0061] It should be further noted that the computer device can set the permission of the re-identified removable device to the default permission 755 when mounting the removable device to the second user account. The default permission 755 means that all users of the removable device, i.e., the second user, have the read, write and executable permissions of the removable device. The group to which the second user belongs and other users only have the read and executable permissions.

[0062] In the embodiment of the present application, the computer device with the Linux operating system, after obtaining the account logout instruction of the first user account, in the case that the removable device is mounted, unmounts the removable device before logging out the first user account. Thus, after the second user account is logged in, the computer device can re-identify the removable device and mount the removable device to the second user account, so that the second user can access the removable device. In the technical solution, by unmounting the removable device before the first user account is logged out, according to the principle that the computer device defaults to mount the identified removable device to the currently logged-in account of the operating system, after the second user account is logged in, the computer device can mount the unmounted removable device to the second user account, so that the removable device can be accessed by the second user, the access permission of the removable device is changed along with the change of the logged-in user of the operating system, and the problem that the removable device such as a U disk cannot be accessed due to the change of the logged-in user is avoided. Moreover, in the process of changing the access permission of the removable device, the technical solution of the present application does not need to modify the file permission management mechanism of the current Linux operating system or the device mounting mechanism of the Linux operating system, and the security of changing the access permission of the removable device is ensured.

[0063] The removable device access method provided by the embodiment of the present application is further illustratively described below by using an example. As shown in Figure 3 The removable device access method includes:

[0064] After obtaining the account logout instruction of the first user account, a volume manager instance is called to obtain a mounted device list. The volume manager instance represents a volume manager which maintains a mounted device list of mounted electronic devices. The mounted device list is traversed to determine whether the mounted device list is empty.

[0065] In the case that the mounted device list is empty, the execution of the removable device access method can be directly ended. In the case that the mounted device list is not empty, the computer device can obtain an instance identifier in the mounted device list and perform target processing according to the instance identifier. The target processing includes:

[0066] The GMount instance indicated by the instance identifier is called to obtain the unmounting information, the ejecting information, the mounting drive instance information and the mounting volume instance information of the electronic device corresponding to the instance identifier according to the GMount instance. Whether the electronic device can be unmounted is determined according to the unmounting information, whether the electronic device can be ejected is determined according to the ejecting information, whether the GDrive instance of the electronic device exists is determined according to the mounting drive instance information, and whether the GVolume instance of the electronic device exists is determined according to the mounting volume instance information.

[0067] In a case where it is determined according to the unmounting condition information, the ejecting condition information, the mounting drive instance information and the mounting volume instance information of the electronic device that the removable device is unmountable, ejectable, has a GDrive instance and has a GVolume instance, another instance identifier in the mounted device list is acquired, and the target processing is repeatedly executed according to the instance identifier until the target processing is repeatedly executed according to the last instance identifier.

[0068] In a case where it is determined according to the unmounting condition information, the ejecting condition information, the mounting drive instance information and the mounting volume instance information of the electronic device that the removable device is unmountable, ejectable, has a GDrive instance and has a GVolume instance, the mounting path of the electronic device is acquired. It is judged whether the mounting path is under the directory of the first user account. In a case where the mounting path is not under the directory of the first user account, the computer device can acquire another instance identifier in the mounted device list, and repeatedly execute the target processing according to the instance identifier until the target processing is repeatedly executed according to the last instance identifier.

[0069] In a case where the mounting path is under the directory of the first user account, the computer device can unmount the removable device, and acquire another instance identifier in the mounted device list, and repeatedly execute the target processing according to the instance identifier until the target processing is repeatedly executed according to the last instance identifier.

[0070] In the embodiment of the application, after the computer device unmounts the removable device and logs out the first user account, the computer device re-identifies the removable device and mounts the removable device to the second user account after the second user account is logged in. For example, taking the unmounted removable device as a U disk, the mounting process of the computer device re-identifying the removable device and mounting the removable device to the second user account is further illustratively described. As shown in Figure 4 and Figure 5 The mounting process includes:

[0071] After the second user account of the second user b is logged in the system, the USB controller in the kernel of the computer device can identify the inserted U disk, generate a hardware interrupt, and the USB controller identifies the hardware type of the U disk and the drive program corresponding to the hardware type in response to the hardware interrupt. The USB controller controls the U disk to be connected with the new block device created by the identified drive program, so that the components in the user space running on the Linux operating system can perform corresponding operations on the U disk through the new block device. The components include a device manager (udev), a disk manager (udisks2) and a file manager of a desktop component.

[0072] The USB controller sends an add signal to the device manager after connecting the U disk to the new block device. The device manager links the U disk to the / dev directory and sends an add event signal to the disk manager after receiving the add signal. The disk manager creates a UDisks interface drive object instance (UDisksLinuxDriveObject instance), a UDisks interface block device object instance (UDisksLinuxBlockObject), and a job task in sequence after receiving the add event signal.

[0073] The UDisks interface drive object instance represents a disk device, a storage device, and a disk drive, and saves disk-related hardware information. The hardware information includes manufacturer, product model, serial number, and the like. The UDisks interface drive object instance is used to enumerate disks and storage devices (including U disks) and provide related processing operations for the disks and storage devices. The related processing operations include querying, mounting, unmounting, or formatting, and the like. The D-Bus interface corresponding to the UDisks interface drive object instance is org.freedesktop.UDisks2.Drive. The UDisks interface drive object instance can be invoked through the interface. The UDisks interface block device object instance represents a block device connected to the U disk, and is used to save related information of the U disk. The related information includes a U disk access path, a U disk and block device link path, a device number, a capacity size, and the like. The D-Bus interface corresponding to the UDisks interface block device object instance is org.freedesktop.UDisks2.Block. The UDisks interface block device object instance can be invoked through the interface. The job task is used to provide a mount system command of the U disk, so that the mounting operation of the U disk is performed when the job task is running. The D-Bus interface corresponding to the job task is org.freedesktop.UDisks2.Job. The job task can be invoked through the interface.

[0074] The disk manager starts running the job task to execute the mount system command to mount the U disk under the second user account, i.e., to mount to the / media / second user account / directory. It should be noted that the disk manager generates a completed signal after the mounting is completed. The computer device displays the device identifier of the U disk on the interface corresponding to the file manager. The second user can double-click the device identifier, so that the computer device displays the identifier of the file stored in the U disk after receiving the double-click input on the device identifier, to access the file stored in the U disk.

[0075] In summary, the computer device with the Linux operating system, after obtaining the account logout instruction of the first user account, in the case that the removable device is mounted, unmounts the removable device before logging out the first user account. Thus, after the second user account is logged in, the computer device can re-identify the removable device and mount the removable device to the second user account, so that the second user can access the removable device. In the technical solution, by unmounting the removable device before the first user account is logged out, according to the principle that the computer device defaults to mount the identified removable device to the currently logged-in account of the operating system, after the second user account is logged in, the computer device can mount the unmounted removable device to the second user account, so that the removable device can be accessed by the second user, the access permission of the removable device is changed along with the change of the logged-in user of the operating system, and the problem that the removable device such as a U disk cannot be accessed due to the change of the logged-in user is avoided. Moreover, in the process of changing the access permission of the removable device, the technical solution of the present application does not need to modify the file permission management mechanism of the current Linux operating system or the device mounting mechanism of the Linux operating system, and the security of changing the access permission of the removable device is ensured.

[0076] Please refer to Figure 6 which shows a block diagram of a removable device access apparatus provided by an embodiment of the present application. The removable device access apparatus is applied to a computer device, and the computer device has a Linux operating system. As shown in Figure 6 The removable device access apparatus 600 includes an unmounting module 601, a logging out module 602, and a mounting module 603.

[0077] The unmounting module 601 is configured to, in the case that the removable device is mounted, unmount the removable device after obtaining the account logout instruction of the first user account.

[0078] The logging out module 602 is configured to execute the account logout instruction to log out the first user account.

[0079] The mounting module 603 is configured to re-identify the removable device and mount the removable device to the second user account after the second user account is logged in.

[0080] Optionally, the removable device access apparatus 600 further includes an obtaining module.

[0081] The obtaining module is configured to obtain a mounted device list, and the mounted device list is used to record the instance identifier of the mounted electronic device, and the instance identifier is used to indicate the mounting command instance of the mounted electronic device.

[0082] The obtaining module is further configured to, when the mounted device list is not empty, obtain mounting status information of the electronic device corresponding to the instance identifier through the mounting command instance indicated by the instance identifier, the mounting status information being used to reflect whether the electronic device is a removable device.

[0083] The uninstalling module is further configured to, when it is determined according to the mounting status information that the electronic device is a removable device, uninstall the removable device.

[0084] Optionally, the mounting status information includes: unmounting status information, ejecting status information, mounting drive instance information and mounting volume instance information; the unmounting status information is used to indicate whether the electronic device is unmountable, the ejecting status information is used to indicate whether the electronic device is ejectable, the mounting drive instance information is used to indicate whether there is a mounting drive instance corresponding to the electronic device, and the mounting volume instance information is used to indicate whether there is a mounting volume instance corresponding to the electronic device.

[0085] The uninstalling module is further configured to, when the mounting status information satisfies a target condition, determine that the electronic device is a removable device; the target condition is that the unmounting status information indicates that the electronic device is unmountable, the ejecting status information indicates that the electronic device is ejectable, the mounting drive instance information indicates that there is a mounting drive instance, and the mounting volume instance information indicates that there is a mounting volume instance.

[0086] Optionally, the uninstalling module is further configured to:

[0087] Obtain a mounting path of the removable device.

[0088] When the mounting path is under a directory of the first user account, uninstall the removable device.

[0089] Optionally, the obtaining module is further configured to: call a volume manager instance to obtain the mounted device list.

[0090] In summary, the computer device with the Linux operating system, after obtaining the account logout instruction of the first user account, in the case that the removable device is mounted, unmounts the removable device before logging out the first user account. Thus, after the second user account is logged in, the computer device can re-identify the removable device and mount the removable device to the second user account, so that the second user can access the removable device. In the technical solution, by unmounting the removable device before the first user account is logged out, according to the principle that the computer device mounts the identified removable device to the current logged-in account of the operating system, after the second user account is logged in, the computer device can mount the unmounted removable device to the second user account, so that the removable device can be accessed by the second user, the access permission of the removable device is changed along with the change of the logged-in user of the operating system, and the problem that the removable device such as a U disk cannot be accessed due to the change of the logged-in user is avoided. Moreover, in the process of changing the access permission of the removable device, the technical solution of the present application does not need to modify the file permission management mechanism of the current Linux operating system, nor does it need to modify the device mounting mechanism of the Linux operating system, and the security of changing the access permission of the removable device is ensured.

[0091] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts are described in the part of the method embodiment.

[0092] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same and similar parts of each embodiment can be referred to each other.

[0093] For the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment related to the method, and will not be described in detail here.

[0094] The embodiment of the present application provides an access device for a removable device, which includes a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, and the one or more programs include the access method of the removable device in one or more embodiments described above.

[0095] Figure 7 is a block diagram of an electronic device 800 for a removable device according to an exemplary embodiment. For example, the electronic device 800 can be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0096] Reference Figure 7The electronic device 800 can include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.

[0097] The processing component 802 usually controls overall operations of the electronic device 800, such as operations associated with displaying, making phone calls, data communications, camera operations and recording operations. The processing component 802 can include one or more processors 820 to execute instructions to complete all or part of steps of the methods described above. In addition, the processing component 802 can include one or more modules to facilitate

[0098] The memory 804 is configured to store various types of data to support operations of the electronic device 800. Examples of these data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and the like. The memory 804 can be implemented by any type of volatile or non-volatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic or optical disk.

[0099] The power supply component 806 provides power for the various components of the electronic device 800. The power supply component 806 can include a power supply management system, one or more power supplies, and other components associated with generating, managing and distributing power for the electronic device 800.

[0100] The multimedia component 808 includes a screen to provide an output interface between the electronic device 800 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding action, but also detect duration and pressure related to the touching or sliding action. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0101] The audio component 810 is configured to output and / or input an audio signal. For example, the audio component 810 includes a microphone (MIC) to receive an external audio signal when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker to output an audio signal.

[0102] The I / O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which can be a keypad, a click wheel, buttons, and the like. The buttons can include, but are not limited to, a home button, a volume button, a start button, and a lock button.

[0103] The sensor component 814 includes one or more sensors to provide various state assessments for the electronic device 800. For example, the sensor component 814 can detect an open / closed state of the electronic device 800, relative positioning of components, such as a display and a keypad of the electronic device 800, search for a change in position of the electronic device 800 or a component of the electronic device 800, detect the presence or absence of user contact with the electronic device 800, detect a change in orientation or acceleration / deceleration of the electronic device 800, and detect a temperature change of the electronic device 800. The sensor component 814 can include a proximity sensor configured to detect presence of a nearby object without any physical touch. The sensor component 814 can further include a light sensor such as a CMOS or CCD image sensor for use in an imaging application. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0104] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0105] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic elements, for performing the above-described methods.

[0106] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as a memory including instructions, is also provided, which can be executed by a processor of the electronic device 800 to complete the above-described methods. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.

[0107] Figure 8 is a structural diagram of a server in some embodiments of the present application. The server 1900 can have a large difference due to different configurations or performances, and can include one or more central processing units (CPUs) 1922 (e.g., one or more processors) and a memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) storing application programs 1942 or data 1944. Among them, the memory 1932 and the storage medium 1930 can be temporary storage or persistent storage. The programs stored in the storage medium 1930 can include one or more modules (not shown in the figure), each of which can include a series of instruction operations in the server. Further, the central processing unit 1922 can be configured to communicate with the storage medium 1930 and execute a series of instruction operations in the storage medium 1930 on the server 1900.

[0108] The server 1900 can also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input / output interfaces 1958, one or more keyboards 1956, and / or one or more operating systems 1941, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0109] A non-transitory computer readable storage medium, when instructions in the storage medium are executed by a processor of an apparatus (a server or a terminal), enable the apparatus to perform Figure 1 The access method of the removable device shown.

[0110] A non-transitory computer readable storage medium, when instructions in the storage medium are executed by a processor of an apparatus (a server or a terminal), enable the apparatus to perform the foregoing Figure 1 The foregoing description of the access method of the removable device in the corresponding embodiment, therefore, will not be repeated here. In addition, the description of the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer program product or computer program embodiments involved in the present application, please refer to the description of the method embodiments of the present application.

[0111] In addition, it should be noted that: the present application also provides a computer program product or computer program, the computer program product or computer program can include computer instructions, the computer instructions can be stored in a computer readable storage medium. The processor of the computer equipment reads the computer instructions from the computer readable storage medium, and the processor can execute the computer instructions, so that the computer equipment executes the foregoing Figure 1 The foregoing description of the access method of the removable device in the corresponding embodiment, therefore, will not be repeated here. In addition, the description of the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer program product or computer program embodiments involved in the present application, please refer to the description of the method embodiments of the present application.

[0112] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the application embrace any and all variations of the application that fall within the scope of the general description herein. It is intended that the application include the general principles established by the teachings herein and the examples provided herein. This application is to be limited only by the terms of the claims that follow.

[0113] It is to be understood that the application is not limited to the precise construction herein described and illustrated and that various modifications and changes can be made therein without departing from the scope thereof. The only scope of the application is defined by the appended claims.

[0114] The above description is only the preferred embodiment of the present application, and is not intended to limit the present application, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

[0115] The above provides a detailed description of the access method of the removable device, the access device of the removable device and the readable storage medium, the principles and implementation modes of the present application are described by applying specific examples, the above embodiment is only used to help understand the method and core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description should not be understood as the limitation of the present application.

Claims

1. A method of accessing a removable device, characterized by, The method is applied to a computer device having a Linux operating system, and the method comprises the following steps: After obtaining an account logout instruction of a first user account, a mounted device list is obtained, the mounted device list being used to record instance identifiers of mounted electronic devices, the instance identifiers being used to indicate mounting command instances for managing the mounted electronic devices; in a case where the mounted device list is not empty, mounting condition information of an electronic device corresponding to an instance identifier is obtained through a mounting command instance indicated by the instance identifier, the mounting condition information being used to reflect whether the electronic device is a removable device; In a case where it is determined according to the mounting condition information that the electronic device is a removable device, the removable device is unmounted; The account logout instruction is executed to log out the first user account; After a second user account is logged in, the removable device is re-identified, and the removable device is mounted to the second user account.

2. The method of claim 1, wherein, The mounting condition information comprises unmounting condition information, ejecting condition information, mounting drive instance information and mounting volume instance information; the unmounting condition information is used to indicate whether the electronic device can be unmounted, the ejecting condition information is used to indicate whether the electronic device can be ejected, the mounting drive instance information is used to indicate whether there is a mounting drive instance corresponding to the electronic device, and the mounting volume instance information is used to indicate whether there is a mounting volume instance corresponding to the electronic device; The determination that the electronic device is a removable device according to the mounting condition information comprises: In a case where the mounting condition information meets a target condition, it is determined that the electronic device is a removable device; the target condition is that the unmounting condition information indicates that the electronic device can be unmounted, the ejecting condition information indicates that the electronic device can be ejected, the mounting drive instance information indicates that there is the mounting drive instance, and the mounting volume instance information indicates that there is the mounting volume instance.

3. The method according to any one of claims 1 to 2, characterized in that, The unmounting of the removable device comprises: A mounting path of the removable device is obtained; In a case where the mounting path is under a directory of the first user account, the removable device is unmounted.

4. The method of claim 1, wherein, The obtaining of the mounted device list comprises: A volume manager instance is called to obtain the mounted device list.

5. An access device for a removable device, the access device comprising: The device is applied to a computer device having a Linux operating system, and the device comprises the following steps: An obtaining module is configured to obtain a mounted device list, the mounted device list being used to record instance identifiers of mounted electronic devices, the instance identifiers being used to indicate mounting command instances for managing the mounted electronic devices; The obtaining module is further configured to, in a case where the mounted device list is not empty, obtain mounting condition information of an electronic device corresponding to an instance identifier through a mounting command instance indicated by the instance identifier, the mounting condition information being used to reflect whether the electronic device is a removable device; An unmounting module is configured to, in a case where an account logout instruction of a first user account is obtained, in a case where it is determined according to the mounting condition information that the electronic device is a removable device, unmount the removable device. A logout module, configured to execute the account logout instruction to log out the first user account; A mounting module, configured to re-identify the removable device after the second user account is logged in, and mount the removable device to the second user account.

6. The apparatus of claim 5, wherein, The mounting condition information comprises: unmounting condition information, ejecting condition information, mounting drive instance information and mounting volume instance information; the unmounting condition information is used to indicate whether the electronic device is unmountable, the ejecting condition information is used to indicate whether the electronic device is ejectable, the mounting drive instance information is used to indicate whether there is a mounting drive instance corresponding to the electronic device, and the mounting volume instance information is used to indicate whether there is a mounting volume instance corresponding to the electronic device; The unmounting module is further configured to determine that the electronic device is a removable device when the mounting condition information meets a target condition; the target condition is that the unmounting condition information indicates that the electronic device is unmountable, the ejecting condition information indicates that the electronic device is ejectable, the mounting drive instance information indicates that there is the mounting drive instance, and the mounting volume instance information indicates that there is the mounting volume instance.

7. An access device for a removable device, the access device comprising: A memory, and one or more programs stored in the memory and configured to be executed by one or more processors, the one or more programs including instructions for performing the removable device access method of any one of claims 1-4.

8. A readable storage medium having instructions stored thereon, which, when executed by one or more processors of an apparatus, cause the apparatus to perform the removable device access method of any one of claims 1-4.

Citation Information

Patent Citations

  • Mounting method and device of external storage device, equipment and medium

    CN113835857A

  • Peripheral equipment processing method based on cloud desktop, electronic equipment and storage medium

    CN115484258A