The USB device is mounted multiple times.

Source: Internet
Author: User

After the system is started, it is found that the same USB device has been attached multiple times, causing problems in the File Manager applications. The process of attaching a USB device is in Android/system/vold/volume. cpp and is handled by the volume: mountudiskvol function. You can solve this problem by checking whether the device has been mounted before mounting:

 
Bool isusbdevicemounted (const char * path) {char device [256]; char mount_path [256]; char rest [256]; file * FP; char line [1024]; If (! (FP = fopen ("/proc/mounts", "R") {sloge ("error opening/proc/mounts (% s)", strerror (errno )); return false;} while (fgets (line, sizeof (line), FP) {line [strlen (line)-1] = '\ 0'; sscanf (line, "% 255 S % 255 S % 255s \ n", device, mount_path, rest); If (! Strcmp (device, PATH) {fclose (FP); Return true ;}} fclose (FP); Return false ;}

Int volume: mountudiskvol () {... For (IT = mudiskpartition-> begin (); it! = Mudiskpartition-> end (); It ++) {imajor = (* It)-> imajor; iminor = (* It)-> iminor; sprintf (devicepath, "/dev/block/vold/% d: % d", imajor, iminor); If (isusbdevicemounted (devicepath) continue ;...}...}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.