summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-03-19 13:54:15 +0000
committerphk <phk@FreeBSD.org>2002-03-19 13:54:15 +0000
commit4106fb634928e1b6d3744c3b8317083f2c780bfc (patch)
tree045a98068ab44510351eedb7469fd082579845d3
parent6718ce496e665b6c2204043dd44f4412da8aebd1 (diff)
downloadFreeBSD-src-4106fb634928e1b6d3744c3b8317083f2c780bfc.zip
FreeBSD-src-4106fb634928e1b6d3744c3b8317083f2c780bfc.tar.gz
Add five GEOM oriented ioctls to get basic information about a geom device.
-rw-r--r--sys/geom/geom_dev.c42
-rw-r--r--sys/sys/disklabel.h6
-rw-r--r--sys/sys/diskmbr.h6
-rw-r--r--sys/sys/diskpc98.h6
4 files changed, 49 insertions, 11 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index d0be27a..ee85122 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -248,17 +248,37 @@ g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
error = 0;
DROP_GIANT();
- gio = g_malloc(sizeof *gio, M_WAITOK);
- gio->cmd = cmd;
- gio->data = data;
- gio->fflag = fflag;
- gio->td = td;
- i = sizeof *gio;
- if (cmd & IOC_IN)
- error = g_io_setattr("GEOM::ioctl", cp, i, gio, td);
- else
- error = g_io_getattr("GEOM::ioctl", cp, &i, gio, td);
- g_free(gio);
+ i = IOCPARM_LEN(cmd);
+ switch (cmd) {
+ case DIOCGSECTORSIZE:
+ error = g_io_getattr("GEOM::sectorsize", cp, &i, data, td);
+ break;
+ case DIOCGMEDIASIZE:
+ error = g_io_getattr("GEOM::mediasize", cp, &i, data, td);
+ break;
+ case DIOCGFWSECTORS:
+ error = g_io_getattr("GEOM::fwsectors", cp, &i, data, td);
+ break;
+ case DIOCGFWHEADS:
+ error = g_io_getattr("GEOM::fwheads", cp, &i, data, td);
+ break;
+ case DIOCGFWCYLINDERS:
+ error = g_io_getattr("GEOM::fwcylinders", cp, &i, data, td);
+ break;
+ default:
+ gio = g_malloc(sizeof *gio, M_WAITOK);
+ gio->cmd = cmd;
+ gio->data = data;
+ gio->fflag = fflag;
+ gio->td = td;
+ i = sizeof *gio;
+ if (cmd & IOC_IN)
+ error = g_io_setattr("GEOM::ioctl", cp, i, gio, td);
+ else
+ error = g_io_getattr("GEOM::ioctl", cp, &i, gio, td);
+ g_free(gio);
+ break;
+ }
if (error != 0 && cmd == DIOCGDVIRGIN) {
g_topology_lock();
diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h
index a3b927f..4cf1223 100644
--- a/sys/sys/disklabel.h
+++ b/sys/sys/disklabel.h
@@ -418,6 +418,12 @@ struct dos_partition {
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
+#define DIOCGSECTORSIZE _IOR('d', 128, u_int) /* Get sector size in bytes */
+#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */
+#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware sectorcount */
+#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware headcount */
+#define DIOCGFWCYLINDERS _IOR('d', 132, u_int) /* Get firmware cyl'scount */
+
#ifdef _KERNEL
/*
diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h
index a3b927f..4cf1223 100644
--- a/sys/sys/diskmbr.h
+++ b/sys/sys/diskmbr.h
@@ -418,6 +418,12 @@ struct dos_partition {
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
+#define DIOCGSECTORSIZE _IOR('d', 128, u_int) /* Get sector size in bytes */
+#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */
+#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware sectorcount */
+#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware headcount */
+#define DIOCGFWCYLINDERS _IOR('d', 132, u_int) /* Get firmware cyl'scount */
+
#ifdef _KERNEL
/*
diff --git a/sys/sys/diskpc98.h b/sys/sys/diskpc98.h
index a3b927f..4cf1223 100644
--- a/sys/sys/diskpc98.h
+++ b/sys/sys/diskpc98.h
@@ -418,6 +418,12 @@ struct dos_partition {
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
+#define DIOCGSECTORSIZE _IOR('d', 128, u_int) /* Get sector size in bytes */
+#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */
+#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware sectorcount */
+#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware headcount */
+#define DIOCGFWCYLINDERS _IOR('d', 132, u_int) /* Get firmware cyl'scount */
+
#ifdef _KERNEL
/*
OpenPOWER on IntegriCloud