Permalink
Browse files

[DROID] Only add one mount point per device

I've observed some prettys strange behavior on AML devices regarding
reading /proc/mounts.  Somehow there are multiple, unique mount points
for some devices when reading /proc/mounts with fopen/fgets.  However
they don't exist if "cat /proc/mounts" is issued from the shell.
Baffling...
  • Loading branch information...
1 parent de12a4c commit 88e0fc27b2473853d9c7d7f68ee5cd18ce4d0397 @t-nelson t-nelson committed Feb 19, 2014
Showing with 8 additions and 8 deletions.
  1. +8 −8 xbmc/storage/android/AndroidStorageProvider.cpp
View
16 xbmc/storage/android/AndroidStorageProvider.cpp
@@ -30,6 +30,7 @@
#include <cstdio>
#include <cstring>
#include <cstdlib>
+#include <map>
CAndroidStorageProvider::CAndroidStorageProvider()
{
@@ -98,10 +99,10 @@ void CAndroidStorageProvider::GetLocalDrives(VECSOURCES &localDrives)
void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
{
// mounted usb disks
- char* buf = NULL;
- FILE* pipe;
- std::vector<CStdString> result;
- CRegExp reMount;
+ char* buf = NULL;
+ FILE* pipe;
+ std::map<std::string, std::string> result;
+ CRegExp reMount;
reMount.RegComp("^(.+?)\\s+(.+?)\\s+(.+?)\\s");
/* /proc/mounts is only guaranteed atomic for the current read
@@ -158,7 +159,6 @@ void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
std::string device = reMount.GetReplaceString("\\1");
std::string mountStr = reMount.GetReplaceString("\\2");
std::string fsStr = reMount.GetReplaceString("\\3");
- const char* mount = mountStr.c_str();
const char* fs = fsStr.c_str();
// Here we choose which filesystems are approved
@@ -176,17 +176,17 @@ void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
accepted = false;
if(accepted)
- result.push_back(mount);
+ result[device] = mountStr;
}
line = strtok_r(NULL, "\n", &saveptr);
}
free(buf);
}
- for (unsigned int i = 0; i < result.size(); i++)
+ for (std::map<std::string, std::string>::const_iterator i = result.begin(); i != result.end(); ++i)
{
CMediaSource share;
- share.strPath = unescape(result[i]);
+ share.strPath = unescape(i->second);
share.strName = URIUtils::GetFileName(share.strPath);
share.m_ignore = true;
removableDrives.push_back(share);

0 comments on commit 88e0fc2

Please sign in to comment.