Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Device problems
@ 1997-10-01  4:00 Calyx UK Development
  0 siblings, 0 replies; only message in thread
From: Calyx UK Development @ 1997-10-01  4:00 UTC (permalink / raw)




I am having a few problems accessing a Digital TSZ07 tape drive
connected to an AlphaServer 1000 running DEC UNIX 4.0. It is being
accessed using low level UNIX system calls i.e. open, close and ioctl.

A simple example would be :-

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mtio.h>
#include <sys/ioctl.h>
#include <sys/devio.h>
#include <sys/ioctl_compat.h>
#include <stdlib.h>
#include <string.h>

int main ( int argc , char **argv )
{
  char deviceId[256] , errStr[256];
  int deviceFd;
  int result , error;
  struct mtop tapeCmd;
  struct devget tapeStatus;

  strcpy( deviceId , "/dev/rmt1h" );

  deviceFd = open( deviceId , O_RDWR | O_SYNC , 0666 );
  if ( deviceFd < 0 )
  {
    printf( "Failed to open tape device : %s\n", deviceId );
    error = errno;
    printf( "TapeIo Error - errno : %d : %s\n", error, strerror(error));
    return (-1);
  }

  printf( "Getting Tape drive status :-\n\n");

  result = ioctl( deviceFd , DEVIOCGET , &tapeStatus );
  if ( result == -1 )
  {
    error = errno;
    printf( "TapeIo Error - errno : %d : %s\n", error, strerror(error));
  }
  else
  {
    printf( "Status is %ld\n", tapeStatus.stat );
  }

  close ( deviceFd );

  return (1);
}

This program works fine provided that the tape drive is online, but if
the tape drive is offline the program fails on the open statement, which
is not much use if you wish to obtain the current status of the tape
drive from within a program.

If an 'mt' command is issued e.g.

mt -f /dev/rmt1h status <CR>

this will acually return information telling you that the tape drive is
offline. Can anyone explain what is happening here.

MTIA

Tim
Calyx UK Development



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-10-01  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-10-01  4:00 Device problems Calyx UK Development

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