[c-host] linux: implemented getValues support for shmDevice option

This commit is contained in:
Geoffrey McRae 2019-05-12 16:14:25 +10:00
parent e22f33a44b
commit b662128708
2 changed files with 8 additions and 6 deletions

View File

@ -1 +1 @@
a12-184-g5d69d2aba9+1 a12-185-ge22f33a44b+1

View File

@ -141,12 +141,13 @@ static bool shmDeviceValidator(struct Option * opt, const char ** error)
return true; return true;
} }
static void shmDevicePrintHelp() static StringList shmDeviceGetValues(struct Option * option)
{ {
printf("Valid devices are:\n\n"); StringList sl = stringlist_new(true);
DIR * d = opendir("/sys/class/uio"); DIR * d = opendir("/sys/class/uio");
if (!d) if (!d)
return; return sl;
struct dirent * dir; struct dirent * dir;
while((dir = readdir(d)) != NULL) while((dir = readdir(d)) != NULL)
@ -159,12 +160,13 @@ static void shmDevicePrintHelp()
continue; continue;
if (strcmp(name, "KVMFR") == 0) if (strcmp(name, "KVMFR") == 0)
printf(" * %s\n", dir->d_name); stringlist_push(sl, strdup(dir->d_name));
free(name); free(name);
} }
closedir(d); closedir(d);
return sl;
} }
int main(int argc, char * argv[]) int main(int argc, char * argv[])
@ -180,7 +182,7 @@ int main(int argc, char * argv[])
.type = OPTION_TYPE_STRING, .type = OPTION_TYPE_STRING,
.value.x_string = "uio0", .value.x_string = "uio0",
.validator = shmDeviceValidator, .validator = shmDeviceValidator,
.printHelp = shmDevicePrintHelp .getValues = shmDeviceGetValues
}, },
{0} {0}
}; };