Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / dos / filesystem_support.c
blob6d8ac5c3e9861e48bd8d4bab7ea2853eec3cf78e
1 /*
2 Copyright © 1995-2009, 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 void InitIOFS(struct IOFileSys *iofs, ULONG type,
21 struct DosLibrary *DOSBase)
23 struct Process *me = (struct Process *)FindTask(NULL);
25 iofs->IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
26 iofs->IOFS.io_Message.mn_ReplyPort = &me->pr_MsgPort;
27 iofs->IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
28 iofs->IOFS.io_Command = type;
29 iofs->IOFS.io_Flags = 0;
32 CONST_STRPTR StripVolume(CONST_STRPTR name) {
33 const char *path = strchr(name, ':');
34 if (path != NULL)
35 path++;
36 else
37 path = name;
38 return path;
41 LONG DoIOFS(struct IOFileSys *iofs, struct DevProc *dvp, CONST_STRPTR name,
42 struct DosLibrary *DOSBase) {
43 BOOL freedvp = FALSE;
45 if (dvp == NULL) {
46 if ((dvp = GetDeviceProc(name, NULL)) == NULL)
47 return IoErr();
49 freedvp = TRUE;
52 iofs->IOFS.io_Device = (struct Device *) dvp->dvp_Port;
54 if (dvp->dvp_Lock != NULL)
55 iofs->IOFS.io_Unit = ((struct FileHandle *) BADDR(dvp->dvp_Lock))->fh_Unit;
56 else
57 iofs->IOFS.io_Unit = dvp->dvp_DevNode->dol_Ext.dol_AROS.dol_Unit;
59 if (name != NULL)
60 iofs->io_Union.io_NamedFile.io_Filename = StripVolume(name);
62 DosDoIO((struct IORequest *)iofs);
64 if (freedvp)
65 FreeDeviceProc(dvp);
67 SetIoErr(iofs->io_DosError);
69 return iofs->io_DosError;