home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / UZIUTILS.ARK / BD.C next >
Text File  |  1988-12-24  |  1KB  |  70 lines

  1.  
  2. /**************************************************
  3. UZI (Unix Z80 Implementation) Utilities:  bd.c
  4. ***************************************************/
  5.  
  6.  
  7. #include <stdio.h>
  8. #include "unix.h"
  9. #include "extern.h"
  10.  
  11. /* Block dump: to examine hard disk.
  12.  
  13. Usage:  bd dev blkno
  14.  
  15. ************************************************** */
  16.  
  17. char buf[512];
  18.  
  19. main(argc,argv)
  20. int argc;
  21. char *argv[];
  22. {
  23.     int i,j;
  24.     unsigned blkno;
  25.     int dev;
  26.  
  27.     if (argc != 3 || !isdigit(argv[1][0]))
  28.     {
  29.     fprintf(stderr,"Usage: bd device blkno\n");
  30.     exit(1);
  31.     }
  32.  
  33.     dev = atoi(argv[1]);
  34.     blkno = atoi(argv[2]);
  35.     bufinit();
  36.     d_open(dev);
  37.  
  38.     dread(dev,blkno,buf);
  39.  
  40.     for (i=0; i < 512/24; ++i)
  41.     {
  42.     printf("%4x  ",24*i);
  43.     for (j=0; j < 24; ++j)
  44.     {
  45.         if (( buf[24*i+j]&0x00ff) < 16)
  46.             printf("0%1x ",buf[24*i + j] & 0x00ff);
  47.         else
  48.             printf("%2x ",buf[24*i + j] & 0x00ff);
  49.     }
  50.     printf("\n");
  51.     }  
  52.     
  53.     exit(0);
  54. }
  55.  
  56.  
  57.  
  58. dread(dev, blk, addr)
  59. int dev;
  60. uint16 blk;
  61. char *addr;
  62. {
  63.     char *buf;
  64.     char *bread();
  65.  
  66.     buf = bread(dev, blk, 0);
  67.     bcopy(buf, addr, 512);
  68.     bfree(buf, 0);
  69. }
  70.