/******************************************* Name : attemptAddDosVolume Descr.: adds a new volume to dos Input : volume - volume to add Output: DOSTRUE for success; DOSFALSE otherwise ********************************************/ LONG attemptAddDosVolume(struct AFSBase *afsbase, struct Volume *volume) { struct DosList *doslist; struct DosList *dl=NULL; char string[32]; BSTR bname; UBYTE i; if (volume->volumenode) { D(bug("[afs 0x%08lX] VolumeNode is already present!\n", volume)); return DOSTRUE; } bname = volume->devicelist.dl_Name; for (i=0; i<AROS_BSTR_strlen(bname); i++) string[i] = AROS_BSTR_getchar(bname,i); string[AROS_BSTR_strlen(bname)] = 0; D(bug("[afs 0x%08lX] Processing inserted volume %s\n", volume, string)); /* is the volume already in the list? */ doslist = AttemptLockDosList(LDF_WRITE | LDF_VOLUMES); if (doslist != NULL) { dl = FindDosEntry(doslist,string,LDF_VOLUMES); UnLockDosList(LDF_WRITE | LDF_VOLUMES); } else return TRUE; /* if not create a new doslist */ if (dl == NULL) { D(bug("[afs 0x%08lX] Creating new VolumeNode\n", volume)); doslist = MakeDosEntry(string,DLT_VOLUME); if (doslist == NULL) return DOSFALSE; doslist->dol_Task = &((struct Process *)FindTask(NULL))->pr_MsgPort; doslist->dol_misc.dol_volume.dol_VolumeDate.ds_Days = volume->devicelist.dl_VolumeDate.ds_Days; doslist->dol_misc.dol_volume.dol_VolumeDate.ds_Minute = volume->devicelist.dl_VolumeDate.ds_Minute; doslist->dol_misc.dol_volume.dol_VolumeDate.ds_Tick = volume->devicelist.dl_VolumeDate.ds_Tick; AddDosEntry(doslist); /* if we re-use "volume" clear locklist */ volume->locklist = NULL; dl = doslist; } volume->volumenode = dl; SendEvent(afsbase, IECLASS_DISKINSERTED); return DOSTRUE; }
static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR conbase) { static const char *devnames[2] = { "CON", "RAW" }; struct DeviceNode *dn; int i; /* Really bad hack, but con_handler is in ROM, intuition.library is open, if intuition.library is open, then Input.Device must be open, too, ... and I don't like to OpenDevice just for Peek- Qualifier */ #warning InputDevice open hack. Hope this is not a problem since it is only used for PeekQualifier Forbid(); conbase->inputbase = (struct Device *)FindName(&SysBase->DeviceList, "input.device"); Permit(); /* Install CON: and RAW: handlers into device list * * KLUDGE: con-handler should create only one device node, depending on * the startup packet it gets. The mountlists for CON:/RAW: should be into dos.library bootstrap * routines. */ for(i = 0; i < 2; i++) { if((dn = AllocMem(sizeof (struct DeviceNode) + 4 + AROS_BSTR_MEMSIZE4LEN(3), MEMF_CLEAR|MEMF_PUBLIC))) { BSTR s = (BSTR)MKBADDR(((IPTR)dn + sizeof(struct DeviceNode) + 3) & ~3); WORD a; for(a = 0; a < 3; a++) { AROS_BSTR_putchar(s, a, devnames[i][a]); } AROS_BSTR_setstrlen(s, 3); dn->dn_Type = DLT_DEVICE; /* i equals 1 when dn_DevName is "RAW", and 0 otherwise. This tells con_task that it has to start in RAW mode */ dn->dn_Ext.dn_AROS.dn_Unit = (struct Unit *)i; dn->dn_Ext.dn_AROS.dn_Device = &conbase->device; dn->dn_Handler = NULL; dn->dn_Startup = NULL; dn->dn_Name = s; dn->dn_Ext.dn_AROS.dn_DevName = AROS_BSTR_ADDR(dn->dn_Name); if (AddDosEntry((struct DosList *)dn)) { if (i == 0) continue; return TRUE; } FreeMem(dn, sizeof (struct DeviceNode)); } } return FALSE; }
/* Mount a volume with the given name; route all handler ** messages to the given port. */ struct DeviceNode *Mount(char *name, struct MsgPort *port) { struct DeviceNode *volume; struct DosList *dlist; struct FileSysStartupMsg *fssm = AllocVec(sizeof(struct FileSysStartupMsg), MEMF_CLEAR); struct DosEnvec *dosenvec = AllocVec(sizeof(struct DosEnvec), MEMF_CLEAR); if(name == NULL || port == NULL) return NULL; /* make dosenvec */ /* test: bpt=8,hc=1250000 */ /* zip: bpt=8,hc=24575 */ dosenvec->de_TableSize = 17; dosenvec->de_SizeBlock = 128; dosenvec->de_Surfaces = 16; // 1; // !! dosenvec->de_SectorPerBlock = 1; dosenvec->de_BlocksPerTrack = 63; // 8; //555; // !! dosenvec->de_Reserved = 2; dosenvec->de_LowCyl = 2; // 0; // !! dosenvec->de_HighCyl = 14759; // 1250000; // !! dosenvec->de_NumBuffers = 350; dosenvec->de_BufMemType = 0; dosenvec->de_MaxTransfer = 0x1ffff; dosenvec->de_Mask = 0x7ffffffe; dosenvec->de_DosType = 0x6d757577; //ID_MUAF_DISK; // 0x6D754653; //ID_PFS_DISK or just fun: 0x6d757575; dosenvec->de_BootBlocks = 2; /* make fssm */ fssm->fssm_Unit = 1; // 5; // !! fssm->fssm_Device = MKBADDR(devicename); fssm->fssm_Environ = MKBADDR(dosenvec); fssm->fssm_Flags = 0; while(!(dlist = AttemptLockDosList(LDF_DEVICES|LDF_WRITE))) { /* Can't lock the DOS list. Wait a second and try again. */ Delay(50); } volume = (struct DeviceNode *)FindDosEntry(dlist, name, LDF_DEVICES); if(volume) RemDosEntry((struct DosList *)volume); UnLockDosList(LDF_DEVICES|LDF_WRITE); if(!volume && !(volume = (struct DeviceNode *)MakeDosEntry(name, DLT_DEVICE))) return NULL; volume->dn_Startup = MKBADDR(fssm); volume->dn_Lock = NULL; volume->dn_GlobalVec = -1; /* Now we can own the volume by giving it our msgport */ volume->dn_Task = port; while(!(dlist = AttemptLockDosList(LDF_DEVICES|LDF_WRITE))) { /* Oops, can't lock DOS list. Wait 1 second and retry. */ Delay(50); } AddDosEntry((struct DosList *)volume); UnLockDosList(LDF_DEVICES|LDF_WRITE); return volume; }