Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/diskinfo/diskinfo.c
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
fprintf(stderr, "usage: diskinfo [-cipsStvw] disk ...\n"); | fprintf(stderr, "usage: diskinfo [-cipsStvw] disk ...\n"); | ||||
exit (1); | exit (1); | ||||
} | } | ||||
static int opt_c, opt_i, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w; | static int opt_c, opt_i, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w; | ||||
static bool candelete(int fd); | static bool candelete(int fd); | ||||
static bool hba_name(int fd, char *hbaname, size_t buflen); | |||||
static void speeddisk(int fd, off_t mediasize, u_int sectorsize); | static void speeddisk(int fd, off_t mediasize, u_int sectorsize); | ||||
static void commandtime(int fd, off_t mediasize, u_int sectorsize); | static void commandtime(int fd, off_t mediasize, u_int sectorsize); | ||||
static void iopsbench(int fd, off_t mediasize, u_int sectorsize); | static void iopsbench(int fd, off_t mediasize, u_int sectorsize); | ||||
static void rotationrate(int fd, char *buf, size_t buflen); | static void rotationrate(int fd, char *buf, size_t buflen); | ||||
static void slogbench(int fd, int isreg, off_t mediasize, u_int sectorsize); | static void slogbench(int fd, int isreg, off_t mediasize, u_int sectorsize); | ||||
static int zonecheck(int fd, uint32_t *zone_mode, char *zone_str, | static int zonecheck(int fd, uint32_t *zone_mode, char *zone_str, | ||||
size_t zone_str_len); | size_t zone_str_len); | ||||
static uint8_t *buf; | static uint8_t *buf; | ||||
int | int | ||||
main(int argc, char **argv) | main(int argc, char **argv) | ||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
int i, ch, fd, error, exitval = 0; | int i, ch, fd, error, exitval = 0; | ||||
char tstr[BUFSIZ], ident[DISK_IDENT_SIZE], physpath[MAXPATHLEN]; | char tstr[BUFSIZ], ident[DISK_IDENT_SIZE], physpath[MAXPATHLEN], | ||||
hbaname[MAXPATHLEN]; | |||||
char zone_desc[64]; | char zone_desc[64]; | ||||
char rrate[64]; | char rrate[64]; | ||||
struct diocgattr_arg arg; | struct diocgattr_arg arg; | ||||
off_t mediasize, stripesize, stripeoffset; | off_t mediasize, stripesize, stripeoffset; | ||||
u_int sectorsize, fwsectors, fwheads, zoned = 0, isreg; | u_int sectorsize, fwsectors, fwheads, zoned = 0, isreg; | ||||
uint32_t zone_mode; | uint32_t zone_mode; | ||||
while ((ch = getopt(argc, argv, "cipsStvw")) != -1) { | while ((ch = getopt(argc, argv, "cipsStvw")) != -1) { | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | if (!opt_v) { | ||||
printf("\t%-12u\t# Sectors according to firmware.\n", fwsectors); | printf("\t%-12u\t# Sectors according to firmware.\n", fwsectors); | ||||
} | } | ||||
strlcpy(arg.name, "GEOM::descr", sizeof(arg.name)); | strlcpy(arg.name, "GEOM::descr", sizeof(arg.name)); | ||||
arg.len = sizeof(arg.value.str); | arg.len = sizeof(arg.value.str); | ||||
if (ioctl(fd, DIOCGATTR, &arg) == 0) | if (ioctl(fd, DIOCGATTR, &arg) == 0) | ||||
printf("\t%-12s\t# Disk descr.\n", arg.value.str); | printf("\t%-12s\t# Disk descr.\n", arg.value.str); | ||||
if (ioctl(fd, DIOCGIDENT, ident) == 0) | if (ioctl(fd, DIOCGIDENT, ident) == 0) | ||||
printf("\t%-12s\t# Disk ident.\n", ident); | printf("\t%-12s\t# Disk ident.\n", ident); | ||||
if (hba_name(fd, hbaname, sizeof(hbaname))) | |||||
printf("\t%-12s\t# HBA device name\n", hbaname); | |||||
if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) | if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) | ||||
printf("\t%-12s\t# Physical path\n", physpath); | printf("\t%-12s\t# Physical path\n", physpath); | ||||
printf("\t%-12s\t# TRIM/UNMAP support\n", | printf("\t%-12s\t# TRIM/UNMAP support\n", | ||||
candelete(fd) ? "Yes" : "No"); | candelete(fd) ? "Yes" : "No"); | ||||
rotationrate(fd, rrate, sizeof(rrate)); | rotationrate(fd, rrate, sizeof(rrate)); | ||||
printf("\t%-12s\t# Rotation rate in RPM\n", rrate); | printf("\t%-12s\t# Rotation rate in RPM\n", rrate); | ||||
if (zoned != 0) | if (zoned != 0) | ||||
printf("\t%-12s\t# Zone Mode\n", zone_desc); | printf("\t%-12s\t# Zone Mode\n", zone_desc); | ||||
Show All 20 Lines | candelete(int fd) | ||||
struct diocgattr_arg arg; | struct diocgattr_arg arg; | ||||
strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); | strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); | ||||
arg.len = sizeof(arg.value.i); | arg.len = sizeof(arg.value.i); | ||||
if (ioctl(fd, DIOCGATTR, &arg) == 0) | if (ioctl(fd, DIOCGATTR, &arg) == 0) | ||||
return (arg.value.i != 0); | return (arg.value.i != 0); | ||||
else | else | ||||
return (false); | return (false); | ||||
} | |||||
static bool | |||||
hba_name(int fd, char *hbaname, size_t buflen) | |||||
{ | |||||
struct diocgattr_arg arg1, arg2; | |||||
int ret; | |||||
strlcpy(arg1.name, "GEOM::dev_name", sizeof(arg1.name)); | |||||
arg1.len = sizeof(arg1.value.str); | |||||
ret = ioctl(fd, DIOCGATTR, &arg1); | |||||
if (ret != 0 || arg1.value.str[0] == '\0') | |||||
return (false); | |||||
strlcpy(arg2.name, "GEOM::unit_number", sizeof(arg2.name)); | |||||
arg2.len = sizeof(arg2.value.i); | |||||
ret = ioctl(fd, DIOCGATTR, &arg2); | |||||
if (ret != 0) | |||||
return (false); | |||||
snprintf(hbaname, buflen, "%s%d", arg1.value.str, arg2.value.i); | |||||
return (true); | |||||
} | } | ||||
static void | static void | ||||
rotationrate(int fd, char *rate, size_t buflen) | rotationrate(int fd, char *rate, size_t buflen) | ||||
{ | { | ||||
struct diocgattr_arg arg; | struct diocgattr_arg arg; | ||||
int ret; | int ret; | ||||
▲ Show 20 Lines • Show All 452 Lines • Show Last 20 Lines |