#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#define LABMAX 33

extern int errno;

int main(int argc, char *argv[])
{
  int ifd, ix, err;
  char lbl[LABMAX] = "";

  if (argc != 2){
    fprintf(stderr,"%s - no device specified!\n",argv[0]);
    return 1;
    }

  if  ((ifd = open(argv[1],O_RDONLY)) == -1){    /* open the device */
    fprintf(stderr,"%s - device '%s' err:
%s\n",argv[0],argv[1],strerror(errno));
    return 1;
    }

  err = lseek(ifd,0x8028,SEEK_SET) == -1;    /* seek to the label */
  if (!err) err = (read(ifd,lbl,LABMAX - 1) == -1); /*  and try to read
it */
  if (err){
    fprintf(stderr,"%s - device '%s' err:
%s\n",argv[0],argv[1],strerror(errno));
    return 1;
    }

  for (ix=0; ix < LABMAX; ix++)            /* trim trailing blanks */
    if (lbl[ix] == '  '){                                   /* that's a
single blank between the quotes */
      lbl[ix] = '\0';
      break;
      }

  if ((int) *lbl == '\0'){                /* no label? - bad! */
    fprintf(stderr,"%s - device '%s' err: no label
found!\n",argv[0],argv[1]);
    return 1;
    }

  puts(lbl);
  return 0;

}
