const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
- void *data)
+ void *data, const char *prefix)
{
int fd = -1, err, ret = -1;
FILE *list = NULL;
}
while (fgets(line, sizeof(line), list) != NULL) {
+ char *p = NULL;
/* Strip trailing newline */
int len = strlen(line);
if (len && line[len-1] == '\n')
line[len-1] = '\0';
+ /* ignore any command prefix */
+ if (prefix)
+ p = STRSKIP(line, prefix);
+ if (!p)
+ p = line;
+
for (i = 0 ; i <= maxReg && i < nregex ; i++) {
- if (regexec(®[i], line, nvars[i]+1, vars, 0) == 0) {
+ if (regexec(®[i], p, nvars[i]+1, vars, 0) == 0) {
maxReg++;
if (i == 0)
/* NULL terminate each captured group in the line */
for (j = 0 ; j < nvars[i] ; j++) {
/* NB vars[0] is the full pattern, so we offset j by 1 */
- line[vars[j+1].rm_eo] = '\0';
+ p[vars[j+1].rm_eo] = '\0';
if ((groups[ngroup++] =
- strdup(line + vars[j+1].rm_so)) == NULL) {
+ strdup(p + vars[j+1].rm_so)) == NULL) {
virReportOOMError();
goto cleanup;
}
const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
- void *data);
+ void *data, const char *cmd_to_ignore);
int virStorageBackendRunProgNul(virStoragePoolObjPtr pool,
const char **prog,
if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars,
virStorageBackendFileSystemNetFindPoolSourcesFunc,
- &state) < 0)
+ &state, NULL) < 0)
goto cleanup;
retval = virStoragePoolSourceListFormat(&state.list);
regexes,
vars,
virStorageBackendLogicalMakeVol,
- vol) < 0) {
+ vol, "lvs") < 0) {
return -1;
}
if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars,
virStorageBackendLogicalFindPoolSourcesFunc,
- &sourceList) < 0)
+ &sourceList, "pvs") < 0)
return NULL;
retval = virStoragePoolSourceListFormat(&sourceList);
regexes,
vars,
virStorageBackendLogicalRefreshPoolFunc,
- NULL) < 0) {
+ NULL, "vgs") < 0) {
virStoragePoolObjClearVols(pool);
return -1;
}