VirtualBox

Ignore:
Timestamp:
Oct 24, 2012 8:32:14 AM (12 years ago)
Author:
vboxsync
Message:

Main/Metrics: devmapper support in Linux (#6345)

File:
1 edited

Legend:

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

    r43629 r43715  
    2828#include <iprt/err.h>
    2929#include <iprt/param.h>
     30#include <iprt/path.h>
    3031#include <iprt/string.h>
    3132#include <iprt/mp.h>
     
    3637#include "Logging.h"
    3738#include "Performance.h"
     39
     40#define VBOXVOLINFO_NAME "VBoxVolInfo"
    3841
    3942namespace pm {
     
    365368}
    366369
     370static void addVolumeDependencies(const char *pcszVolume, DiskList& listDisks)
     371{
     372    char szVolInfo[RTPATH_MAX];
     373    int rc = RTPathExecDir(szVolInfo, sizeof(szVolInfo) - sizeof("/" VBOXVOLINFO_NAME " ") - strlen(pcszVolume));
     374    if (RT_FAILURE(rc))
     375    {
     376        LogRel(("VolInfo: Failed to get program path, rc=%Rrc\n", rc));
     377        return VERR_INVALID_PARAMETER;
     378    }
     379    strcat(szVolInfo, "/" VBOXVOLINFO_NAME " ");
     380    strcat(szVolInfo, pcszVolume);
     381
     382    FILE *fp = popen(szVolInfo, "r");
     383    if (fp)
     384    {
     385        char szBuf[128];
     386
     387        while (fgets(szBuf, sizeof(szBuf), fp))
     388            listDisks.push_back(RTCString(szBuf));
     389
     390        pclose(fp);
     391    }
     392    else
     393        listDisks.push_back(RTCString(pcszVolume));
     394}
    367395
    368396int getDiskListByFs(const char *pszPath, DiskList& listDisks)
     
    376404            if (strcmp(pszPath, mntent->mnt_dir) == 0)
    377405            {
    378                 char szDevName[32];
    379                 listDisks.push_back(RTCString(getDiskName(szDevName, sizeof(szDevName), mntent->mnt_fsname)));
     406                char szDevName[128];
     407                getDiskName(szDevName, sizeof(szDevName), mntent->mnt_fsname);
     408                if (strncmp(mntent->mnt_fsname, "/dev/mapper", 11))
     409                    listDisks.push_back(RTCString(szDevName));
     410                else
     411                    addVolumeDependencies(szDevName, listDisks);
    380412                break;
    381413            }
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