+ while (1) {
+ struct stat st;
+
+ errno = 0;
+ ent = readdir(dir);
+ if (ent == NULL) {
+ if (errno != 0)
+ perror("readdir");
+ break;
+ }
+
+ if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
+ continue;
+
+ snprintf(fname, sizeof(fname), "%s/%s", Config.BiosDir, ent->d_name);
+ if (stat(fname, &st) != 0 || st.st_size != 512*1024) {
+ printf("bad BIOS file: %s\n", ent->d_name);
+ continue;
+ }
+
+ if (bios_i < ARRAY_SIZE(bioses) - 1) {
+ bioses[bios_i++] = strdup(ent->d_name);
+ continue;
+ }
+
+ printf("too many BIOSes, dropping \"%s\"\n", ent->d_name);
+ }
+
+ closedir(dir);
+
+do_plugins: