Date: Mon, 29 Nov 1999 19:26:53 +0100 (CET) From: Elmar.Bartel@informatik.tu-muenchen.de To: FreeBSD-gnats-submit@freebsd.org Subject: misc/15168: Adding tracklist support to fdformat Message-ID: <199911291826.TAA44254@bsdsystem1.informatik.tu-muenchen.de>
next in thread | raw e-mail | index | archive | help
>Number: 15168
>Category: misc
>Synopsis: Adding tracklist support to fdformat
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Nov 29 10:30:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: Elmar Bartel
>Release: FreeBSD 3.[*]-RELEASE i386
>Organization:
Technische Universitaet Muenchen, Fakultaet fuer Informatik
>Environment:
Any FreeBSD 3.* version should work.
>Description:
Added track list support to fdformat. This way its possible
to specify an arbitrary list of tracks to operate on.
The patch is against the head revision of FreeBSD-current.
>How-To-Repeat:
Nothing to repeat.
>Fix:
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<<fdt.secsize) * 128;
tracks_per_dot = fdt.tracks * fdt.heads / 40;
+ if (tl_arg) {
+ memset(track_list, 0, sizeof(track_list));
+ parse_list(tl_arg, track_list, fdt.tracks*fdt.heads);
+ }
+ else {
+ memset(track_list, 1, sizeof(track_list));
+ }
+
if (verify_only) {
if(!quiet)
printf("Verify %dK floppy `%s'.\n",
***************
*** 307,312 ****
--- 363,375 ----
error = errs = 0;
for (track = 0; track < fdt.tracks * fdt.heads; track++) {
+ if (!track_list[track]) {
+ if(!quiet && !((track + 1) % tracks_per_dot)) {
+ putchar('.');
+ fflush(stdout);
+ }
+ continue;
+ }
if (!verify_only) {
format_track(fd, track / fdt.heads, fdt.sectrac,
track % fdt.heads, fdt.trans, fdt.f_gap,
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911291826.TAA44254>
