New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / expansion / adddosnode.c
blobd24f0909c2b4cb768325ec5a528bab04f9f31da6
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a DOS device to the system.
6 Lang: English
7 */
8 #include "expansion_intern.h"
9 #include <exec/io.h>
10 #include <dos/filesystem.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
14 /*****************************************************************************
16 NAME */
17 #include <dos/filehandler.h>
18 #include <dos/dosextens.h>
19 #include <libraries/expansion.h>
20 #include <proto/expansion.h>
22 AROS_LH3(BOOL, AddDosNode,
24 /* SYNOPSIS */
25 AROS_LHA(LONG , bootPri, D0),
26 AROS_LHA(ULONG , flags, D1),
27 AROS_LHA(struct DeviceNode *, deviceNode, A0),
29 /* LOCATION */
30 struct ExpansionBase *, ExpansionBase, 25, Expansion)
32 /* FUNCTION
33 This is the old function for adding devices to the system. It
34 is recommended that you use the AddBootNode() function.
36 Unlike AddBootNode() you will have to add a BootNode to the
37 system yourself.
39 INPUTS
40 bootPri - The priority of the device (-128 --> 127).
41 flags - Flags (ADNF_STARTPROC etc)
42 deviceNode - The device to add to the system.
44 RESULT
45 non-zero if everything succeeded, zero on failure.
47 NOTES
48 It is much better to use AddBootNode() as it will also
49 construct the BootNode structure, and add it to the system.
51 EXAMPLE
52 // Add a bootable disk to the system. This will start a
53 // file handler process immediately.
55 if( AddDosNode( 0, ADNF_STARTPROC, MakeDosNode( paramPacket )))
57 // AddDosNode() ok
60 BUGS
62 SEE ALSO
63 AddBootNode(), MakeDosNode()
65 INTERNALS
67 HISTORY
68 27-11-96 digulla automatically created from
69 expansion_lib.fd and clib/expansion_protos.h
71 *****************************************************************************/
73 AROS_LIBFUNC_INIT
74 AROS_LIBBASE_EXT_DECL(struct ExpansionBase *,ExpansionBase)
76 struct DosLibrary *DOSBase;
77 BOOL ok = FALSE;
79 /* Have we been asked to start a filesystem, and there is none already */
80 if ((flags & ADNF_STARTPROC) && (deviceNode->dn_Device == NULL))
82 /* yes, better do so */
83 struct MsgPort *mp;
84 struct IOFileSys *iofs;
86 mp = CreateMsgPort();
88 if (mp != NULL)
90 iofs = (struct IOFileSys *)CreateIORequest(mp,
91 sizeof(struct IOFileSys));
93 if (iofs != NULL)
95 STRPTR handler;
96 struct FileSysStartupMsg *fssm;
98 if (deviceNode->dn_Handler == NULL)
100 handler = "ffs.handler";
102 else
104 handler = AROS_BSTR_ADDR(deviceNode->dn_Handler);
107 fssm = (struct FileSysStartupMsg *)BADDR(deviceNode->dn_Startup);
108 iofs->io_Union.io_OpenDevice.io_DeviceName = AROS_BSTR_ADDR(fssm->fssm_Device);
109 iofs->io_Union.io_OpenDevice.io_Unit = fssm->fssm_Unit;
110 iofs->io_Union.io_OpenDevice.io_Environ = (IPTR *)BADDR(fssm->fssm_Environ);
111 iofs->io_Union.io_OpenDevice.io_DosName = deviceNode->dn_NewName;
113 if (!OpenDevice(handler, 0, &iofs->IOFS, fssm->fssm_Flags))
116 Ok, this means that the handler was able to open,
117 the old mount command just left the device hanging?
119 I suppose that is one one of preventing it from
120 dieing
122 deviceNode->dn_Device = iofs->IOFS.io_Device;
123 deviceNode->dn_Unit = iofs->IOFS.io_Unit;
124 ok = TRUE;
127 DeleteIORequest(&iofs->IOFS);
130 DeleteMsgPort(mp);
133 else
135 ok = TRUE;
138 if (ok)
140 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 0);
142 /* Aha, DOS is up and running... */
143 if (DOSBase != NULL)
145 /* We should add the filesystem to the DOS device list. It will
146 usable from this point onwards.
148 The DeviceNode structure that was passed to us can be added
149 to the DOS list as it is, and we will let DOS start the
150 filesystem task if it is necessary to do so.
153 AddDosEntry((struct DosList *)deviceNode);
154 CloseLibrary((struct Library *)DOSBase);
158 return ok;
160 AROS_LIBFUNC_EXIT
161 } /* AddDosNode */