* mounted and where
*/
int
-virCgroupDetectMountsFromFile(virCgroupPtr group,
- const char *path,
- bool checkLinks)
+virCgroupDetectMounts(virCgroupPtr group)
{
size_t i;
FILE *mounts = NULL;
char buf[CGROUP_MAX_VAL];
int ret = -1;
- mounts = fopen(path, "r");
+ mounts = fopen("/proc/mounts", "r");
if (mounts == NULL) {
- virReportSystemError(errno, _("Unable to open %s"), path);
+ virReportSystemError(errno, "%s", _("Unable to open /proc/mounts"));
return -1;
}
/* If it is a co-mount it has a filename like "cpu,cpuacct"
* and we must identify the symlink path */
- if (checkLinks &&
- virCgroupResolveMountLink(entry.mnt_dir, typestr,
+ if (virCgroupResolveMountLink(entry.mnt_dir, typestr,
controller) < 0) {
goto cleanup;
}
return ret;
}
-static int
-virCgroupDetectMounts(virCgroupPtr group)
-{
- return virCgroupDetectMountsFromFile(group, "/proc/mounts", true);
-}
-
static int
virCgroupCopyPlacement(virCgroupPtr group,
int
-virCgroupDetectMountsFromFile(virCgroupPtr group ATTRIBUTE_UNUSED,
- const char *path ATTRIBUTE_UNUSED,
- bool checkLinks ATTRIBUTE_UNUSED)
+virCgroupDetectMounts(virCgroupPtr group ATTRIBUTE_UNUSED)
{
virReportSystemError(ENXIO, "%s",
_("Control groups not supported on this platform"));
virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
};
-int virCgroupDetectMountsFromFile(virCgroupPtr group,
- const char *path,
- bool checkLinks);
+int virCgroupDetectMounts(virCgroupPtr group);
int virCgroupNewPartition(const char *path,
bool create,
{
int result = -1;
const char *file = args;
- char *mounts = NULL;
char *parsed = NULL;
const char *actual;
virCgroupPtr group = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
size_t i;
- if (virAsprintf(&mounts, "%s/vircgroupdata/%s.mounts",
- abs_srcdir, file) < 0 ||
- virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed",
- abs_srcdir, file) < 0 ||
- VIR_ALLOC(group) < 0)
+ setenv("VIR_CGROUP_MOCK_FILENAME", file, 1);
+
+ if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir, file) < 0)
+ goto cleanup;
+
+ if (VIR_ALLOC(group) < 0)
goto cleanup;
- if (virCgroupDetectMountsFromFile(group, mounts, false) < 0)
+ if (virCgroupDetectMounts(group) < 0)
goto cleanup;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
result = 0;
cleanup:
- VIR_FREE(mounts);
+ unsetenv("VIR_CGROUP_MOCK_FILENAME");
VIR_FREE(parsed);
virCgroupFree(&group);
virBufferFreeAndReset(&buf);