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 ;...}...}