Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: jtkohl@quicksilver.mit.edu (John T Kohl)
Subject: Re: LBN's versus head numbers,formula wanted
Date: 13 Dec 89 05:29:19 GMT	[thread overview]
Message-ID: <JTKOHL.89Dec12212919@quicksilver.mit.edu> (raw)
In-Reply-To: elsen@esat.kuleuven.ac.be's message of 11 Dec 89 13:28:30 GMT

Here's a program which reads LBN's from a Unix/Ultrix message file, and
translates to cylinder, etc.  This one knows about ra80's and ra81's; if
you get an RA90 user's manual, it should have the appropriate geometry
info you need to wire into this program.

I got this from someone else at MIT, who got it from someone else...
insert standard disclaimer.

#include <stdio.h>

#define LINESIZE 132	/* Maximum number of characters on a line */

main(argc,argv)
int argc;
char *argv[];
{
    char line[LINESIZE], *fgets(), *lineptr, *findstring();
    long blocknumber;
    FILE *infile;
    int nscyl, nstrk, nblk = -1;

    if (argc != 4) {
	fprintf(stderr, "Usage: %s drive_type drive_name log_file\n", argv[0]);
	exit(-1);
    }

    if (!strcmp(argv[1], "ra81")) {
	nscyl = 714;
	nstrk = 51;
	nblk = 891072;
    } else if (!strcmp(argv[1], "ra80")) {
	nscyl = 434;
	nstrk = 31;
	nblk = 242606;
    } else if (!strcmp(argv[1], "ra60")) {
	nscyl = 168;
	nstrk = 42;
	nblk = 400176;
    }

    if (nblk == -1) {
	fprintf(stderr, "%s: unknown drive type %s\n", argv[0], argv[1]);
	exit(-1);
    }

    if ((infile = fopen(argv[3], "r")) == NULL) {
	fprintf(stderr, "%s: Can't open %s\n", argv[0], argv[3]);
	exit(-1);
    }
    
    while (fgets(line, LINESIZE, infile) != NULL){
	/* Look for a line with the drive name and "hdr" on it */
	if ((findstring(argv[2], line) == NULL) ||
	    (lineptr = findstring("hdr 0x", line)) == NULL)
	    continue;

	/* Get the block number */
    	sscanf(lineptr, "%X", &blocknumber);
    	hdr(blocknumber, nscyl, nstrk, nblk);
    }
}

char *findstring(substring, string)
register char *substring, *string;
{
    register char *ptr;
    int match;

    for ( ; *string != '\0'; string++) {
	match = 1;
	for (ptr = substring; *ptr != '\0'; ptr++, string++) {
	    if (*ptr != *string){
		match = 0;
		break;
	    }
	}
	if (match)
	    return (string);
    }
    return (NULL);
}

hdr(blocknumber, nscyl, nstrk,nb)
long blocknumber;
int nscyl;
int nstrk;
int nb;
{
    long cyl;
    long trk;
    long sec;

    printf("hdr: %6D", blocknumber);
    if (blocknumber >=0 && blocknumber <=nb) {
	cyl = blocknumber / nscyl;
	trk = (blocknumber - (cyl * nscyl)) / nstrk;
	sec = blocknumber - (cyl * nscyl) - (trk * nstrk);
	
	printf(" cyl: %4D trk: %2D sec: %2D\n", cyl, trk, sec);
    }
    else printf(" Illegal blocknumber\n");
}

--
John Kohl <jtkohl@ATHENA.MIT.EDU> or <jtkohl@Kolvir.Brookline.MA.US>
Digital Equipment Corporation/Project Athena
(The above opinions are MINE.  Don't put my words in somebody else's mouth!)


      reply	other threads:[~1989-12-13  5:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1989-12-11 13:28 LBN's versus head numbers,formula wanted elsen
1989-12-13  5:29 ` John T Kohl [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox