home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
MISC
/
sector0.c
< prev
next >
Wrap
C/C++ Source or Header
|
2009-11-06
|
4KB
|
111 lines
/* sector0 - a utility to interpret the contents of sector0 of OS-9 disk */
/* written by Andrzej Kotanski, 1996, e-mail kotanski@desy.de */
#include <stdio.h>
#include <rbf.h>
#include <errno.h>
struct sector0 sec0;
struct rbf_opt opt;
main(argc, argv)
char **argv;
{
unsigned boot;
char name[33];
FILE *fp;
char device[20];
if ( argc !=2 )
exit(_errmsg(errno, "Usage: sector0 /device\n"));
strcpy(device, argv[1]);
strcat(device, "@");
fp = fopen(device, "r");
if ( fp == NULL )
exit(_errmsg(errno, "Cannot open '%s'\n", device));
if ( fread(&sec0, sizeof(struct sector0), 1, fp) == 0 )
exit(_errmsg(errno, "Cannot read sector 0\n"));
memcpy(&opt, sec0.dd_opt, 32);
printf("total sectors = %d, ", (sec0.dd_tot[0] << 16) +
(sec0.dd_tot[1] << 8) + sec0.dd_tot[2]);
printf("track size = %d\n", sec0.dd_tks);
printf("bytes in alloc map = %d = $%x, ", sec0.dd_map, sec0.dd_map);
printf("cluster size = %d\n", sec0.dd_bit);
printf("lsn of root dir = %x\n", (sec0.dd_dir[0] << 16) +
(sec0.dd_dir[1] << 8) + sec0.dd_dir[2]);
printf("disk owner = %d.%d\n", sec0.dd_own[0], sec0.dd_own[1]);
printf("disk attributes = %x, ", sec0.dd_att & 0xff);
printf("disk id = %x\n", sec0.dd_dsk);
printf("disk format = %x ", sec0.dd_fmt);
if (sec0.dd_fmt & FMT_DS)
printf("double-sided ");
if (sec0.dd_fmt & FMT_DD)
printf("double-density ");
if (sec0.dd_fmt & FMT_DT)
printf("double-track ");
if (sec0.dd_fmt & FMT_QT)
printf("quad-track ");
if (sec0.dd_fmt & FMT_OT)
printf("octal-track ");
printf("\n");
printf("sectors per track = %d\n", (sec0.dd_spt[0] <<8) + sec0.dd_spt[1]);
boot = (sec0.dd_bt[0] << 16) + (sec0.dd_bt[1] << 8) + sec0.dd_bt[2];
if ( sec0.dd_bsz ) {
printf("lsn of boot = %x\n", boot);
printf("boot size = %d\n", sec0.dd_bsz);
} else
printf("boot fd ptr = %x\n", boot);
printf("creation date = %d/%02d/%02d %02d:%02d\n", sec0.dd_date[0] & 0xff,
sec0.dd_date[1] & 0xff, sec0.dd_date[2] & 0xff, sec0.dd_date[3] & 0xff,
sec0.dd_date[4] & 0xff);
if ( strlen(sec0.dd_name) == 0 )
name[0] = 0;
else
strhcpy(name, sec0.dd_name);
printf("volume name = %s\n", name);
printf("integrity code: %s\n", sec0.dd_sync);
if ( sec0.dd_maplsn )
printf("bitmap starting lsn = %x\n", sec0.dd_maplsn);
if ( sec0.dd_lsnsize == 0 )
sec0.dd_lsnsize = 256;
printf("sector size = %d\n", sec0.dd_lsnsize);
printf("sector 0 version ID = %x\n", sec0.dd_versid);
printf("drive number = %d\n", opt.pd_drv);
printf("step rate = %d\n", opt.pd_stp);
printf("disk type: %x ", opt.pd_typ);
if ( opt.pd_typ & TYP_HARD )
printf("hard ");
if ( opt.pd_typ & TYP_DDTRK0 )
printf("DD track 0 ");
if ( opt.pd_typ & TYP_OLD ) {
printf(" old type floppy ");
if ( opt.pd_typ & TYP_SIZ8 )
printf("8\" ");
if ( opt.pd_typ & TYP_SIZ5 )
printf("5.25\" ");
if ( opt.pd_typ & TYP_SIZ3 )
printf("3.5\" ");
}
printf("\n");
printf("density: %x ", opt.pd_dns);
if ( opt.pd_dns & DNS_DD )
printf("double ");
if ( opt.pd_dns & DNS_DT )
printf("double track ");
if ( opt.pd_dns & DNS_QT )
printf("quad track ");
if ( opt.pd_dns & DNS_OT )
printf("octal track ");
printf("\n");
printf("track base = %d sector base %d\n", opt.pd_toffs, opt.pd_soffs);
printf("sector size = %d\n", opt.pd_ssize);
printf("control word = %x\n", opt.pd_cntl);
}