Warning ! None of the fields of the structure below must be modified directly. In this case, i can not tell how will behave the library. Unless specified, read access is of course allowed.
The dynamic memory allocation/releasing is done by the library (i hope :).
struct AdfDevice {
int devType; /* DEVTYPE_FLOPDD, DEVTYPE_FLOPHD or DEVTYPE_HARDDISK */
long size; /* size in bytes of the media. ADFlib is limited to 4Gb */
int nVol; /* number of partitions (volumes) */
struct adfVolume ** volList; /* volumes */
long cylinders, /* device geometry */
heads,
sectors;
BOOL isNativeDev;
void * nativeDev; /* native specific and private structure */
}
The Partition structure is used with adfCreateHd().
struct Partition{
long startCyl; /* starting cylinder of the usable space : should be 2 */
long lenCyl; /* length of this area, in cylinders */
char* volName; /* name of the volume, if any. Instead filled with 0. */
int volType; /* filesystem characteristics : use the flags FSMASK_FFS,
FSMASK_INTL and FSMASK_DIRCACHE */
}
adfMountDev()
adfUnMountDev()
adfCreateHd()
In case of a new ADF dump, adfCreateDumpDevice() must be called before to create an empty media of the right size.
An Harddisk ADF dump created with ADFlib -can not be- used back by the AmigaDOS, since some fields of the header structures are missing : they can not be automatically determined.
struct Partition part1;
struct Partition **partList;
/* Env init */
/* cyl = 2891, heads = 1, sectors = 68 */
struct AdfDevice * hd = adfCreateDumpDevice("newdev", 2891, 1, 68);
if (!hd) { /* cleanup and exit */ }
/* allocation of partlist[] */
/* the filesystem definition : size, FFS with DIRCACHE */
part1.startCyl = 2;
part1.lenCyl = 2889;
part1.volName = strdup("zip");
part1.volType = FSMASK_FFS | FSMASK_DIRCACHE;
partList[0] = &part1;
/* creates the filesystem */
RETCODE rc = adfCreateHd(hd,1,partList);
if (rc != RC_OK) { /* something wrong, cleaning up and exit */ }
/* freeing of partList[] and part1.volName */
/* device usage */
adfUnMountDev(hd);
/* Env cleanup */
adfCreateFlop()
In case of a new ADF dump, adfCreateDumpDevice() must be called before to create an empty media of the right size.
An Harddisk ADF dump created with ADFlib -can be- used back by the AmigaDOS.
struct AdfDevice *flop;
/* Env init */
/* creates a DD floppy empty dump */
/* cyl = 80, heads = 2, sectors = 11. HD floppies has 22 sectors */
flop = adfCreateDumpDevice("newdev", 80, 2, 11);
if (!flop) { /* cleanup and exit */ }
/* create the filesystem : OFS with DIRCACHE */
rc = adfCreateFlop( flop, "empty", FSMASK_DIRCACHE );
if (rc != RC_OK) { /* error : cleanup and exit() */
/* device usage */
adfUnMountDev(flop);
/* Env cleanup */
ADF only : adfCreateDumpDevice()