25 March 2018, 17:21 | #1 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,197
|
get "xxx.device" name from volume/device name
Hi,
I have "DH0:" which is my device name. I'd like to know which device (scsi.device, uaehf.device...) drives it. Any asm/C code to do so? Thanks |
25 March 2018, 17:54 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,001
|
Code:
#include <proto/exec.h> #include <proto/dos.h> #include <dos/filehandler.h> #include <string.h> /* copy a BCPL string to a C string */ void bstrcpy (char *dest,UBYTE *src) { int len = *src++; strncpy (dest,src,len); dest[len] = 0; } /* get drive name, device and unit for a given path */ BOOL get_device_unit (const char *path,char *drive,char *device,long *unit) { BOOL ok = FALSE; struct DevProc *proc; if ((proc = GetDeviceProc (path,NULL))) { struct DosList *dl; dl = LockDosList (LDF_DEVICES | LDF_READ); while ((dl = NextDosEntry (dl,LDF_DEVICES))) { if (dl->dol_Task == proc->dvp_Port) break; } if (dl) { struct FileSysStartupMsg *fssm = BADDR(dl->dol_misc.dol_handler.dol_Startup); if (TypeOfMem(fssm) && (APTR)fssm > (APTR)1000) { bstrcpy (drive,BADDR(dl->dol_Name)); bstrcpy (device,BADDR(fssm->fssm_Device)); *unit = fssm->fssm_Unit; ok = TRUE; } } UnLockDosList (LDF_DEVICES | LDF_READ); FreeDeviceProc (proc); } return (ok); } /* main program */ int main (void) { struct RDArgs *rdargs; struct { char **path; } args; if (!(rdargs = ReadArgs ("PATH/A/M",(APTR)&args,NULL))) PrintFault (IoErr(),NULL); else { char name[256]; char device[256]; long unit; char **path; for (path = args.path; *path; path++) { if (!get_device_unit (*path,name,device,&unit)) Printf ("could not find information for %s\n",*path); else { Printf ("info for %s: device=%s; unit=%ld\n",name,device,unit); } } FreeArgs (rdargs); } return (RETURN_OK); } |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cannot open "gvpscsi.device" unit 2 | Sanxion | support.Hardware | 3 | 03 October 2017 19:32 |
UAE4All2 on an android "non-touch device" | KombatSanta | support.OtherUAE | 0 | 27 February 2014 17:08 |
Is it possible to get "netprinter.device" working on FS-UAE | nexusle | support.FS-UAE | 0 | 23 February 2013 11:58 |
After creating OS 3.9 Emergency Disk: Cannot open "cd.device" unit 2 | Snowwie | support.Other | 2 | 31 March 2012 14:44 |
Harddrive & "USB-xx-in-one-device" support | Borg_Number_One | request.UAE Wishlist | 2 | 19 September 2004 21:33 |
|
|