diff options
-rw-r--r-- | util-linux/fdformat.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c index 63ec2204d..efbdcc8fe 100644 --- a/util-linux/fdformat.c +++ b/util-linux/fdformat.c | |||
@@ -45,16 +45,6 @@ struct format_descr { | |||
45 | #define FDGETPRM _IOR(2, 0x04, struct floppy_struct) | 45 | #define FDGETPRM _IOR(2, 0x04, struct floppy_struct) |
46 | #define FD_FILL_BYTE 0xF6 /* format fill byte. */ | 46 | #define FD_FILL_BYTE 0xF6 /* format fill byte. */ |
47 | 47 | ||
48 | static void print_and_flush(const char * __restrict format, ...) | ||
49 | { | ||
50 | va_list arg; | ||
51 | |||
52 | va_start(arg, format); | ||
53 | bb_vfprintf(stdout, format, arg); | ||
54 | va_end(arg); | ||
55 | xfflush_stdout(); | ||
56 | } | ||
57 | |||
58 | static void xioctl(int fd, int request, void *argp, const char *string) | 48 | static void xioctl(int fd, int request, void *argp, const char *string) |
59 | { | 49 | { |
60 | if (ioctl (fd, request, argp) < 0) { | 50 | if (ioctl (fd, request, argp) < 0) { |
@@ -91,12 +81,12 @@ int fdformat_main(int argc,char **argv) | |||
91 | 81 | ||
92 | xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */ | 82 | xioctl(fd, FDGETPRM, ¶m, "FDGETPRM");/*original message was: "Could not determine current format type" */ |
93 | 83 | ||
94 | print_and_flush("%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", | 84 | printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", |
95 | (param.head == 2) ? "Double" : "Single", | 85 | (param.head == 2) ? "Double" : "Single", |
96 | param.track, param.sect, param.size >> 1); | 86 | param.track, param.sect, param.size >> 1); |
97 | 87 | ||
98 | /* FORMAT */ | 88 | /* FORMAT */ |
99 | print_and_flush("Formatting ... ", NULL); | 89 | printf("Formatting ... "); |
100 | xioctl(fd, FDFMTBEG,NULL,"FDFMTBEG"); | 90 | xioctl(fd, FDFMTBEG,NULL,"FDFMTBEG"); |
101 | 91 | ||
102 | /* n == track */ | 92 | /* n == track */ |
@@ -105,7 +95,7 @@ int fdformat_main(int argc,char **argv) | |||
105 | descr.head = 0; | 95 | descr.head = 0; |
106 | descr.track = n; | 96 | descr.track = n; |
107 | xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); | 97 | xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); |
108 | print_and_flush("%3d\b\b\b", n); | 98 | printf("%3d\b\b\b", n); |
109 | if (param.head == 2) { | 99 | if (param.head == 2) { |
110 | descr.head = 1; | 100 | descr.head = 1; |
111 | xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); | 101 | xioctl(fd, FDFMTTRK,&descr,"FDFMTTRK"); |
@@ -113,7 +103,7 @@ int fdformat_main(int argc,char **argv) | |||
113 | } | 103 | } |
114 | 104 | ||
115 | xioctl(fd,FDFMTEND,NULL,"FDFMTEND"); | 105 | xioctl(fd,FDFMTEND,NULL,"FDFMTEND"); |
116 | print_and_flush("done\n", NULL); | 106 | printf("done\n"); |
117 | 107 | ||
118 | /* VERIFY */ | 108 | /* VERIFY */ |
119 | if(verify) { | 109 | if(verify) { |
@@ -121,9 +111,9 @@ int fdformat_main(int argc,char **argv) | |||
121 | n = param.sect*param.head*512; | 111 | n = param.sect*param.head*512; |
122 | 112 | ||
123 | data = xmalloc(n); | 113 | data = xmalloc(n); |
124 | print_and_flush("Verifying ... ", NULL); | 114 | printf("Verifying ... "); |
125 | for (cyl = 0; cyl < param.track; cyl++) { | 115 | for (cyl = 0; cyl < param.track; cyl++) { |
126 | print_and_flush("%3d\b\b\b", cyl); | 116 | printf("%3d\b\b\b", cyl); |
127 | if((read_bytes = safe_read(fd,data,n))!= n ) { | 117 | if((read_bytes = safe_read(fd,data,n))!= n ) { |
128 | if(read_bytes < 0) { | 118 | if(read_bytes < 0) { |
129 | bb_perror_msg(bb_msg_read_error); | 119 | bb_perror_msg(bb_msg_read_error); |
@@ -133,7 +123,7 @@ int fdformat_main(int argc,char **argv) | |||
133 | /* Check backwards so we don't need a counter */ | 123 | /* Check backwards so we don't need a counter */ |
134 | while(--read_bytes>=0) { | 124 | while(--read_bytes>=0) { |
135 | if( data[read_bytes] != FD_FILL_BYTE) { | 125 | if( data[read_bytes] != FD_FILL_BYTE) { |
136 | print_and_flush("bad data in cyl %d\nContinuing ... ",cyl); | 126 | printf("bad data in cyl %d\nContinuing ... ",cyl); |
137 | } | 127 | } |
138 | } | 128 | } |
139 | } | 129 | } |
@@ -143,7 +133,7 @@ int fdformat_main(int argc,char **argv) | |||
143 | 133 | ||
144 | if (ENABLE_FEATURE_CLEAN_UP) free(data); | 134 | if (ENABLE_FEATURE_CLEAN_UP) free(data); |
145 | 135 | ||
146 | print_and_flush("done\n", NULL); | 136 | printf("done\n"); |
147 | } | 137 | } |
148 | 138 | ||
149 | if (ENABLE_FEATURE_CLEAN_UP) close(fd); | 139 | if (ENABLE_FEATURE_CLEAN_UP) close(fd); |