diff options
| author | Andrey V. Elsukov <ae@FreeBSD.org> | 2012-08-05 12:15:15 +0000 |
|---|---|---|
| committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2012-08-05 12:15:15 +0000 |
| commit | 2c6f04dc0a1fc38959acb378f6d48203cd351f60 (patch) | |
| tree | 501c361d26f74b81898691e07cc2c47566e5946b /sys/boot/userboot/test | |
| parent | 9cef00000859df891c0536e2f4c4c1f527955eb0 (diff) | |
Notes
Diffstat (limited to 'sys/boot/userboot/test')
| -rw-r--r-- | sys/boot/userboot/test/test.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/boot/userboot/test/test.c b/sys/boot/userboot/test/test.c index a752a8032ef80..8745d315cbf51 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, |
