
/*
 * Copyright 1987 Alan Kent
 *
 * Permission is granted to redistribute this code as long
 * as this message is retained in the code and the code is
 * not sold without written permission from the author.
 *
 * UUCP: {seismo,hplabs,mcvax,ukc,nttlab}!munnari!goanna.oz!ajk
 * ACSnet: ajk@goanna.oz
 * ARPA: munnari!goanna.oz!ajk@SEISMO.ARPA
 */

#include "hd.h"


BOOL
calc ( ior , posn , num_secs )
register struct IOStdReq *ior;
register struct posn *posn;
LONG *num_secs;
{
	if (  ior->io_Offset < 0
	||    ior->io_Length < 0
	||  ( ior->io_Offset % HD_SECTOR ) != 0
	||  ( ior->io_Length % HD_SECTOR ) != 0 ) {
		ior->io_Error = TDERR_NotSpecified;
		return ( FALSE );
	}
	posn->block = ior->io_Offset / HD_SECTOR;
	posn->sector = posn->block % first.sectors;
	posn->surface = ( posn->block / first.sectors ) % first.heads;
	posn->cylinder = posn->block / ( first.sectors * first.heads );
	*num_secs = ior->io_Length / HD_SECTOR;
	if ( posn->cylinder >= first.cylinders ) {
		ior->io_Error = TDERR_NotSpecified;
		return ( FALSE );
	}
	return ( TRUE );
}
