summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2020-06-12 18:03:11 +0000
committerPascal Terjan <pterjan@mageia.org>2020-06-12 18:03:11 +0000
commit353c8adc2ecd4e3fdfe2941d51d8f8f620f073ff (patch)
treec5301b6dc0f6b7dcd30ae6292c0f02728ba5dc60 /mdk-stage1
parenta1c3d8f29fc3cf1b03d8e07d58c6ed902355775f (diff)
downloaddrakx-353c8adc2ecd4e3fdfe2941d51d8f8f620f073ff.tar
drakx-353c8adc2ecd4e3fdfe2941d51d8f8f620f073ff.tar.gz
drakx-353c8adc2ecd4e3fdfe2941d51d8f8f620f073ff.tar.bz2
drakx-353c8adc2ecd4e3fdfe2941d51d8f8f620f073ff.tar.xz
drakx-353c8adc2ecd4e3fdfe2941d51d8f8f620f073ff.zip
Move VirtIO to generic code
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/probing.c60
1 files changed, 24 insertions, 36 deletions
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index d97ecce69..c23ab517b 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -870,47 +870,13 @@ void find_media(enum media_bus bus)
}
}
/* ----------------------------------------------- */
- log_message("looking for VirtIO");
- {
- int fd, i;
- char b[50];
- char *name = b+11;
- strcpy(b, "/sys/block/vd");
- for (b[13] = 'a'; b[13] <= 'c'; b[13]++) {
- /* first, test if file exists (will tell if attached medium exists) */
- b[14] = '\0';
- if (access(b, R_OK))
- continue;
-
- tmp[count].name = strdup(name);
- tmp[count].type = DISK; //UNKNOWN_MEDIA;
- tmp[count].model = strdup("VirtIO disk");
-
- /* media type */
- strcpy(b + 14, "/capability");
- fd = open(b, O_RDONLY);
- if (fd == -1) {
- log_message("failed to open %s for reading", b);
- //continue;
- }
- i = read(fd, buf, sizeof(buf));
- if (i == -1) {
- log_message("Couldn't read capabilities file (%s)", b);
- } else {
- if (!strcmp(buf, "10"))
- tmp[count].type = DISK;
- }
-
- count++;
- }
- }
- /* ----------------------------------------------- */
log_message("looking for other disks");
{
glob_t globbuf;
// TODO: We should switch everything to here, and later switch to ignoring
// some types of disks (ram, loop, ...) rather than a list to accept.
glob("/sys/block/nvme*", 0, NULL, &globbuf);
+ glob("/sys/block/vd*", 0, NULL, &globbuf);
for (int i = 0; i < globbuf.gl_pathc; i++) {
char *name, *pathend;
@@ -948,8 +914,30 @@ void find_media(enum media_bus bus)
strcpy(pathend, "/device/model");
read_attribute(path, model+vendor_length);
+ strcpy(pathend, "/device/capability");
+ strcpy(buf, "0x0");
+ read_attribute(path, buf+3);
+ int caps = atoi(buf);
+
+ if (!(caps & 0x0010)) {
+ log_message("Ignoring device %s (not up)", name);
+ free(name);
+ continue;
+ }
+
+ if (caps & 0x0400) {
+ log_message("Ignoring device %s (hidden)", name);
+ free(name);
+ continue;
+ }
+
+ if (caps & 0x0008) {
+ tmp[count].type = CDROM;
+ } else {
+ tmp[count].type = DISK;
+ }
+
tmp[count].name = name;
- tmp[count].type = DISK;
tmp[count].model = strdup(model);
count++;
}