diff -c -r fdformat/fdformat.1 fdformat.new/fdformat.1 *** fdformat/fdformat.1 Mon Nov 29 18:45:25 1999 --- fdformat.new/fdformat.1 Mon Nov 29 18:49:00 1999 *************** *** 34,39 **** --- 34,40 ---- .Nm fdformat .Op Fl q .Op Fl v | Fl n + .Op Fl l Ar tracklist .Op Fl f Ar capacity .Op Fl c Ar cyls .Op Fl s Ar secs *************** *** 73,78 **** --- 74,86 ---- Suppress any normal output from the command, and don't ask the user for a confirmation whether to format the floppy disk at .Ar device_name . + .It Fl l Ar tracklist + give a list of tracks to be formatted or verified. The + .Ar tracklist + is given as a comma seperated list of track numbers or track ranges. + A track range is a pair of track numbers seperated by a '-' character. + The second number has to b equal or larger than the first one. Track + numbers start with 0. .It Fl f Ar capacity The normal way to specify the desired formatting parameters. .Ar Capacity Only in fdformat.new: fdformat.1.gz diff -c -r fdformat/fdformat.c fdformat.new/fdformat.c *** fdformat/fdformat.c Mon Nov 29 18:45:25 1999 --- fdformat.new/fdformat.c Mon Nov 29 18:59:35 1999 *************** *** 138,144 **** usage (void) { fprintf(stderr, "%s\n%s\n", ! "usage: fdformat [-q] [-n | -v] [-f #] [-c #] [-s #] [-h #]", " [-r #] [-g #] [-i #] [-S #] [-F #] [-t #] devname"); exit(2); } --- 138,144 ---- usage (void) { fprintf(stderr, "%s\n%s\n", ! "usage: fdformat [-q] [-n | -v] [ -l tracklist ] [-f #] [-c #] [-s #] [-h #]", " [-r #] [-g #] [-i #] [-S #] [-F #] [-t #] devname"); exit(2); } *************** *** 163,168 **** --- 163,211 ---- } } + void + parse_list(char *list, char *track_list, int max) { + while (*list) { + long n; + char *nl= list; + while (isspace(*nl)) + nl++; + n= strtol(list, &nl, 0); + if (nl == list) { + errx(1, "cannot parse track list"); + } + if (n >= max) { + errx(1, "there is no track %ld", n); + } + while (isspace(*nl)) + nl++; + if (*nl == ',' || *nl == '\0') { + track_list[n]= 1; + if (*nl == ',') + list= nl+1; + else + list= nl; + } + else if (*nl == '-') { + long m; + char *ml= nl+1; + m= strtol(ml, &ml, 0); + if (ml == nl+1 || m < n || m >= max) { + errx(1, "invalid track range"); + } + while (n<=m) { + track_list[n]= 1; + n++; + } + list= nl+1; + } + else { + errx(1, "invalid list seperator: `%c'.\n", *nl); + } + } + } + + int main(int argc, char **argv) { *************** *** 172,180 **** int fd, c, track, error, tracks_per_dot, bytes_per_track, errs; const char *devname, *suffix; struct fd_type fdt; ! while((c = getopt(argc, argv, "f:c:s:h:r:g:S:F:t:i:qvn")) != -1) switch(c) { case 'f': /* format in kilobytes */ format = atoi(optarg); break; --- 215,228 ---- int fd, c, track, error, tracks_per_dot, bytes_per_track, errs; const char *devname, *suffix; struct fd_type fdt; + char *tl_arg, track_list[200]; ! tl_arg= 0; ! while((c = getopt(argc, argv, "f:l:c:s:h:r:g:S:F:t:i:qvn")) != -1) switch(c) { + case 'l': /* list of tracks to operate on */ + tl_arg= optarg; + break; case 'f': /* format in kilobytes */ format = atoi(optarg); break; *************** *** 279,284 **** --- 327,340 ---- bytes_per_track = fdt.sectrac * (1<