STDMETHODIMP CDisk::xwrite(IGeometry *g, VARIANT *buf, long cylinder, short head, long cyl_expected, short head_expected, /*[in]*/ short sector,long sector_len, short deleted) { HRESULT hr; DSK_GEOMETRY geom; unsigned char *pData; g_to_dg(g, &geom); hr = GetBuffer(buf, &pData, sector_len); if (FAILED(hr)) return hr; hr = MapError(dsk_xwrite(m_driver, &geom, pData, cylinder, head, cyl_expected, head_expected, sector, sector_len, deleted)); dsk_free(pData); return hr; }
int main(int argc, char *argv[]) { FILE *fp; struct disk_side *sides, *curr_side; struct disk_track *curr_track; struct disk_sector *curr_sector; DSK_GEOMETRY geom; DSK_PDRIVER newdisk; DSK_FORMAT *format; dsk_err_t err; int i; char *secdata; if (argc != 3) { fprintf(stderr, "usage: %s infile outfile\n", argv[0]); exit(1); } fp = fopen(argv[1], "r"); if (fp == NULL) { fprintf(stderr, "unable to open file: %s\n", argv[1]); exit(1); } sides = parse_image(fp); memset(&geom, 0, sizeof(DSK_GEOMETRY)); geom.dg_cylinders = max_tracks; geom.dg_heads = max_sides; geom.dg_sectors = max_sectors; geom.dg_secbase = 1; /* perhaps this should be determined from file? */ geom.dg_secsize = sector_size; format = malloc(geom.dg_sectors*sizeof(DSK_FORMAT)); secdata = malloc(geom.dg_secsize); if ((format == NULL) || (secdata == NULL)) { fprintf(stderr, "main: out of memory\n"); exit(1); } if (dsk_creat(&newdisk, argv[2], "dsk", NULL) != DSK_ERR_OK) { fprintf(stderr, "main: error in dsk_creat\n"); exit(1); } for (i=0; i<max_sides; i++) if (dsk_apform(newdisk, &geom, 0, i, 0xE5) != DSK_ERR_OK) { fprintf(stderr, "main: error formatting inital cylinder\n"); exit(1); } curr_side = sides; while (curr_side != NULL) { /* printf("Side = %i\n", curr_side->id); */ curr_track = curr_side->tracks; while (curr_track != NULL) { /*printf(" Track = %i\n", curr_track->id); */ curr_sector = curr_track->sectors; i = 0; while (curr_sector != NULL) { /* printf(" Sector = %i\n", curr_sector->id);*/ format[i].fmt_cylinder = curr_sector->logical_track; format[i].fmt_head = curr_sector->logical_side; format[i].fmt_sector = curr_sector->id; format[i].fmt_secsize = curr_sector->length; curr_sector = curr_sector->next; i++; } if ((err = dsk_pformat(newdisk, &geom, curr_track->id, curr_side->id, format, 0xE5)) != DSK_ERR_OK) { fprintf(stderr, "main: error in dsk_pformat(%i)\n", err); exit(1); } curr_sector = curr_track->sectors; while (curr_sector != NULL) { fseek(fp, curr_sector->ofs, SEEK_SET); if (fread(secdata, 1, curr_sector->length, fp) != curr_sector->length) { fprintf(stderr, "main: error reading input file sector\n"); exit(1); } if ((err = dsk_xwrite(newdisk, &geom, secdata, curr_track->id, curr_side->id, curr_sector->logical_track, curr_sector->logical_side, curr_sector->id, curr_sector->length, 0)) != DSK_ERR_OK) { fprintf(stderr, "main: error in dsk_pwrite (%i, sec=%i, side=%i, track=%i) \n", err, curr_sector->id, curr_sector->logical_side, curr_sector->logical_track); exit(1); } curr_sector = curr_sector->next; } curr_track = curr_track->next; } curr_side = curr_side->next; } printf("Sides: %2i Tracks: %2i Sectors: %2i\n", max_sides, max_tracks, max_sectors); dsk_close(&newdisk); fclose(fp); return 0; }
/* Decode an RPC packet and execute it. * If nRefCount is nonzero, it is increased each time a dsk_open or dsk_creat * succeeds, and decreased when a dsk_close succeeds. This allows a server * program to terminate automatically when the reference count reaches 0. * * The only RPC codes that are currently obeyed are those sent by drvwin32.c * through rpccli.c */ LDPUBLIC32 dsk_err_t LDPUBLIC16 dsk_rpc_server(unsigned char *input, int inp_len, unsigned char *output, int *out_len, int *nRefCount) { dsk_err_t err, err2; int16 function; DSK_DRIVER *pDriver; DSK_GEOMETRY geom; DSK_FORMAT fmt, *pfmt; int32 nd, int1, int2, int3, int4, int5, int6, int7; int16 filler; char *str1, *str2, *str3; dsk_psect_t rcount; DSK_FORMAT *trkids; unsigned int nDriver, n; unsigned char secbuf[8192], *pbuf; unsigned char status; int deleted, value; int16 props[sizeof(DRV_CLASS)]; err = dsk_unpack_i16(&input, &inp_len, &function); if (err) return err; switch(function) { case RPC_DSK_OPEN: err = dsk_unpack_string(&input, &inp_len, &str1); if (err) return err; err = dsk_unpack_string(&input, &inp_len, &str2); if (err) return err; err = dsk_unpack_string(&input, &inp_len, &str3); if (err) return err; err2= dsk_open(&pDriver, str1, str2, str3); err = dsk_map_dtoi(pDriver, &nDriver); if (err) return err; err = dsk_pack_err (&output, out_len, err2); if (err) return err; err = dsk_pack_i32 (&output, out_len, nDriver); if (err) return err; if (nRefCount && err2 == DSK_ERR_OK) ++(*nRefCount); return DSK_ERR_OK; case RPC_DSK_CREAT: err = dsk_unpack_string(&input, &inp_len, &str1); if (err) return err; err = dsk_unpack_string(&input, &inp_len, &str2); if (err) return err; err = dsk_unpack_string(&input, &inp_len, &str3); if (err) return err; err2= dsk_creat(&pDriver, str1, str2, str3); err = dsk_map_dtoi(pDriver, &nDriver); if (err) return err; err = dsk_pack_err (&output, out_len, err2); if (err) return err; err = dsk_pack_i32 (&output, out_len, nDriver); if (err) return err; if (nRefCount && err2 == DSK_ERR_OK) ++(*nRefCount); return DSK_ERR_OK; case RPC_DSK_CLOSE: err = dsk_unpack_i32(&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_close(&pDriver); err = dsk_pack_err(&output, out_len, err2); if (err) return err; if (nRefCount) --(*nRefCount); return DSK_ERR_OK; case RPC_DSK_PREAD: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int3); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_pread(pDriver, &geom, secbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2, (dsk_psect_t)int3); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_bytes(&output, out_len, secbuf, geom.dg_secsize); if (err) return err; return DSK_ERR_OK; case RPC_DSK_PWRITE: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_bytes(&input, &inp_len, &pbuf); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int3); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_pwrite(pDriver, &geom, pbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2, (dsk_psect_t)int3); err = dsk_pack_err(&output, out_len, err2); if (err) return err; return DSK_ERR_OK; case RPC_DSK_PFORMAT: pfmt = (DSK_FORMAT *)secbuf; err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; for (n = 0; n < geom.dg_sectors; n++) { err = dsk_unpack_format(&input, &inp_len, &pfmt[n]); if (err) return err; } err = dsk_unpack_i16 (&input, &inp_len, &filler); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_pformat(pDriver, &geom, (dsk_pcyl_t)int1, (dsk_phead_t)int2, pfmt, (unsigned char)filler); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_geom(&output, out_len, &geom); if (err) return err; return DSK_ERR_OK; case RPC_DSK_PSECID: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_psecid(pDriver, &geom, (dsk_pcyl_t)int1, (dsk_phead_t)int2, &fmt); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_format(&output, out_len, &fmt); if (err) return err; return DSK_ERR_OK; case RPC_DSK_DRIVE_STATUS: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_drive_status(pDriver, &geom, (dsk_phead_t)int1, &status); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_i16(&output, out_len, status); if (err) return err; return DSK_ERR_OK; case RPC_DSK_GETGEOM: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_getgeom(pDriver, &geom); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_geom(&output, out_len, &geom); if (err) return err; return DSK_ERR_OK; case RPC_DSK_PSEEK: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_pseek(pDriver, &geom, (dsk_pcyl_t)int1, (dsk_phead_t)int2); err = dsk_pack_err(&output, out_len, err2); if (err) return err; return DSK_ERR_OK; case RPC_DSK_XREAD: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int3); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int4); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int5); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int6); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int7); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; deleted = int7; err2= dsk_xread(pDriver, &geom, secbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2, (dsk_pcyl_t)int3, (dsk_phead_t)int4, (dsk_psect_t)int5, (size_t)int6, &deleted); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_bytes(&output, out_len, secbuf, int6); if (err) return err; err = dsk_pack_i32(&output, out_len, deleted); return DSK_ERR_OK; case RPC_DSK_XWRITE: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_bytes(&input, &inp_len, &pbuf); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int3); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int4); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int5); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int6); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int7); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_xwrite(pDriver, &geom, pbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2, (dsk_pcyl_t)int3, (dsk_phead_t)int4, (dsk_psect_t)int5, (size_t)int6, (int)int7); err = dsk_pack_err(&output, out_len, err2); if (err) return err; return DSK_ERR_OK; case RPC_DSK_TRACKIDS: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2 = dsk_ptrackids(pDriver, &geom, int1, int2, &rcount, &trkids); if (err2 || !trkids) rcount = 0; err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_i32(&output, out_len, rcount); if (err) return err; for (n = 0; n < rcount; n++) { err = dsk_pack_format(&output, out_len, &trkids[n]); if (err) return err; } if (trkids) dsk_free(trkids); return DSK_ERR_OK; case RPC_DSK_PTREAD: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_ptread(pDriver, &geom, secbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_bytes(&output, out_len, secbuf, geom.dg_secsize * geom.dg_sectors); if (err) return err; return DSK_ERR_OK; case RPC_DSK_XTREAD: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int3); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int4); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_xtread(pDriver, &geom, secbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2, (dsk_pcyl_t)int3, (dsk_phead_t)int4); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_bytes(&output, out_len, secbuf, geom.dg_secsize * geom.dg_sectors); if (err) return err; return DSK_ERR_OK; case RPC_DSK_OPTION_ENUM: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_option_enum(pDriver, int1, &str1); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_string(&output, out_len, str1); if (err) return err; return DSK_ERR_OK; case RPC_DSK_OPTION_SET: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_string(&input, &inp_len, &str1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_set_option(pDriver, str1, int1); err = dsk_pack_err(&output, out_len, err2); if (err) return err; return DSK_ERR_OK; case RPC_DSK_OPTION_GET: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_string(&input, &inp_len, &str1); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_get_option(pDriver, str1, &value); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_i32 (&output, out_len, value); if (err) return err; return DSK_ERR_OK; case RPC_DSK_GETCOMMENT: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_get_comment(pDriver, &str1); err = dsk_pack_err(&output, out_len, err2); if (err) return err; err = dsk_pack_string(&output, out_len, str1); if (err) return err; return DSK_ERR_OK; case RPC_DSK_SETCOMMENT: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err = dsk_unpack_string(&input, &inp_len, &str1); if (err) return err; err2= dsk_set_comment(pDriver, str1); err = dsk_pack_err(&output, out_len, err2); if (err) return err; return DSK_ERR_OK; case RPC_DSK_RTREAD: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_unpack_geom(&input, &inp_len, &geom); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int1); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int2); if (err) return err; err = dsk_unpack_i32 (&input, &inp_len, &int3); if (err) return err; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; err2= dsk_rtread(pDriver, &geom, secbuf, (dsk_pcyl_t)int1, (dsk_phead_t)int2, int3); err = dsk_pack_err(&output, out_len, err2); if (err) return err; /* XXX This is a completely arbitrary buffer size */ err = dsk_pack_i32(&output, out_len, geom.dg_secsize * geom.dg_sectors); if (err) return err; err = dsk_pack_bytes(&output, out_len, secbuf, geom.dg_secsize * geom.dg_sectors); if (err) return err; return DSK_ERR_OK; /* Return a list of implemented functions */ case RPC_DSK_PROPERTIES: err = dsk_unpack_i32 (&input, &inp_len, &nd); if (err) return err; nDriver = (unsigned int)nd; err = dsk_map_itod(nDriver, &pDriver); if (err) return err; int1 = 0; /* Count of implemented functions */ #define PROPCHECK(func, rid) if (pDriver->dr_class->func) props[int1++] = rid; PROPCHECK(dc_open, RPC_DSK_OPEN) PROPCHECK(dc_creat, RPC_DSK_CREAT) PROPCHECK(dc_close, RPC_DSK_CLOSE) PROPCHECK(dc_read, RPC_DSK_PREAD) PROPCHECK(dc_write, RPC_DSK_PWRITE) PROPCHECK(dc_format, RPC_DSK_PFORMAT) PROPCHECK(dc_secid, RPC_DSK_PSECID) PROPCHECK(dc_getgeom, RPC_DSK_GETGEOM) PROPCHECK(dc_xseek, RPC_DSK_PSEEK) PROPCHECK(dc_status, RPC_DSK_DRIVE_STATUS) PROPCHECK(dc_xread, RPC_DSK_XREAD) PROPCHECK(dc_xwrite, RPC_DSK_XWRITE) PROPCHECK(dc_tread, RPC_DSK_PTREAD) PROPCHECK(dc_xtread, RPC_DSK_XTREAD) PROPCHECK(dc_option_enum, RPC_DSK_OPTION_ENUM) PROPCHECK(dc_option_get, RPC_DSK_OPTION_GET) PROPCHECK(dc_option_set, RPC_DSK_OPTION_SET) PROPCHECK(dc_trackids, RPC_DSK_TRACKIDS) PROPCHECK(dc_rtread, RPC_DSK_RTREAD) #undef PROPCHECK props[int1++] = RPC_DSK_PROPERTIES; err = dsk_pack_err(&output, out_len, DSK_ERR_OK); if (err) return err; err = dsk_pack_i16(&output, out_len, (unsigned short)int1); if (err) return err; for (int2 = 0; int2 < int1; int2++) { err = dsk_pack_i16(&output, out_len, props[int2]); if (err) return err; } err = dsk_pack_string(&output, out_len, pDriver->dr_class->dc_description); if (err) return err; return DSK_ERR_OK; /* Unsupported function. Return DSK_ERR_UNKRPC */ default: err2 = dsk_pack_err(&output, out_len, DSK_ERR_UNKRPC); return DSK_ERR_OK; } }
int do_test(char *outfile, char *outtyp, char *outcomp, int forcehead) { DSK_PDRIVER outdr = NULL; dsk_err_t e; DSK_GEOMETRY dg, dg2; static DSK_FORMAT fmt[9] = { { 0, 0, 1, 512 }, { 0, 0, 3, 512 }, { 3, 1, 5, 512 }, { 0, 0, 7, 512 }, { 0, 0, 9, 512 }, { 0, 1, 2, 512 }, { 0, 0, 4, 512 }, { 2, 0, 6, 512 }, { 0, 0, 8, 512 }, }; static DSK_FORMAT fmt2[9] = { { 4, 0, 1, 512 }, { 4, 0, 3, 512 }, { 4, 0, 5, 512 }, { 4, 0, 7, 512 }, { 4, 0, 9, 512 }, { 4, 0, 2, 512 }, { 4, 0, 4, 512 }, { 4, 0, 6, 512 }, { 4, 0, 8, 512 }, }; DSK_FORMAT secid, *pfmt; char *comment; unsigned char status; dsk_psect_t count, n; char *optname; int value; dsk_reportfunc_set(report, report_end); dg_stdformat(&dg, FMT_180K, NULL, NULL); if (t80) dg.dg_cylinders = 80; printf("Checking dsk_creat\n"); e = dsk_creat(&outdr, outfile, outtyp, outcomp); CHECKERR("dsk_creat") else { dsk_set_option(outdr, "REMOTE:TESTING", 1); printf("Checking set_comment\n"); e = dsk_set_comment(outdr, "Example comment"); CHECKERR3("dsk_set_comment"); printf("Checking pformat\n"); e = dsk_pformat(outdr, &dg, 0, 0, fmt, 0xE5); CHECKERR("dsk_pformat") printf("Checking apform\n"); e = dsk_apform(outdr, &dg, 1, 0, 0xF6); CHECKERR("dsk_apform") printf("Checking lformat\n"); e = dsk_lformat(outdr, &dg, 2, fmt2, 0xD4); CHECKERR("dsk_pformat") printf("Checking ptrackids\n"); e = dsk_ptrackids(outdr, &dg, 0, 0, &count, &pfmt); CHECKERR("dsk_ptrackids") else { dsk_psect_t n; printf("Cyl Head Sec Size\n"); printf("-----------------\n"); for (n = 0; n < count; n++) { printf("%3d %3d %3d %4d\n", pfmt[n].fmt_cylinder, pfmt[n].fmt_head, pfmt[n].fmt_sector, (int)pfmt[n].fmt_secsize); } printf("-----------------\n"); dsk_free(pfmt); } memset(secbuf, 0, sizeof(secbuf)); memcpy(secbuf, spec180, sizeof(spec180)); printf("Checking dsk_lwrite\n"); e = dsk_lwrite(outdr, &dg, secbuf, 0); CHECKERR("dsk_lwrite") strcpy((char *)secbuf, "Cyl=3 Head=1 Sec=5"); printf("Checking dsk_xwrite\n"); e = dsk_xwrite(outdr, &dg, secbuf, 0, 0, 3, 1, 5, 512, 0); CHECKERR("dsk_xwrite") printf("Checking dsk_psecid\n"); e = dsk_psecid(outdr, &dg, 1, 0, &secid); CHECKERR("dsk_psecid") else { printf("%3d %3d %3d %4d\n", secid.fmt_cylinder, secid.fmt_head, secid.fmt_sector, (int)secid.fmt_secsize); if (secid.fmt_cylinder != 1 || secid.fmt_head != 0 || secid.fmt_secsize != 512) { ++failures; printf("-- mismatch!\n"); } } } if (outdr) { dsk_close(&outdr); CHECKERR("dsk_close") } printf("Checking dsk_open\n"); e = dsk_open(&outdr, outfile, outtyp, outcomp); CHECKERR("dsk_open") else { dsk_set_option(outdr, "REMOTE:TESTING", 1); printf("Checking dsk_getgeom\n"); e = dsk_getgeom(outdr, &dg2); if (t80 && dg2.dg_cylinders == 40) dg2.dg_cylinders = 80; CHECKERR("dsk_getgeom") else if (memcmp(&dg, &dg2, sizeof(dg))) { ++failures; printf("-- mismatch!\n"); printf("Cyls: %3d %3d\n", dg.dg_cylinders, dg2.dg_cylinders); printf("Heads: %3d %3d\n", dg.dg_heads, dg2.dg_heads); printf("Secs: %3d %3d\n", dg.dg_sectors, dg2.dg_sectors); } printf("Checking dsk_lread\n"); e = dsk_lread(outdr, &dg, secbuf, 0); CHECKERR("dsk_lread") else if (memcmp(secbuf, spec180, sizeof(spec180))) { ++failures; printf("-- mismatch!\n"); } printf("Checking dsk_xread\n"); e = dsk_xread(outdr, &dg, secbuf, 0, 0, 3, 1, 5, 512, NULL); CHECKERR("dsk_xread") else if (strcmp((char *)secbuf, "Cyl=3 Head=1 Sec=5")) { ++failures; printf("-- mismatch!\n"); } printf("Checking dsk_lseek\n"); e = dsk_lseek(outdr, &dg, 1); CHECKERR("dsk_lseek") printf("Checking dsk_drive_status\n"); e = dsk_drive_status(outdr, &dg, 0, &status); CHECKERR("dsk_drive_status") else printf("-- status=0x%02x\n", status); printf("Checking dsk_tread\n"); e = dsk_ptread(outdr, &dg, trkbuf, 1, 0); CHECKERR("dsk_ptread") else { for (n = 0; n < 4608; n++) if (trkbuf[n] != 0xF6) { printf("-- mismatch!\n"); ++failures; break; } } printf("Checking dsk_xtread\n"); e = dsk_xtread(outdr, &dg, trkbuf, 2, 0, 4, 0); CHECKERR("dsk_xtread") else { for (n = 0; n < 4608; n++) if (trkbuf[n] != 0xD4) { printf("-- mismatch!\n"); ++failures; break; } } printf("Checking dsk_option_enum\n"); e = dsk_option_enum(outdr, 0, &optname); CHECKERR("dsk_option_enum") else { printf("-- first option is %s\n", optname); } if (!optname) optname = "dummy"; printf("Checking dsk_get_option(%s)\n", optname); e = dsk_get_option(outdr, optname, &value); CHECKERR2("dsk_get_option") else { printf("-- value=%d\n", value); } printf("Checking dsk_set_option(example, 2)\n"); e = dsk_set_option(outdr, "example", 2); CHECKERR2("dsk_set_option") printf("Checking dsk_rtread\n"); e = dsk_rtread(outdr, &dg, trkbuf, 0, 0, 0); CHECKERR3("dsk_rtread") printf("Checking dsk_get_comment\n"); e = dsk_get_comment(outdr, &comment); CHECKERR3("dsk_get_comment") else if (comment) printf("-- comment=%s\n", comment); } if (outdr) { dsk_close(&outdr); CHECKERR("dsk_close") } printf("\n"); printf("Failed calls (failure important): %2d\n", failures); printf("Failed calls (failure unimportant): %2d\n", warnings); printf("Unimplemented functions: %2d\n", unimpl); printf("Unimplemented functions over RPC: %2d\n", rpcunimp); return failures; }