Page MenuHomeFreeBSD

D7828.1794281613.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D7828.1794281613.diff

Index: usr.sbin/diskinfo/diskinfo.8
===================================================================
--- usr.sbin/diskinfo/diskinfo.8
+++ usr.sbin/diskinfo/diskinfo.8
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 9, 2004
+.Dd September 8, 2016
.Dt DISKINFO 8
.Os
.Sh NAME
@@ -38,6 +38,12 @@
.Nm
.Op Fl ctv
.Ar disk ...
+.Nm
+.Op Fl i
+.Ar disk ...
+.Nm
+.Op Fl p
+.Ar disk ...
.Sh DESCRIPTION
The
.Nm
@@ -50,18 +56,20 @@
firmware heads, and firmware sectors.
The last three fields are only present if the information is available.
.Pp
-If given the
-.Fl v
-option, the fields will be printed one per line with a descriptive comment.
-.Pp
-The
-.Fl c
-option triggers a simple measurement of the I/O read command overhead.
-.Pp
-The
-.Fl t
-option triggers a simple and rather naive benchmark of the disks seek
+.Bl -tag -width ".Fl v"
+.It Fl v
+Prints the fields one per line with a descriptive comment.
+.It Fl c
+Triggers a simple measurement of the I/O read command overhead.
+.It Fl t
+Triggers a simple and rather naive benchmark of the disks seek
and transfer performance.
+.It Fl i
+Returns the ident, usually the serial number, of the disk.
+.It Fl p
+Returns the physical path of the disk.
+Used to find the disk in an enclosure.
+.El
.Sh HISTORY
The
.Nm
Index: usr.sbin/diskinfo/diskinfo.c
===================================================================
--- usr.sbin/diskinfo/diskinfo.c
+++ usr.sbin/diskinfo/diskinfo.c
@@ -51,7 +51,7 @@
exit (1);
}
-static int opt_c, opt_t, opt_v;
+static int opt_c, opt_i, opt_p, opt_t, opt_v;
static void speeddisk(int fd, off_t mediasize, u_int sectorsize);
static void commandtime(int fd, off_t mediasize, u_int sectorsize);
@@ -68,12 +68,18 @@
u_int sectorsize, fwsectors, fwheads, zoned = 0;
uint32_t zone_mode;
- while ((ch = getopt(argc, argv, "ctv")) != -1) {
+ while ((ch = getopt(argc, argv, "ciptv")) != -1) {
switch (ch) {
case 'c':
opt_c = 1;
opt_v = 1;
break;
+ case 'i':
+ opt_i = 1;
+ break;
+ case 'p':
+ opt_p = 1;
+ break;
case 't':
opt_t = 1;
opt_v = 1;
@@ -91,6 +97,11 @@
if (argc < 1)
usage();
+ if ((opt_i && opt_p) || ((opt_i || opt_p) && (opt_c || opt_t || opt_v))) {
+ warnx("-i and -p can only be used on their own");
+ usage();
+ }
+
for (i = 0; i < argc; i++) {
fd = open(argv[i], O_RDONLY);
if (fd < 0 && errno == ENOENT && *argv[i] != '/') {
@@ -102,6 +113,24 @@
exitval = 1;
goto out;
}
+
+ if (opt_i) {
+ if (ioctl(fd, DIOCGIDENT, ident) == 0) {
+ printf("%s\n", ident);
+ } else {
+ warnx("Failed to determine ident for: %s", argv[i]);
+ }
+ goto out;
+ }
+ if (opt_p) {
+ if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) {
+ printf("%s\n", physpath);
+ } else {
+ warnx("Failed to determine physpath for: %s", argv[i]);
+ }
+ goto out;
+ }
+
error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
if (error) {
warnx("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 10, 3:33 AM (21 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41609417
Default Alt Text
D7828.1794281613.diff (2 KB)

Event Timeline