summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/probing.c
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-01-26 18:58:23 +0000
committerThierry Vignaud <tv@mageia.org>2012-01-26 18:58:23 +0000
commitc7b4c1bd9048e159ee52893d9bf3b3592b25983f (patch)
treedb45153d7d33e722a73f14289185b4788384c6fc /mdk-stage1/probing.c
parentf741b647156ef40cfd06455158172e5fbf69ab24 (diff)
downloaddrakx-c7b4c1bd9048e159ee52893d9bf3b3592b25983f.tar
drakx-c7b4c1bd9048e159ee52893d9bf3b3592b25983f.tar.gz
drakx-c7b4c1bd9048e159ee52893d9bf3b3592b25983f.tar.bz2
drakx-c7b4c1bd9048e159ee52893d9bf3b3592b25983f.tar.xz
drakx-c7b4c1bd9048e159ee52893d9bf3b3592b25983f.zip
(ensure_dev_exists,find_media) add support for virtio discs
Diffstat (limited to 'mdk-stage1/probing.c')
-rw-r--r--mdk-stage1/probing.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 6b969300b..ff5b02994 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -866,6 +866,41 @@ void find_media(enum media_bus bus)
fclose(f);
}
}
+ /* ----------------------------------------------- */
+ 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++;
+ }
+ }
find_media_after_scsi:
/* ----------------------------------------------- */