Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!convex!texsun!newstop!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga.tech Subject: Re: AmigaDOS help... Message-ID: <126319@sun.Eng.Sun.COM> Date: 13 Oct 89 21:41:05 GMT References: <1484@nigel.udel.EDU> Sender: news@sun.Eng.Sun.COM Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 52 In article <1484@nigel.udel.EDU> new@udel.edu (Darren New) writes: >I'm trying to get the name of the device ("DF0:") given the name of >the volume ("Empty"). ... > ... AmigaDOS obviously does this somehow, but I don't know how. >Can somebody give me a clue? -- Darren A Clue : #include #include struct FileLock *fl; long lock; struct DeviceList *dl; struct DeviceNode *dn; char DeviceName[80]; struct MsgPort *ourtask; lock = Lock("Empty:"); if (!lock) /* No mounted device has an empty volume in it, NOTE: This will generate a requester "please put Empty: in any drive." */ fl = (struct FileLock *)BADDR(lock); dl = (struct DeviceList*)BADDR(fl->fl_Volume); ourtask = dl->dl_Task; /* Now this works, but I don't know if CBM will guarantee it to continue to work. DeviceNodes are always added to the head of the list. So your volume node will always be in front of the device node for the device it is mounted on. */ Forbid(); /* Watch out for changes */ for (dn = (struct DeviceNode *)(BADDR(dl->dl_Next)); dn; dn = (struct DeviceNode *)(BADDR(dn->dn_Next))) { if (dn->dn_Type != DLT_DEVICE) continue; if (dn->dn_Task == ourtask) { strcpy(DeviceName, (char *)(BADDR(dn->dn_Name))+1); break; } } Permit(); printf("That volume is on device %s. \n", DeviceName); --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you. "If I were driving a Macintosh, I'd have to stop before I could turn the wheel."