svn commit: r237374 - user/ae/bootcode/sys/boot/i386/libi386

Andrey V. Elsukov ae at FreeBSD.org
Thu Jun 21 10:03:49 UTC 2012


Author: ae
Date: Thu Jun 21 10:03:48 2012
New Revision: 237374
URL: http://svn.freebsd.org/changeset/base/237374

Log:
  Implement DIOSGSECTORSIZE and DIOCGMEDIASIZE ioctls for biosdisk.

Modified:
  user/ae/bootcode/sys/boot/i386/libi386/biosdisk.c

Modified: user/ae/bootcode/sys/boot/i386/libi386/biosdisk.c
==============================================================================
--- user/ae/bootcode/sys/boot/i386/libi386/biosdisk.c	Thu Jun 21 09:57:34 2012	(r237373)
+++ user/ae/bootcode/sys/boot/i386/libi386/biosdisk.c	Thu Jun 21 10:03:48 2012	(r237374)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
  *
  */
 
+#include <sys/disk.h>
 #include <stand.h>
 #include <machine/bootinfo.h>
 
@@ -114,6 +115,7 @@ static int bd_realstrategy(void *devdata
     size_t size, char *buf, size_t *rsize);
 static int bd_open(struct open_file *f, ...);
 static int bd_close(struct open_file *f);
+static int bd_ioctl(struct open_file *f, u_long cmd, void *data);
 static void bd_print(int verbose);
 
 struct bd_print_args {
@@ -519,6 +521,26 @@ bd_close(struct open_file *f)
 	return (0);
 }
 
+static int
+bd_ioctl(struct open_file *f, u_long cmd, void *data)
+{
+	struct open_disk *od;
+
+	od = (struct open_disk *)
+	    (((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data);
+	switch (cmd) {
+	case DIOCGSECTORSIZE:
+		*(u_int *)data = BDSECSZ(od);
+		break;
+	case DIOCGMEDIASIZE:
+		*(off_t *)data = BDSZ(od) * BDSECSZ(od);
+		break;
+	default:
+		return (ENOTTY);
+	}
+	return (0);
+}
+
 static void
 bd_closedisk(struct open_disk *od)
 {


More information about the svn-src-user mailing list