home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume15
/
upm
/
part01
/
makedrive.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-17
|
1KB
|
56 lines
/*
makedrive.c - creates a "drive device" file for CP/M - really a file
with a size a multiple of 2K and more than 128K, with the first 16K
filled with $E5, and a hole for the rest up to the EOF. This creates
a file that takes up 16K on disk, but has a huge EOF. Under CP/M, the
EOF of a "drive device" file defines its size, which (of course)
doesn't change.
*/
#include <stdio.h>
extern int errno;
extern char *sys_errlist[];
usage(name)
char *name;
{
printf("Usage: %s [size] [filename]\n\n",name);
printf("size is in K-bytes and must be an even number 128 or greater.\n\n");
exit(1);
}
main(argc,argv)
int argc;
char **argv;
{
int size,i;
FILE *f;
if (argc!=3)
usage(*argv);
size=atoi(argv[1]);
if (size<128 || size%2)
usage(*argv);
f=fopen(argv[2],"w");
if (f==NULL)
{
printf("%s: %s - %s\n",*argv,argv[2],sys_errlist[errno]);
exit(1);
}
for (i=0;i<16384*4;i++) /* write out a blank directory */
putc(0xE5,f);
fseek(f,(long)(1024*size-1),0); /* make a big hole */
putc(0xE5,f);
fclose(f);
}