From owner-freebsd-bugs Mon Nov 29 10:30:14 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 4DA0E1500D for ; Mon, 29 Nov 1999 10:30:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id KAA32700; Mon, 29 Nov 1999 10:30:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from bsdsystem1.informatik.tu-muenchen.de (bsdsystem1.informatik.tu-muenchen.de [131.159.0.63]) by hub.freebsd.org (Postfix) with ESMTP id 5868B14A19 for ; Mon, 29 Nov 1999 10:26:53 -0800 (PST) (envelope-from bartel@bsdsystem1.informatik.tu-muenchen.de) Received: (from bartel@localhost) by bsdsystem1.informatik.tu-muenchen.de (8.9.3/8.9.3) id TAA44254; Mon, 29 Nov 1999 19:26:53 +0100 (CET) (envelope-from bartel) Message-Id: <199911291826.TAA44254@bsdsystem1.informatik.tu-muenchen.de> Date: Mon, 29 Nov 1999 19:26:53 +0100 (CET) From: Elmar.Bartel@informatik.tu-muenchen.de Reply-To: Elmar.Bartel@informatik.tu-muenchen.de To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: misc/15168: Adding tracklist support to fdformat Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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<Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message