2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
9 #include <exec/execbase.h>
11 #include <exec/devices.h>
13 #include <aros/libcall.h>
14 #include <proto/exec.h>
16 #include "exec_debug.h"
17 #ifndef DEBUG_CloseDevice
18 # define DEBUG_CloseDevice 0
24 #include <aros/debug.h>
27 /*****************************************************************************
31 AROS_LH1(void, CloseDevice
,
34 AROS_LHA(struct IORequest
*, iORequest
, A1
),
37 struct ExecBase
*, SysBase
, 75, Exec
)
40 Closes a previously opened device. Any outstanding I/O requests must
41 be finished. It is safe to call CloseDevice with a cleared iorequest
42 structure or one that failed to open.
45 iORequest - Pointer to iorequest structure.
60 ******************************************************************************/
65 D(bug("CloseDevice $%lx $%lx (\"%s\") by \"%s\"\n", iORequest
, iORequest
->io_Device
,
66 iORequest
->io_Device
? iORequest
->io_Device
->dd_Library
.lib_Node
.ln_Name
: "(null)",
67 GET_THIS_TASK
->tc_Node
.ln_Name
));
69 /* Single-thread the close routine. */
72 /* Something to do? */
73 if(iORequest
->io_Device
!=NULL
)
75 dc_ret
= AROS_LVO_CALL1(BPTR
,
76 AROS_LCA(struct IORequest
*,iORequest
, A1
),
77 struct Device
*,iORequest
->io_Device
,2,
80 Normally you'd expect the device to be expunged if this returns
81 non-zero, but this is only exec which doesn't know anything about
82 seglists - therefore dos.library has to SetFunction() into this
83 vector for the additional functionality.
86 /* Trash device field */
87 iORequest
->io_Device
=(struct Device
*)-1;
91 /* local vars not guaranteed to be initialised to 0 */
98 AROS_COMPAT_SETD0(dc_ret
);