|
@@ -2,6 +2,7 @@
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <string>
|
|
|
+#include <regex>
|
|
|
#include <vector>
|
|
|
#include <map>
|
|
|
#include <ext/stdio_filebuf.h>
|
|
@@ -40,6 +41,7 @@
|
|
|
#define _INTERNAL_EMMC_DISK "mmcblk1"
|
|
|
#define _INTERNAL_EMMC_PART1 "mmcblk1p1"
|
|
|
#define _INTERNAL_EMMC_PART2 "mmcblk1p2"
|
|
|
+#define _CMD_LINE_PATH "/proc/cmdline"
|
|
|
|
|
|
#define _POLL_INTERVAL_MS 500
|
|
|
|
|
@@ -296,7 +298,7 @@ static bool _LookupMountPoint(MountMap &mm, const char *pszNode, char *pszMntPoi
|
|
|
|
|
|
static bool _UpdatePartitionFsInfo(MountMap &mm, GFA_SYSINFO_PARTITION &part)
|
|
|
{
|
|
|
- if(_LookupMountPoint(mm, part.szDevNode, part.szMntPoint, sizeof(part.szMntPoint)))
|
|
|
+ if(_LookupMountPoint(mm, part.szDevNode, part.szMntPoint, sizeof(part.szMntPoint)) || !strcmp(part.szMntPoint, "/"))
|
|
|
{
|
|
|
struct statvfs stvs;
|
|
|
|
|
@@ -449,6 +451,42 @@ static bool _IsInternalEmmc(const char *pszDevNode)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+static const char* _FileToStdString(const char *pszFilepath, std::string &str)
|
|
|
+{
|
|
|
+ std::ifstream ifs(pszFilepath);
|
|
|
+ str.clear();
|
|
|
+
|
|
|
+ if(ifs.good())
|
|
|
+ {
|
|
|
+ str.assign((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
|
|
+ return str.c_str();
|
|
|
+ }
|
|
|
+
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+static std::string _GetRootDevice(void)
|
|
|
+{
|
|
|
+ std::string sbd, sCmdLine;
|
|
|
+
|
|
|
+ if(_FileToStdString(_CMD_LINE_PATH, sCmdLine))
|
|
|
+ {
|
|
|
+ std::regex rg("\\broot=\\s*(.+mmcblk[0-9]p[0-9])\\b");
|
|
|
+ std::smatch m;
|
|
|
+
|
|
|
+ if( std::regex_search(sCmdLine, m, rg) &&
|
|
|
+ m.size() >= 2)
|
|
|
+ {
|
|
|
+ sbd = m[1];
|
|
|
+// if(!sbd.compare(_INTERNAL_EMMC_PART2) || sbd.compare(_INTERNAL_EMMC_PART1))
|
|
|
+// return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// sbd.clear();
|
|
|
+ return sbd;
|
|
|
+}
|
|
|
+
|
|
|
static long long _NumberFromString(const char *pszString, int base, bool *pbErr)
|
|
|
{
|
|
|
if(!pszString || !*pszString)
|
|
@@ -524,9 +562,8 @@ static void _ProcessPartition(GFA_SYSINFO_STORAGE_DEVICE_MAP &sdm, MountMap &mm,
|
|
|
|
|
|
if(!pszDevNode)
|
|
|
return;
|
|
|
-// if(_IsInternalEmmc(pszDevNode))
|
|
|
-// return; // skip internal emmc
|
|
|
bool bInternalEmmc = _IsInternalEmmc(pszDevNode);
|
|
|
+ bool bIsRootDevice = CStgDevInfo::IsRootDevice(pszDevNode);
|
|
|
strncpy(part.szDevNode, pszDevNode, sizeof(part.szDevNode) - 1);
|
|
|
|
|
|
const char *pszAction = ::udev_device_get_action(dev);
|
|
@@ -544,6 +581,8 @@ static void _ProcessPartition(GFA_SYSINFO_STORAGE_DEVICE_MAP &sdm, MountMap &mm,
|
|
|
_ReadDevPropertyValue(dev, "ID_FS_TYPE", part.szFsType, sizeof(part.szFsType), true);
|
|
|
_ReadDevPropertyValue(dev, "ID_FS_VERSION", part.szFsVersion, sizeof(part.szFsVersion), true);
|
|
|
part.nKiBPartSize = _ReadDevPropertyValue(dev, "ID_PART_ENTRY_SIZE") / 2;
|
|
|
+ if(bIsRootDevice)
|
|
|
+ part.szMntPoint[0] = '/';
|
|
|
_UpdatePartitionFsInfo(mm, part);
|
|
|
|
|
|
struct udev_device* cur = dev;
|
|
@@ -637,9 +676,13 @@ static void _EnumStorageDevices(GFA_SYSINFO_STORAGE_DEVICE_MAP &sdm, MountMap &m
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
+std::string CStgDevInfo::m_strRootDev;
|
|
|
+
|
|
|
CStgDevInfo::CStgDevInfo(void) : m_bPaused(false), m_bStateTransition(false)
|
|
|
{
|
|
|
m_bOsIsHypervised = ::GfAIpcSystemIsHypervised();
|
|
|
+ if(m_strRootDev.empty())
|
|
|
+ m_strRootDev = _GetRootDevice();
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -651,6 +694,15 @@ bool CStgDevInfo::IsSystemHypervised(void) const
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
+bool CStgDevInfo::IsRootDevice(const char *pszDevice)
|
|
|
+{
|
|
|
+ if(pszDevice && *pszDevice)
|
|
|
+ return !m_strRootDev.compare(pszDevice);
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+/////////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
void* CStgDevInfo::ThreadRoutine(void *pParam)
|
|
|
{
|
|
|
LPEXEC_PARAMS pep = (LPEXEC_PARAMS)pParam;
|