back to fun with pread.c

Well I know this topic keeps comming up over & over that the pread.c that I had used to build my Xenix on Qemu is long lost.

Anyways someone else was asking me for it, and I stumbled accross this Microsoft Memo:

http://support.microsoft.com/kb/100027

which means the device name I was listing was wrong… I’m unsure if it means in 2003 it change from what it was since 1991….

Anyways here is my new ‘pread’.

#include <stdio.h>

#define BUFFSIZE 1024*1024

void main(void)
{
FILE *disk;
FILE *ofile;
int disknumber;
char fname[255];
char oname[255];
char *buffer;
int rc;
int pass;

buffer=(char*)malloc(BUFFSIZE);
if(buffer==(char*)NULL)
{printf(“\nError allocating buffer!!\n”);return;}

printf(“please tell me the disk NUMBER that you want to read\n”);
printf(“for \\\\.\\PhysicalDrive1 just answer 1\n\n:”);

memset(fname,0x0,sizeof(fname));
scanf(“%d”,&disknumber);
sprintf(fname,”\\\\.\\PhysicalDrive%d”,disknumber);
printf(“reading the device %s\n”,fname);

disk=fopen(fname,”rb”);
memset(oname,0x0,sizeof(oname));

printf(“\nWhat is the output file name?\n\n:”);
scanf(“%s”,oname);
ofile=fopen(oname,”wb”);

if(ofile==NULL){printf(“\n\nERROR with %s\n”,oname);return;}
if(disk==NULL){printf(“\n\nERROR with disk %s\n”,fname);return;}

rc=5;
pass = 0;
while(rc!=0)
{
memset(buffer,0x0,sizeof(buffer));
rc=fread(buffer,1,BUFFSIZE,disk);
printf(“\r%d\t%d:Megabytes processed”,rc,pass);
fwrite(buffer,1,rc,ofile);
pass++;
}
fclose(disk);
fclose(ofile);
printf(“\n\n\nDone!%c”,7);
}

This entry was posted in qemu, xenix by neozeed. Bookmark the permalink.
avatar

About neozeed

What is there to tell? I’ve loved UNIX like things since I was first exposed to QNX in highschool (we had the Unisys ICONS!), and spent the better time of my teenage years trying to get my own UNIX… I should have bought Coherent in retrospect.. Anyways latched onto Linux in 1992, and then got some old BSD admin books and have been hooked on the VAX BSD & other big/ancient things since…!

3 thoughts on “back to fun with pread.c

Leave a Reply

Your email address will not be published.

Notify me of followup comments via e-mail. You can also subscribe without commenting.