VirtualBox

Changeset 43840 in vbox for trunk


Ignore:
Timestamp:
Nov 8, 2012 1:33:23 PM (12 years ago)
Author:
vboxsync
Message:

Main/Metrics: Fix volume name extraction in Linux (#6345)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp

    r43831 r43840  
    6060    virtual int _getRawHostCpuLoad();
    6161    int getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed);
     62    char *getDiskName(char *pszDiskName, size_t cbDiskName, const char *pszDevName, bool fTrimDigits);
     63    void addVolumeDependencies(const char *pcszVolume, DiskList& listDisks);
    6264
    6365    struct VMProcessStats
     
    354356}
    355357
    356 static char *getDiskName(char *pszDiskName, size_t cbDiskName, const char *pszDevName)
     358char *CollectorLinux::getDiskName(char *pszDiskName, size_t cbDiskName, const char *pszDevName, bool fTrimDigits)
    357359{
    358360    unsigned cbName = 0;
    359361    unsigned cbDevName = strlen(pszDevName);
    360362    const char *pszEnd = pszDevName + cbDevName - 1;
    361     while (pszEnd > pszDevName && RT_C_IS_DIGIT(*pszEnd))
    362         pszEnd--;
     363    if (fTrimDigits)
     364        while (pszEnd > pszDevName && RT_C_IS_DIGIT(*pszEnd))
     365            pszEnd--;
    363366    while (pszEnd > pszDevName && *pszEnd != '/')
    364367    {
     
    370373}
    371374
    372 static void addVolumeDependencies(const char *pcszVolume, DiskList& listDisks)
     375void CollectorLinux::addVolumeDependencies(const char *pcszVolume, DiskList& listDisks)
    373376{
    374377    char szVolInfo[RTPATH_MAX];
     
    407410            {
    408411                char szDevName[128];
    409                 getDiskName(szDevName, sizeof(szDevName), mntent->mnt_fsname);
    410412                if (strncmp(mntent->mnt_fsname, "/dev/mapper", 11))
     413                {
     414                    getDiskName(szDevName, sizeof(szDevName), mntent->mnt_fsname, true);
    411415                    listDisks.push_back(RTCString(szDevName));
     416                }
    412417                else
     418                {
     419                    getDiskName(szDevName, sizeof(szDevName), mntent->mnt_fsname, false);
    413420                    addVolumeDependencies(szDevName, listDisks);
     421                }
    414422                break;
    415423            }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette