mirror of
https://github.com/gryf/ADFlib.git
synced 2026-02-07 08:45:55 +01:00
92 lines
1.6 KiB
C
92 lines
1.6 KiB
C
/*
|
|
* hd_test.c
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include"adflib.h"
|
|
|
|
|
|
void MyVer(char *msg)
|
|
{
|
|
fprintf(stderr,"Verbose [%s]\n",msg);
|
|
}
|
|
|
|
|
|
/*
|
|
*
|
|
*
|
|
*/
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct Device *hd;
|
|
struct Volume *vol;
|
|
FILE* boot;
|
|
unsigned char bootcode[1024];
|
|
|
|
adfEnvInitDefault();
|
|
|
|
// adfSetEnvFct(0,0,MyVer,0);
|
|
|
|
/* mount existing device */
|
|
hd = adfMountDev( argv[1],FALSE );
|
|
if (!hd) {
|
|
fprintf(stderr, "can't mount device\n");
|
|
adfEnvCleanUp(); exit(1);
|
|
}
|
|
|
|
vol = adfMount(hd, 0, FALSE);
|
|
if (!vol) {
|
|
adfUnMountDev(hd);
|
|
fprintf(stderr, "can't mount volume\n");
|
|
adfEnvCleanUp(); exit(1);
|
|
}
|
|
|
|
adfVolumeInfo(vol);
|
|
|
|
adfUnMount(vol);
|
|
adfUnMountDev(hd);
|
|
|
|
putchar('\n');
|
|
|
|
/* create and mount one device */
|
|
hd = adfCreateDumpDevice("newdev", 80, 2, 11);
|
|
if (!hd) {
|
|
fprintf(stderr, "can't mount device\n");
|
|
adfEnvCleanUp(); exit(1);
|
|
}
|
|
|
|
adfDeviceInfo(hd);
|
|
|
|
adfCreateFlop( hd, "empty", FSMASK_FFS|FSMASK_DIRCACHE );
|
|
|
|
vol = adfMount(hd, 0, FALSE);
|
|
if (!vol) {
|
|
adfUnMountDev(hd);
|
|
fprintf(stderr, "can't mount volume\n");
|
|
adfEnvCleanUp(); exit(1);
|
|
}
|
|
|
|
boot=fopen(argv[2],"rb");
|
|
if (!boot) {
|
|
adfUnMountDev(hd);
|
|
fprintf(stderr, "can't mount volume\n");
|
|
adfEnvCleanUp(); exit(1);
|
|
}
|
|
fread(bootcode, sizeof(unsigned char), 1024, boot);
|
|
adfInstallBootBlock(vol, bootcode);
|
|
fclose(boot);
|
|
|
|
adfVolumeInfo(vol);
|
|
|
|
adfUnMount(vol);
|
|
adfUnMountDev(hd);
|
|
|
|
adfEnvCleanUp();
|
|
|
|
return 0;
|
|
}
|