static int openvzAssignUUIDs(void) { DIR *dp; struct dirent *dent; char *conf_dir; int vpsid; char *ext; int ret = 0; conf_dir = openvzLocateConfDir(); if (conf_dir == NULL) return -1; dp = opendir(conf_dir); if (dp == NULL) { VIR_FREE(conf_dir); return 0; } while ((ret = virDirRead(dp, &dent, conf_dir)) > 0) { if (virStrToLong_i(dent->d_name, &ext, 10, &vpsid) < 0 || *ext++ != '.' || STRNEQ(ext, "conf")) continue; if (vpsid > 0) /* '0.conf' belongs to the host, ignore it */ openvzSetUUID(vpsid); } closedir(dp); VIR_FREE(conf_dir); return ret; }
static int openvzAssignUUIDs(void) { DIR *dp; struct dirent *dent; char *conf_dir; int vpsid; char *ext; int ret = 0; conf_dir = openvzLocateConfDir(); if (conf_dir == NULL) return -1; dp = opendir(conf_dir); if (dp == NULL) { VIR_FREE(conf_dir); return 0; } errno = 0; while ((dent = readdir(dp))) { if (virStrToLong_i(dent->d_name, &ext, 10, &vpsid) < 0 || *ext++ != '.' || STRNEQ(ext, "conf")) continue; if (vpsid > 0) /* '0.conf' belongs to the host, ignore it */ openvzSetUUID(vpsid); errno = 0; } if (errno) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to scan configuration directory")); ret = -1; } closedir(dp); VIR_FREE(conf_dir); return ret; }