Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jun 2012 11:01:12 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r237599 - user/ae/bootcode/sys/boot/userboot/test
Message-ID:  <201206261101.q5QB1CWc036246@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206261101.q5QB1CWc036246>