2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
9 #include <exec/errors.h>
10 #include <exec/resident.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
13 #include <utility/tagitem.h>
14 #include <dos/dosextens.h>
15 #include <dos/filesystem.h>
16 #include <proto/dos.h>
17 #include <aros/libcall.h>
18 #include <aros/symbolsets.h>
20 #include "zero_handler_gcc.h"
22 #include LC_LIBDEFS_FILE
26 static int GM_UNIQUENAME(Init
)(LIBBASETYPEPTR zerobase
)
28 zerobase
->dosbase
=(struct DosLibrary
*)OpenLibrary("dos.library",39);
29 if(zerobase
->dosbase
!=NULL
)
35 static int GM_UNIQUENAME(Open
)
37 LIBBASETYPEPTR zerobase
,
38 struct IOFileSys
*iofs
,
45 /* Mark Message as recently used. */
46 iofs
->IOFS
.io_Message
.mn_Node
.ln_Type
=NT_REPLYMSG
;
48 dev
=AllocMem(sizeof(ULONG
),MEMF_PUBLIC
|MEMF_CLEAR
);
51 iofs
->IOFS
.io_Unit
=(struct Unit
*)dev
;
52 iofs
->IOFS
.io_Device
=&zerobase
->device
;
53 iofs
->IOFS
.io_Error
=0;
58 iofs
->io_DosError
=ERROR_NO_FREE_STORE
;
61 iofs
->IOFS
.io_Error
=IOERR_OPENFAIL
;
66 static int GM_UNIQUENAME(Close
)
68 LIBBASETYPEPTR zerobase
,
69 struct IOFileSys
*iofs
74 dev
=(ULONG
*)iofs
->IOFS
.io_Unit
;
77 iofs
->io_DosError
=ERROR_OBJECT_IN_USE
;
81 /* Let any following attemps to use the device crash hard. */
82 FreeMem(dev
,sizeof(ULONG
));
88 ADD2INITLIB(GM_UNIQUENAME(Init
), 0)
89 ADD2OPENDEV(GM_UNIQUENAME(Open
), 0)
90 ADD2CLOSEDEV(GM_UNIQUENAME(Close
), 0)
92 AROS_LH1(void, beginio
,
93 AROS_LHA(struct IOFileSys
*, iofs
, A1
),
94 struct zerobase
*, zerobase
, 5, Zero
)
101 Do everything quick no matter what. This is possible
102 because I never need to Wait().
104 switch(iofs
->IOFS
.io_Command
)
108 ++*(ULONG
*)iofs
->IOFS
.io_Unit
;
113 /* No names allowed on ZERO: */
114 if (iofs
->io_Union
.io_NamedFile
.io_Filename
[0])
116 error
=ERROR_OBJECT_NOT_FOUND
;
122 for ( i
= iofs
->io_Union
.io_READ
.io_Length
; i
> 0 ; i
-- )
123 iofs
->io_Union
.io_READ
.io_Buffer
[i
-1] = 0;
130 iofs
->io_Union
.io_SEEK
.io_Offset
= 0;
135 --*(ULONG
*)iofs
->IOFS
.io_Unit
;
139 case FSA_IS_INTERACTIVE
:
140 iofs
->io_Union
.io_IS_INTERACTIVE
.io_IsInteractive
= TRUE
;
142 case FSA_SET_FILE_SIZE
:
144 case FSA_EXAMINE_NEXT
:
145 case FSA_EXAMINE_ALL
:
147 case FSA_CREATE_HARDLINK
:
148 case FSA_CREATE_SOFTLINK
:
150 case FSA_DELETE_OBJECT
:
151 error
= ERROR_NOT_IMPLEMENTED
;
155 error
= ERROR_ACTION_NOT_KNOWN
;
160 iofs
->io_DosError
=error
;
162 /* If the quick bit is not set send the message to the port */
163 if(!(iofs
->IOFS
.io_Flags
&IOF_QUICK
))
164 ReplyMsg(&iofs
->IOFS
.io_Message
);
169 AROS_LH1(LONG
, abortio
,
170 AROS_LHA(struct IOFileSys
*, iofs
, A1
),
171 struct zerobase
*, zerobase
, 6, Zero
)
174 /* Everything already done. */