Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / filesystem_support.c
blobd74c07e090f1d1dbc4acc4ae43edb3807e1b66f3
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <dos/dos.h>
10 #include <dos/dosextens.h>
11 #include <dos/filesystem.h>
12 #include <exec/memory.h>
13 #include <proto/dos.h>
14 #include <proto/exec.h>
15 #include "dos_intern.h"
17 #include <string.h>
20 struct Device *GetDosType(ULONG type, CONST_STRPTR name, struct Unit **unit,
21 struct DosLibrary *DOSBase);
24 void InitIOFS(struct IOFileSys *iofs, ULONG type,
25 struct DosLibrary *DOSBase)
27 struct Process *me = (struct Process *)FindTask(NULL);
29 iofs->IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
30 iofs->IOFS.io_Message.mn_ReplyPort = &me->pr_MsgPort;
31 iofs->IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
32 iofs->IOFS.io_Command = type;
33 iofs->IOFS.io_Flags = 0;
36 struct Device *GetDevice(CONST_STRPTR name, struct Unit **unit,
37 struct DosLibrary *DOSBase)
39 return GetDosType(LDF_DEVICES, name, unit, DOSBase);
40 // return GetDosType(DLT_DEVICE, name, unit, DOSBase);
44 struct Device *GetVolume(CONST_STRPTR name, struct Unit **unit,
45 struct DosLibrary *DOSBase)
47 return GetDosType(LDF_VOLUMES, name, unit, DOSBase);
48 // return GetDosType(DLT_VOLUME, name, unit, DOSBase);
52 /* Return the device corresponding to the 'name'. This function will
53 only look into "real" devices, that is no "PROGDIR:" or such.
54 The pointer to the device unit will be written into 'unit' if
55 'unit' is not NULL. */
56 struct Device *GetDosType(ULONG type, CONST_STRPTR name, struct Unit **unit,
57 struct DosLibrary *DOSBase)
59 int len = strlen(name);
60 int size;
61 STRPTR colon = strchr(name, ':');
62 STRPTR tempName;
64 struct Device *device = NULL;
65 struct DosList *dl;
67 if (colon == NULL)
69 return NULL;
72 size = colon - name;
74 /* Not only a device name with trailing colon? */
75 if (size + 1 != len)
77 return NULL;
80 tempName = AllocVec(len, MEMF_ANY);
82 if (tempName == NULL)
84 return NULL;
87 CopyMem(name, tempName, size);
88 tempName[size] = 0; /* Terminate string */
90 dl = LockDosList(type | LDF_READ);
91 dl = FindDosEntry(dl, tempName, type);
92 if (dl != NULL)
94 device = dl->dol_Device;
95 if (unit!=NULL)
96 *unit = dl->dol_Unit;
99 UnLockDosList(type | LDF_READ);
101 if (device == NULL)
103 SetIoErr(ERROR_DEVICE_NOT_MOUNTED);
106 FreeVec(tempName);
108 return device;