Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src Pull up following revision(s) (requested by jnemeth in ti...
details: https://anonhg.NetBSD.org/src/rev/8665661d0992
branches: netbsd-7
changeset: 799386:8665661d0992
user: snj <snj%NetBSD.org@localhost>
date: Mon Jun 01 19:19:44 2015 +0000
description:
Pull up following revision(s) (requested by jnemeth in ticket #775):
share/man/man9/disk.9: revision 1.37
sys/kern/subr_disk.c: revisions 1.104, 1.105
sys/dev/dksubr.c: revision 1.56
sys/sys/dkio.h: revision 1.21
Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD.
--
clear error for new ioctls.
diffstat:
share/man/man9/disk.9 | 6 +++++-
sys/dev/dksubr.c | 19 ++-----------------
sys/kern/subr_disk.c | 15 ++++++++++++---
sys/sys/dkio.h | 6 +++++-
4 files changed, 24 insertions(+), 22 deletions(-)
diffs (128 lines):
diff -r 7c1405120cca -r 8665661d0992 share/man/man9/disk.9
--- a/share/man/man9/disk.9 Thu May 28 10:03:27 2015 +0000
+++ b/share/man/man9/disk.9 Mon Jun 01 19:19:44 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: disk.9,v 1.36 2010/12/02 12:54:13 wiz Exp $
+.\" $NetBSD: disk.9,v 1.36.24.1 2015/06/01 19:19:44 snj 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 7c1405120cca -r 8665661d0992 sys/dev/dksubr.c
--- a/sys/dev/dksubr.c Thu May 28 10:03:27 2015 +0000
+++ b/sys/dev/dksubr.c Mon Jun 01 19:19:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.51.2.2 2014/11/11 10:42:22 martin Exp $ */
+/* $NetBSD: dksubr.c,v 1.51.2.3 2015/06/01 19:19:44 snj 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.51.2.2 2014/11/11 10:42:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.51.2.3 2015/06/01 19:19:44 snj Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -291,10 +291,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:
@@ -317,17 +313,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 7c1405120cca -r 8665661d0992 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c Thu May 28 10:03:27 2015 +0000
+++ b/sys/kern/subr_disk.c Mon Jun 01 19:19:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.103.4.1 2015/05/19 04:53:02 snj Exp $ */
+/* $NetBSD: subr_disk.c,v 1.103.4.2 2015/06/01 19:19:44 snj 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.4.1 2015/05/19 04:53:02 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.103.4.2 2015/06/01 19:19:44 snj Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -510,7 +510,7 @@
disk_ioctl(struct disk *diskp, u_long cmd, void *data, int flag,
struct lwp *l)
{
- int error;
+ int error = 0;
switch (cmd) {
case DIOCGDISKINFO:
@@ -525,6 +525,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 7c1405120cca -r 8665661d0992 sys/sys/dkio.h
--- a/sys/sys/dkio.h Thu May 28 10:03:27 2015 +0000
+++ b/sys/sys/dkio.h Mon Jun 01 19:19:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkio.h,v 1.19.2.1 2014/11/11 10:36:41 martin Exp $ */
+/* $NetBSD: dkio.h,v 1.19.2.2 2015/06/01 19:19:44 snj 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