summaryrefslogtreecommitdiffstats
path: root/sys/boot/userboot/test/test.c
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2012-08-05 12:15:15 +0000
committerae <ae@FreeBSD.org>2012-08-05 12:15:15 +0000
commitdd4aba9f57e96eb70a818f9730bcd8dbad26237b (patch)
tree501c361d26f74b81898691e07cc2c47566e5946b /sys/boot/userboot/test/test.c
parentf18cc2993b88548bf262e2f65f28a84a06343770 (diff)
downloadFreeBSD-src-dd4aba9f57e96eb70a818f9730bcd8dbad26237b.zip
FreeBSD-src-dd4aba9f57e96eb70a818f9730bcd8dbad26237b.tar.gz
Introduce new API to work with disks from the loader's drivers.
It uses new API from the part.c to work with partition tables. Update userboot's disk driver to use new API. Note that struct loader_callbacks_v1 has changed.
Diffstat (limited to 'sys/boot/userboot/test/test.c')
-rw-r--r--sys/boot/userboot/test/test.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/boot/userboot/test/test.c b/sys/boot/userboot/test/test.c
index a752a80..8745d31 100644
--- a/sys/boot/userboot/test/test.c
+++ b/sys/boot/userboot/test/test.c
@@ -26,6 +26,8 @@
* $FreeBSD$
*/
+#include <sys/types.h>
+#include <sys/disk.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -251,6 +253,29 @@ test_diskread(void *arg, int unit, uint64_t offset, void *dst, size_t size,
return (0);
}
+int
+test_diskioctl(void *arg, int unit, u_long cmd, void *data)
+{
+ struct stat sb;
+
+ if (unit != 0 || disk_fd == -1)
+ return (EBADF);
+ switch (cmd) {
+ case DIOCGSECTORSIZE:
+ *(u_int *)data = 512;
+ break;
+ case DIOCGMEDIASIZE:
+ if (fstat(disk_fd, &sb) == 0)
+ *(off_t *)data = sb.st_size;
+ else
+ return (ENOTTY);
+ break;
+ default:
+ return (ENOTTY);
+ };
+ return (0);
+}
+
/*
* Guest virtual machine i/o
*
@@ -353,6 +378,7 @@ struct loader_callbacks_v1 cb = {
.stat = test_stat,
.diskread = test_diskread,
+ .diskioctl = test_diskioctl,
.copyin = test_copyin,
.copyout = test_copyout,
OpenPOWER on IntegriCloud