summaryrefslogtreecommitdiffstats
path: root/usr.sbin/fdcontrol
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-02-25 13:43:39 +0000
committerphk <phk@FreeBSD.org>2004-02-25 13:43:39 +0000
commit8e9d9728d468509b765adc961f6fc9dd547ec66d (patch)
tree64102e8bea4e421c176f55d88d0182792c69334d /usr.sbin/fdcontrol
parent723f970b1f0f70fad78c2aaaa7f13f07d1c8a0ad (diff)
downloadFreeBSD-src-8e9d9728d468509b765adc961f6fc9dd547ec66d.zip
FreeBSD-src-8e9d9728d468509b765adc961f6fc9dd547ec66d.tar.gz
Recognize "auto" format.
Be more verbose when asked to.
Diffstat (limited to 'usr.sbin/fdcontrol')
-rw-r--r--usr.sbin/fdcontrol/Makefile2
-rw-r--r--usr.sbin/fdcontrol/fdcontrol.c51
2 files changed, 47 insertions, 6 deletions
diff --git a/usr.sbin/fdcontrol/Makefile b/usr.sbin/fdcontrol/Makefile
index 32196b7..be67b66 100644
--- a/usr.sbin/fdcontrol/Makefile
+++ b/usr.sbin/fdcontrol/Makefile
@@ -7,6 +7,6 @@ SRCS= fdcontrol.c fdutil.c
MAN= fdcontrol.8
WARNS?= 2
-CFLAGS+= -I${.CURDIR}/../fdread
+CFLAGS+= -I${.CURDIR}/../fdread -static
.include <bsd.prog.mk>
diff --git a/usr.sbin/fdcontrol/fdcontrol.c b/usr.sbin/fdcontrol/fdcontrol.c
index ba1e1f3d..5ef5057 100644
--- a/usr.sbin/fdcontrol/fdcontrol.c
+++ b/usr.sbin/fdcontrol/fdcontrol.c
@@ -92,7 +92,9 @@ main(int argc, char **argv)
break;
case 'f':
- if (getnum(optarg, &format)) {
+ if (!strcmp(optarg, "auto")) {
+ format = -1;
+ } else if (getnum(optarg, &format)) {
fprintf(stderr,
"Bad argument %s to -f option; must be numeric\n",
optarg);
@@ -124,6 +126,7 @@ main(int argc, char **argv)
mode = O_RDONLY | O_NONBLOCK;
else
mode = O_RDWR;
+mode = O_RDONLY | O_NONBLOCK;
if((fd = open(argv[0], mode)) < 0)
err(EX_UNAVAILABLE, "open(%s)", argv[0]);
@@ -154,10 +157,48 @@ main(int argc, char **argv)
}
if (showfmt) {
- if (verbose)
- printf("%s: %d KB media type, fmt = ",
- argv[0], ft.size / 2);
- print_fmt(ft);
+ if (verbose) {
+ char *s;
+
+ printf("%s: %d KB media type\n", argv[0],
+ (128 << ft.secsize) * ft.size / 1024);
+ printf("\tFormat:\t\t");
+ print_fmt(ft);
+ if (ft.datalen != 0xff &&
+ ft.datalen != (128 << ft.secsize))
+ printf("\tData length:\t%d\n", ft.datalen);
+ printf("\tSector size:\t%d\n", 128 << ft.secsize);
+ printf("\tSectors/track:\t%d\n", ft.sectrac);
+ printf("\tHeads/cylinder:\t%d\n", ft.heads);
+ printf("\tCylinders/disk:\t%d\n", ft.tracks);
+ switch (ft.trans) {
+ case 0: printf("\tTransfer rate:\t500 kbps\n"); break;
+ case 1: printf("\tTransfer rate:\t300 kbps\n"); break;
+ case 2: printf("\tTransfer rate:\t250 kbps\n"); break;
+ case 3: printf("\tTransfer rate:\t1 Mbps\n"); break;
+ }
+ printf("\tSector gap:\t%d\n", ft.gap);
+ printf("\tFormat gap:\t%d\n", ft.f_gap);
+ printf("\tInterleave:\t%d\n", ft.f_inter);
+ printf("\tSide offset:\t%d\n", ft.offset_side2);
+ printf("\tFlags\t\t<");
+ s = "";
+ if (ft.flags & FL_MFM) {
+ printf("%sMFM", s);
+ s = ",";
+ }
+ if (ft.flags & FL_2STEP) {
+ printf("%s2STEP", s);
+ s = ",";
+ }
+ if (ft.flags & FL_PERPND) {
+ printf("%sPERPENDICULAR", s);
+ s = ",";
+ }
+ printf(">\n");
+ } else {
+ print_fmt(ft);
+ }
return (0);
}
OpenPOWER on IntegriCloud