[comp.sys.amiga.tech] AmigaDOS help...

new@udel.edu (Darren New) (10/13/89)

I'm trying to get the name of the device ("DF0:") given the name of
the volume ("Empty").  I'm sure that SOME bit of software knows how to
do this, but I sure can't figure it out.  Right now, I'm running thru
the device list until I find the volume node with the right name.
Then I look at node->dn_Task->mp_SigTask->tc_Node.ln_Name.  This has
two problems: 1) It seems like the wrong way of doing it.  2) It does
not seem to work for non-mounted devices; i.e., for floppy drives and
such.  AmigaDOS obviously does this somehow, but I don't know how.
Can somebody give me a clue?    -- Darren

cmcmanis%pepper@Sun.COM (Chuck McManis) (10/14/89)

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 <libraries/dosextens.h>
#include <libraries/filehandler.h>

	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."

new@udel.edu (Darren New) (10/17/89)

Ok, another question about AmigaDOS:

Is it possible to force the file-system(s) to write out their buffered
data?  In my program, I write a (sometimes) large file (>400K) and then
inhibit the filesystem in order to read bitmaps, etc.  Right now I just
Delay(300) or so to let the FS finish flushing bitmaps and such.  However,
this seems like a bad way of doing it, especially since it is possible that
the FS won't get a chance to run due to other procs running at a higher
priority.  There are packets for "ACTION_DISKCHANGE" but I think that
these are obsolete.  The Inhibit packet seems to cause troubles if 
DoIO()'ed while the bitmaps are bad.  I think I remember experimenting
and finding that C:DiskChange will screw up a disk if issued right
after writing to a disk, which leads me to believe there is no
good way to do it right.
Right now, the Delay() seems to be OK, but I'm interested in knowing 
if there is a better way. Thanks!!!  -- Darren