Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.
details: https://anonhg.NetBSD.org/src/rev/674c0d46054e
branches: trunk
changeset: 335194:674c0d46054e
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Dec 29 18:41:20 2014 +0000
description:
Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.
diffstat:
share/man/man9/disk.9 | 6 +++++-
sys/dev/dksubr.c | 19 ++-----------------
sys/kern/subr_disk.c | 13 +++++++++++--
sys/sys/dkio.h | 6 +++++-
4 files changed, 23 insertions(+), 21 deletions(-)
diffs (119 lines):
diff -r 891ea22365bd -r 674c0d46054e share/man/man9/disk.9
--- a/share/man/man9/disk.9 Mon Dec 29 18:36:27 2014 +0000
+++ b/share/man/man9/disk.9 Mon Dec 29 18:41:20 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: disk.9,v 1.36 2010/12/02 12:54:13 wiz Exp $
+.\" $NetBSD: disk.9,v 1.37 2014/12/29 18:41:20 mlelstv Exp $
.\"
.\" Copyright (c) 1995, 1996 Jason R. Thorpe.
.\" All rights reserved.
@@ -299,6 +299,10 @@
Set disk buffer queue strategy.
.It Dv DIOCGDISKINFO "struct plistref"
Get disk-info dictionary.
+.It Dv DIOCGMEDIASIZE "off_t"
+Get disk size in bytes.
+.It Dv DIOCGSECTORSIZE "u_int"
+Get sector size in bytes.
.El
.Sh USING THE FRAMEWORK
This section includes a description on basic use of the framework
diff -r 891ea22365bd -r 674c0d46054e sys/dev/dksubr.c
--- a/sys/dev/dksubr.c Mon Dec 29 18:36:27 2014 +0000
+++ b/sys/dev/dksubr.c Mon Dec 29 18:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.55 2014/12/29 12:03:39 mlelstv Exp $ */
+/* $NetBSD: dksubr.c,v 1.56 2014/12/29 18:41:20 mlelstv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.55 2014/12/29 12:03:39 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.56 2014/12/29 18:41:20 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -311,10 +311,6 @@
/* ensure that the pseudo-disk is initialized for these */
switch (cmd) {
-#ifdef DIOCGSECTORSIZE
- case DIOCGSECTORSIZE:
- case DIOCGMEDIASIZE:
-#endif
case DIOCGDINFO:
case DIOCSDINFO:
case DIOCWDINFO:
@@ -337,17 +333,6 @@
}
switch (cmd) {
-#ifdef DIOCGSECTORSIZE
- case DIOCGSECTORSIZE:
- *(u_int *)data = dksc->sc_dkdev.dk_geom.dg_secsize;
- return 0;
- case DIOCGMEDIASIZE:
- *(off_t *)data =
- (off_t)dksc->sc_dkdev.dk_geom.dg_secsize *
- dksc->sc_dkdev.dk_geom.dg_nsectors;
- return 0;
-#endif
-
case DIOCGDINFO:
*(struct disklabel *)data = *(dksc->sc_dkdev.dk_label);
break;
diff -r 891ea22365bd -r 674c0d46054e sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c Mon Dec 29 18:36:27 2014 +0000
+++ b/sys/kern/subr_disk.c Mon Dec 29 18:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.103 2013/10/19 22:36:57 mlelstv Exp $ */
+/* $NetBSD: subr_disk.c,v 1.104 2014/12/29 18:41:20 mlelstv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.103 2013/10/19 22:36:57 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.104 2014/12/29 18:41:20 mlelstv Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -502,6 +502,15 @@
break;
}
+ case DIOCGSECTORSIZE:
+ *(u_int *)data = diskp->dk_geom.dg_secsize;
+ break;
+
+ case DIOCGMEDIASIZE:
+ *(off_t *)data = (off_t)diskp->dk_geom.dg_secsize *
+ diskp->dk_geom.dg_secperunit;
+ break;
+
default:
error = EPASSTHROUGH;
}
diff -r 891ea22365bd -r 674c0d46054e sys/sys/dkio.h
--- a/sys/sys/dkio.h Mon Dec 29 18:36:27 2014 +0000
+++ b/sys/sys/dkio.h Mon Dec 29 18:41:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkio.h,v 1.20 2014/11/04 07:41:37 mlelstv Exp $ */
+/* $NetBSD: dkio.h,v 1.21 2014/12/29 18:41:20 mlelstv Exp $ */
/*
* Copyright (c) 1987, 1988, 1993
@@ -115,4 +115,8 @@
/* trigger wedge auto discover */
#define DIOCMWEDGES _IOR('d', 131, int) /* make wedges */
+ /* query disk geometry */
+#define DIOCGSECTORSIZE _IOR('d', 133, u_int) /* sector size in bytes */
+#define DIOCGMEDIASIZE _IOR('d', 132, off_t) /* media size in bytes */
+
#endif /* _SYS_DKIO_H_ */
Home |
Main Index |
Thread Index |
Old Index