Module Name: src
Committed By: mlelstv
Date: Sat Sep 14 08:30:44 UTC 2024
Modified Files:
src/sbin/dkctl: dkctl.8 dkctl.c
Log Message:
Expose DIOCGMEDIASIZE, DIOCGSECTORSIZE with new getgeometry command.
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sbin/dkctl/dkctl.8
cvs rdiff -u -r1.26 -r1.27 src/sbin/dkctl/dkctl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/dkctl/dkctl.8
diff -u src/sbin/dkctl/dkctl.8:1.29 src/sbin/dkctl/dkctl.8:1.30
--- src/sbin/dkctl/dkctl.8:1.29 Mon Mar 30 08:36:09 2020
+++ src/sbin/dkctl/dkctl.8 Sat Sep 14 08:30:44 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: dkctl.8,v 1.29 2020/03/30 08:36:09 wiz Exp $
+.\" $NetBSD: dkctl.8,v 1.30 2024/09/14 08:30:44 mlelstv Exp $
.\"
.\" Copyright 2002 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -132,6 +132,8 @@ Get and display the cache enables for th
Display information about the specified disk wedge.
.Ar device
in this case is the wedge name.
+.It Ic getgeometry
+Display media and sector size of the specified disk, wedge or volume.
.It Ic keeplabel Op Ar yes | no
Specify to keep or drop the in-core disklabel on the last close of
the disk device.
Index: src/sbin/dkctl/dkctl.c
diff -u src/sbin/dkctl/dkctl.c:1.26 src/sbin/dkctl/dkctl.c:1.27
--- src/sbin/dkctl/dkctl.c:1.26 Sun Jan 7 12:29:25 2018
+++ src/sbin/dkctl/dkctl.c Sat Sep 14 08:30:44 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dkctl.c,v 1.26 2018/01/07 12:29:25 kre Exp $ */
+/* $NetBSD: dkctl.c,v 1.27 2024/09/14 08:30:44 mlelstv Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: dkctl.c,v 1.26 2018/01/07 12:29:25 kre Exp $");
+__RCSID("$NetBSD: dkctl.c,v 1.27 2024/09/14 08:30:44 mlelstv Exp $");
#endif
#include <sys/param.h>
@@ -100,6 +100,7 @@ static void disk_badsectors(int, char *[
static void disk_addwedge(int, char *[]);
static void disk_delwedge(int, char *[]);
static void disk_getwedgeinfo(int, char *[]);
+static void disk_getgeometry(int, char *[]);
static void disk_listwedges(int, char *[]);
static void disk_makewedges(int, char *[]);
static void disk_strategy(int, char *[]);
@@ -130,6 +131,11 @@ static struct command commands[] = {
disk_getwedgeinfo,
O_RDONLY },
+ { "getgeometry",
+ "",
+ disk_getgeometry,
+ O_RDONLY },
+
{ "keeplabel",
YESNO_ARG,
disk_keeplabel,
@@ -626,6 +632,26 @@ disk_getwedgeinfo(int argc, char *argv[]
}
static void
+disk_getgeometry(int argc, char *argv[])
+{
+ off_t bytes;
+ u_int secsize;
+
+ if (argc != 1)
+ usage();
+
+ if (ioctl(fd, DIOCGMEDIASIZE, &bytes) == -1)
+ err(EXIT_FAILURE, "%s: getmediasize", dvname);
+
+ secsize = DEV_BSIZE;
+ if (ioctl(fd, DIOCGSECTORSIZE, &secsize) == -1)
+ warn("%s: getsectorsize", dvname);
+
+ printf("%s: %"PRIu64" bytes in %"PRIu64" blocks of %u bytes\n",
+ dvname, bytes, bytes/secsize, secsize);
+}
+
+static void
disk_listwedges(int argc, char *argv[])
{
struct dkwedge_info *dkw;