🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.dec
Article #1015

Re: LBN's versus head numbers,formula wanted

#1015
From: John T Kohl
Date: Wed, 13 Dec 1989 05:29
107 lines
3254 bytes
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!)
Technical Details
Message-ID: <JTKOHL.89Dec12212919@quicksilver.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!bloom-beacon.mit.edu!jtkohl
References: <1997.2583ab7e@esat.kuleuven.ac.be>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!bloom-beacon.mit.edu!jtkohl
From: jtkohl@quicksilver.mit.edu (John T Kohl)
Newsgroups: comp.sys.dec
Subject: Re: LBN's versus head numbers,formula wanted
Message-ID: <JTKOHL.89Dec12212919@quicksilver.mit.edu>
Date: 13 Dec 89 05:29:19 GMT
References: <1997.2583ab7e@esat.kuleuven.ac.be>
Sender: root@athena.mit.edu (Wizard A. Root)
Reply-To: jtkohl@athena.mit.edu
Organization: MIT Project Athena
Lines: 107
In-Reply-To: elsen@esat.kuleuven.ac.be's message of 11 Dec 89 13:28:30 GMT