svn commit: r237599 - user/ae/bootcode/sys/boot/userboot/test
Andrey V. Elsukov
ae at FreeBSD.org
Tue Jun 26 11:01:13 UTC 2012
Author: ae
Date: Tue Jun 26 11:01:12 2012
New Revision: 237599
URL: http://svn.freebsd.org/changeset/base/237599
Log:
Implement diskioctl call in the userboot test programm.
Modified:
user/ae/bootcode/sys/boot/userboot/test/test.c
Modified: user/ae/bootcode/sys/boot/userboot/test/test.c
==============================================================================
--- user/ae/bootcode/sys/boot/userboot/test/test.c Tue Jun 26 11:00:34 2012 (r237598)
+++ user/ae/bootcode/sys/boot/userboot/test/test.c Tue Jun 26 11:01:12 2012 (r237599)
@@ -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, uint6
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,
More information about the svn-src-user
mailing list