diff options
Diffstat (limited to 'util-linux/fdformat.c')
-rw-r--r-- | util-linux/fdformat.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c index f94d455c9..63ec2204d 100644 --- a/util-linux/fdformat.c +++ b/util-linux/fdformat.c | |||
@@ -9,14 +9,6 @@ | |||
9 | * 5 July 2003 -- modified for Busybox by Erik Andersen | 9 | * 5 July 2003 -- modified for Busybox by Erik Andersen |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <stdio.h> | ||
13 | #include <string.h> | ||
14 | #include <fcntl.h> | ||
15 | #include <errno.h> | ||
16 | #include <unistd.h> | ||
17 | #include <stdlib.h> | ||
18 | #include <sys/stat.h> | ||
19 | #include <sys/ioctl.h> | ||
20 | #include "busybox.h" | 12 | #include "busybox.h" |
21 | 13 | ||
22 | 14 | ||
@@ -60,10 +52,10 @@ static void print_and_flush(const char * __restrict format, ...) | |||
60 | va_start(arg, format); | 52 | va_start(arg, format); |
61 | bb_vfprintf(stdout, format, arg); | 53 | bb_vfprintf(stdout, format, arg); |
62 | va_end(arg); | 54 | va_end(arg); |
63 | bb_xfflush_stdout(); | 55 | xfflush_stdout(); |
64 | } | 56 | } |
65 | 57 | ||
66 | static void bb_xioctl(int fd, int request, void *argp, const char *string) | 58 | static void xioctl(int fd, int request, void *argp, const char *string) |
67 | { | 59 | { |
68 | if (ioctl (fd, request, argp) < 0) { | 60 | if (ioctl (fd, request, argp) < 0) { |
69 | bb_perror_msg_and_die(string); | 61 | bb_perror_msg_and_die(string); |
@@ -95,9 +87,9 @@ int fdformat_main(int argc,char **argv) | |||
95 | 87 | ||
96 | 88 | ||
97 | /* O_RDWR for formatting and verifying */ | 89 | /* O_RDWR for formatting and verifying */ |
98 | fd = bb_xopen(*argv,O_RDWR ); | 90 | fd = xopen(*argv,O_RDWR ); |
99 | 91 | ||
100 | bb_xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */ | 92 | xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */ |
101 | 93 | ||
102 | print_and_flush("%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", | 94 | print_and_flush("%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", |
103 | (param.head == 2) ? "Double" : "Single", | 95 | (param.head == 2) ? "Double" : "Single", |
@@ -105,22 +97,22 @@ int fdformat_main(int argc,char **argv) | |||
105 | 97 | ||
106 | /* FORMAT */ | 98 | /* FORMAT */ |
107 | print_and_flush("Formatting ... ", NULL); | 99 | print_and_flush("Formatting ... ", NULL); |
108 | bb_xioctl(fd, FDFMTBEG,NULL,"FDFMTBEG"); | 100 | xioctl(fd, FDFMTBEG,NULL,"FDFMTBEG"); |
109 | 101 | ||
110 | /* n == track */ | 102 | /* n == track */ |
111 | for (n = 0; n < param.track; n++) | 103 | for (n = 0; n < param.track; n++) |
112 | { | 104 | { |
113 | descr.head = 0; | 105 | descr.head = 0; |
114 | descr.track = n; | 106 | descr.track = n; |
115 | bb_xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); | 107 | xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); |
116 | print_and_flush("%3d\b\b\b", n); | 108 | print_and_flush("%3d\b\b\b", n); |
117 | if (param.head == 2) { | 109 | if (param.head == 2) { |
118 | descr.head = 1; | 110 | descr.head = 1; |
119 | bb_xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); | 111 | xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); |
120 | } | 112 | } |
121 | } | 113 | } |
122 | 114 | ||
123 | bb_xioctl(fd,FDFMTEND,NULL,"FDFMTEND"); | 115 | xioctl(fd,FDFMTEND,NULL,"FDFMTEND"); |
124 | print_and_flush("done\n", NULL); | 116 | print_and_flush("done\n", NULL); |
125 | 117 | ||
126 | /* VERIFY */ | 118 | /* VERIFY */ |