2 /* $Log: dostohandlerinterface.c $
3 * Revision 13.10 1999/05/14 11:31:34 Michiel
4 * Long filename support implemented; bugfixes
6 * Revision 13.9 1999/02/22 16:22:35 Michiel
7 * ACTION_SET_DELDIR added
9 * Revision 13.8 1998/05/31 16:27:42 Michiel
10 * added ACTION_IS_PFS2
12 * Revision 13.7 1997/03/03 22:04:04 Michiel
15 * Revision 13.6 1995/12/29 11:04:12 Michiel
18 * Revision 13.4 1995/08/21 04:20:43 Michiel
19 * added some extrapackets
21 * Revision 13.3 1995/08/16 14:28:28 Michiel
22 * fixed function table bug
23 * added ACTION_KILL_EMPTY (after being forgotten earlier)
24 * added ACTION_REMOVE_DIRENTRY
26 * Revision 13.2 1995/08/12 12:14:31 Michiel
33 #include <exec/memory.h>
34 #include <exec/types.h>
35 #include <exec/interrupts.h>
36 #include <dos/filehandler.h>
37 #include <dos/notify.h>
39 #include <proto/multiuser.h>
46 #include "versionhistory.doc"
49 #include "directory_protos.h"
50 #include "disk_protos.h"
51 #include "lock_protos.h"
52 #include "volume_protos.h"
53 #include "format_protos.h"
54 #include "update_protos.h"
55 #include "lru_protos.h"
56 #include "ass_protos.h"
57 #include "anodes_protos.h"
58 #include "init_protos.h"
61 void ReturnPacket(struct DosPacket
*, struct MsgPort
*, globaldata
*g
);
65 static UBYTE debugbuf
[120];
66 #define DebugOn debug++
67 #define DebugOff debug = 0
68 #define DebugMsg(msg) NormalErrorMsg(msg, NULL);
69 #define DebugMsgNum(msg, num) sprintf(debugbuf, "%s 0x%08lx.", msg, num); \
70 if(debug) {NormalErrorMsg(debugbuf, NULL);debug=0;}
71 #define DebugMsgName(msg, name) sprintf(debugbuf, "%s >%s<.", msg, name); \
72 if(debug) {NormalErrorMsg(debugbuf, NULL);debug=0;}
77 #define DebugMsgNum(msg,num)
78 #define DebugMsgName(msg, name)
82 /**********************
86 void NormalCommands(struct DosPacket
*, globaldata
*);
87 void InhibitedCommands(struct DosPacket
*, globaldata
*);
89 void SleepCommands (struct DosPacket
*action
, globaldata
*g
);
92 /**********************
96 #define RES1(p) (p->dp_Res1)
97 #define RES2(p) (p->dp_Res2)
98 #define BARG1(p) BADDR(p->dp_Arg1)
99 #define BARG2(p) BADDR(p->dp_Arg2)
100 #define BARG3(p) BADDR(p->dp_Arg3)
101 #define BARG4(p) BADDR(p->dp_Arg4)
103 #include "dd_support.c"
104 #include "dd_funcs.c"
107 /**********************
108 * structures and globals
113 SIPTR (*function
)(struct DosPacket
*, globaldata
*);
117 static const struct functable functiontable0
[] =
119 {NotKnown
, 0}, /* ACTION_NIL 0 */
121 {NotKnown
, 0}, /* ACTION_GET_BLOCK 2 */
123 {NotKnown
, 0}, /* ACTION_SET_MAP 4 */
124 {dd_Quit
, 0}, /* ACTION_DIE 5 */
125 {NotKnown
, 0}, /* ACTION_EVENT 6 */
126 {dd_CurrentVolume
, 0}, /* ACTION_CURRENT_VOLUME 7 */
127 {dd_Lock
, 1}, /* ACTION_LOCATE_OBJECT 8 */
128 {dd_Relabel
, 1}, /* ACTION_RENAME_DISK 9 */
134 {dd_Unlock
, 0}, /* ACTION_FREE_LOCK 15 */
135 {dd_DeleteObject
, 1}, /* ACTION_DELETE_OBJECT 16 */
136 {dd_Rename
, 1}, /* ACTION_RENAME_OBJECT 17 */
137 {dd_AddBuffers
, 0}, /* ACTION_MORE_CACHE 18 */
138 {dd_DupLock
, 1}, /* ACTION_COPY_DIR 19 */
139 {NotKnown
, 0}, /* ACTION_WAIT_CHAR 20 */
140 {dd_SetProperty
, 1}, /* ACTION_SET_PROTECT 21 */
141 {dd_CreateDir
, 1}, /* ACTION_CREATE_DIR 22 */
142 {dd_Examine
, 1}, /* ACTION_EXAMINE_OBJECT 23 */
143 {dd_Examine
, 1}, /* ACTION_EXAMINE_NEXT 24 */
144 {dd_Info
, 0}, /* ACTION_DISK_INFO 25 */
145 {dd_Info
, 0}, /* ACTION_INFO 26 */
146 {dd_Flush
, 0}, /* ACTION_FLUSH 27 */
147 {dd_SetProperty
, 1}, /* ACTION_SET_COMMENT 28 */
148 {dd_Parent
, 1}, /* ACTION_PARENT 29 */
149 {NotKnown
, 0}, /* ACTION_TIMER 30 */
150 {dd_InhibitOn
, 0}, /* ACTION_INHIBIT 31 */
151 {NotKnown
, 0}, /* ACTION_DISK_TYPE 32 */
152 {NotKnown
, 0}, /* ACTION_DISK_CHANGE 33 */
153 {dd_SetProperty
, 1}, /* ACTION_SET_DATE 34 */
159 {dd_SameLock
, 0} /* ACTION_SAME_LOCK 40 */
162 static const struct functable functiontable1000
[] =
165 {NotKnown
, 0}, /* ACTION_READ_RETURN 1001 */
166 {NotKnown
, 0}, /* ACTION_WRITE_RETURN 1002 */
168 {dd_Open
, 3}, /* ACTION_FINDUPDATE 1004 */
169 {dd_Open
, 3}, /* ACTION_FINDINPUT 1005 */
170 {dd_Open
, 3}, /* ACTION_FINDOUTPUT 1006 */
171 {dd_Close
, 0}, /* ACTION_END 1007 */
172 {dd_SeekRead
, 3}, /* ACTION_SEEK 1008 */
184 {NotKnown
, 0}, /* ACTION_FORMAT 1020 (inhibited only) */
185 {dd_MakeLink
, 1}, /* ACTION_MAKE_LINK 1021 */
186 {dd_WriteSFS
, 3}, /* ACTION_SET_FILE_SIZE 1022 */
187 {dd_WriteProtect
, 0}, /* ACTION_WRITE_PROTECT 1023 */
188 {dd_ReadLink
, 1}, /* ACTION_READ_LINK 1024 */
190 {dd_OpenFromLock
, 3}, /* ACTION_FH_FROM_LOCK 1026 */
191 {dd_IsFileSystem
, 0}, /* ACTION_IS_FILESYSTEM 1027 */
192 {dd_ChangeMode
, 1}, /* ACTION_CHANGE_MODE 1028 */
194 {dd_DupLock
, 1}, /* ACTION_COPY_DIR_FH 1030 */
195 {dd_Parent
, 1}, /* ACTION_PARENT_FH 1031 */
197 {dd_ExamineAll
, 1}, /* ACTION_EXAMINE_ALL 1033 */
198 {dd_Examine
, 1}, /* ACTION_EXAMINE_FH 1034 */
199 {NotYetImplemented
, 0}, /* ACTION_EXAMINE_ALL_END 1035 */
200 {dd_SetProperty
, 1}, /* ACTION_SET_OWNER 1036 */
205 /**********************
206 * Normal, not-inhibited packet processor
209 /* NormalCommands funtion: normal commandmode
211 * This function executes the operation specified by the passed packet. Can be
212 * called from a testenviroment and from the Handler. The Handler has to take
213 * care of receiving and answering the DOS packet.
215 * This function does not contain initialisation. Its sole purpose is the
216 * execution of commands on an already active filesystem.
218 * pre: filesystem ready; dos- and intuition open; unitdata ready
219 * post: command executed.
221 void NormalCommands(struct DosPacket
*action
, globaldata
*g
)
225 /* clear error field */
228 packettype
= action
->dp_Type
;
229 if (packettype
== ACTION_WRITE
)
231 action
->dp_Res1
= dd_WriteSFS (action
, g
);
234 else if (packettype
== ACTION_READ
)
236 action
->dp_Res1
= dd_SeekRead (action
, g
);
239 else if (packettype
<= ACTION_SAME_LOCK
)
241 action
->dp_Res1
= functiontable0
[packettype
].function(action
, g
);
242 g
->timeout
|= functiontable0
[packettype
].timeout
;
244 else if (packettype
>= 1000 && packettype
<= ACTION_SET_OWNER
)
246 action
->dp_Res1
= functiontable1000
[packettype
-1000].function(action
, g
);
247 g
->timeout
|= functiontable1000
[packettype
-1000].timeout
;
249 else switch (packettype
)
251 case ACTION_LOCK_RECORD
:
252 case ACTION_FREE_RECORD
:
253 action
->dp_Res1
= NotYetImplemented(action
, g
);
256 case ACTION_ADD_NOTIFY
:
257 action
->dp_Res1
= dd_AddNotify(action
, g
);
260 case ACTION_REMOVE_NOTIFY
:
261 action
->dp_Res1
= dd_RemoveNotify(action
, g
);
267 case ACTION_KILL_EMPTY
:
268 action
->dp_Res1
= dd_KillEmpty(action
, g
);
271 case ACTION_REMOVE_DIRENTRY
:
272 action
->dp_Res1
= dd_RemoveDirEntry(action
, g
);
276 action
->dp_Res1
= dd_Sleep(action
, g
);
279 case ACTION_CREATE_ROLLOVER
:
280 action
->dp_Res1
= dd_MakeRollover(action
, g
);
284 case ACTION_SET_ROLLOVER
:
285 action
->dp_Res1
= dd_SetRollover(action
, g
);
290 action
->dp_Res1
= dd_IsPFS2(action
, g
);
293 case ACTION_ADD_IDLE_SIGNAL
:
294 action
->dp_Res1
= dd_SignalIdle(action
, g
);
298 case ACTION_SET_DELDIR
:
299 action
->dp_Res1
= dd_SetDeldir(action
, g
);
302 case ACTION_SET_FNSIZE
:
303 action
->dp_Res1
= dd_SetFileSize(action
, g
);
306 #if EXTENDED_PACKETS_OS4
307 case ACTION_CHANGE_FILE_POSITION64
:
308 dd_ChangeFilePosition64(action
, g
);
310 case ACTION_GET_FILE_POSITION64
:
311 dd_GetFilePosition64(action
, g
);
313 case ACTION_CHANGE_FILE_SIZE64
:
314 dd_ChangeFileSize64(action
, g
);
316 case ACTION_GET_FILE_SIZE64
:
317 dd_GetFileSize64(action
, g
);
321 #if EXTENDED_PACKETS_MORPHOS
323 * Note: If we ever support file sizes between 2^31 to 2^32-2 then SEEK64 needs
324 * to be implemented. - Piru
327 case ACTION_SET_FILE_SIZE64
:
328 case ACTION_LOCK_RECORD64
:
329 case ACTION_FREE_RECORD64
:
330 case ACTION_EXAMINE_OBJECT64
:
331 case ACTION_EXAMINE_NEXT64
:
332 case ACTION_EXAMINE_FH64
:
333 action
->dp_Res1
= NotKnown(action
, g
);
336 #if defined(__MORPHOS__)
337 case ACTION_NEW_READ_LINK
:
339 * This really ought to be implemented at some point.
340 * It'd mostly require support for reading hardlink destination.
343 action
->dp_Res1
= NotKnown(action
, g
);
346 case ACTION_QUERY_ATTR
:
347 action
->dp_Res1
= dd_MorphOSQueryAttr(action
, g
);
351 case ACTION_SERIALIZE_DISK
: // Inhibited only
353 action
->dp_Res1
= NotKnown(action
, g
);
359 /**********************
360 * Inhibited packet processor
363 void InhibitedCommands(struct DosPacket
*action
, globaldata
*g
)
365 /* clear error field */
368 switch (action
->dp_Type
)
371 action
->dp_Res1
= dd_InhibitOff(action
, g
);
374 case ACTION_FORMAT
: // Format(fs,vol,type) 2.0
375 action
->dp_Res1
= dd_Format(action
, g
);
378 case ACTION_FREE_LOCK
: // UnLock()
379 action
->dp_Res1
= dd_Unlock(action
, g
);
382 case ACTION_CURRENT_VOLUME
: // <sendpkt only>
386 case ACTION_DISK_INFO
: // Info(..)
388 action
->dp_Res1
= dd_Info(action
, g
);
391 case ACTION_IS_FILESYSTEM
: // IsFileSystem(devname)
392 action
->dp_Res1
= DOSTRUE
;
395 case ACTION_FLUSH
: // <sendpkt only>
397 action
->dp_Res1
= DOSTRUE
;
400 case ACTION_DIE
: // <sendpkt only>
402 action
->dp_Res1
= dd_Quit(action
, g
);
405 case ACTION_SERIALIZE_DISK
: // zie dosextens.h regel 220
406 action
->dp_Res1
= dd_SerializeDisk(action
, g
);
410 action
->dp_Res1
= dd_IsPFS2(action
, g
);
413 case ACTION_SET_FNSIZE
:
414 case ACTION_FINDINPUT
: // Open(.., MODE_OLDFILE)
415 case ACTION_FINDOUTPUT
: // Open(.., MODE_NEWFILE)
416 case ACTION_FINDUPDATE
: // Open(.., MODE_READWRITE)
417 case ACTION_EXAMINE_FH
: // ExamineFH(fh,fib)
418 case ACTION_EXAMINE_OBJECT
: // Examine(..)
419 case ACTION_EXAMINE_NEXT
: // ExNext(..)
420 case ACTION_CREATE_DIR
: // CreateDir(..)
421 case ACTION_DELETE_OBJECT
: // DeleteFile(..)
422 case ACTION_RENAME_OBJECT
: // Rename(..)
423 case ACTION_WRITE
: // Write(..)
424 case ACTION_LOCATE_OBJECT
: // Lock(..)
425 case ACTION_COPY_DIR_FH
:
426 case ACTION_COPY_DIR
: // DupLock(..) COULD be implemented ?
427 case ACTION_PARENT_FH
: // ParentOfFH(fh)
428 case ACTION_PARENT
: // Parent(..)
429 case ACTION_SET_PROTECT
: // SetProtection(..)
430 case ACTION_SET_COMMENT
: // SetComment(..)
431 case ACTION_SET_DATE
: // SetFileDate(..)
432 case ACTION_FH_FROM_LOCK
: // OpenFromLock(lock)
433 case ACTION_CHANGE_MODE
: // ChangeMode(type,obj,mode)
434 case ACTION_RENAME_DISK
: // Relabel(..)
435 case ACTION_EXAMINE_ALL
: // ExAll(lock,buff,size,type,ctl)
436 case ACTION_SET_FILE_SIZE
: // SetFileSize(file,off,mode)
437 case ACTION_SAME_LOCK
: // SameLock(lock1, lock2)
438 case ACTION_MAKE_LINK
: // MakeLink(name,targ,mode)
439 case ACTION_READ_LINK
: // ReadLink(port,lck,nam,buf,len)
440 case ACTION_ADD_NOTIFY
: // StartNotify(NotifyRequest)
441 case ACTION_REMOVE_NOTIFY
: // EndNotify(NotifyRequest)
442 case ACTION_MORE_CACHE
: // AddBuffers(..)
443 case ACTION_WRITE_PROTECT
: // <sendpkt only>
444 case ACTION_END
: // Close(..)
445 case ACTION_CREATE_ROLLOVER
:
447 #if EXTENDED_PACKETS_OS4
448 case ACTION_CHANGE_FILE_POSITION64
:
449 case ACTION_GET_FILE_POSITION64
:
450 case ACTION_CHANGE_FILE_SIZE64
:
451 case ACTION_GET_FILE_SIZE64
:
454 action
->dp_Res2
= ERROR_NOT_A_DOS_DISK
;
455 action
->dp_Res1
= DOSFALSE
;
458 case ACTION_READ
: // Read(..)
459 case ACTION_SEEK
: // Seek(..)
460 action
->dp_Res2
= ERROR_NOT_A_DOS_DISK
;
461 action
->dp_Res1
= -1;
464 #if EXTENDED_PACKETS_MORPHOS
466 case ACTION_SET_FILE_SIZE64
:
467 case ACTION_LOCK_RECORD64
:
468 case ACTION_FREE_RECORD64
:
469 case ACTION_EXAMINE_OBJECT64
:
470 case ACTION_EXAMINE_NEXT64
:
471 case ACTION_EXAMINE_FH64
:
472 #if defined(__MORPHOS__)
473 case ACTION_NEW_READ_LINK
:
474 action
->dp_Res2
= ERROR_NOT_A_DOS_DISK
;
475 action
->dp_Res1
= DOSFALSE
;
477 case ACTION_QUERY_ATTR
:
478 action
->dp_Res1
= dd_MorphOSQueryAttr(action
, g
);
492 /**********************
493 * MODE_SLEEP packet processor
497 * Packethandler during MODE_SLEEP
499 void SleepCommands(struct DosPacket
*action
, globaldata
*g
)
501 /* clear error field */
504 switch (action
->dp_Type
)
506 case ACTION_FREE_LOCK
: // UnLock()
507 action
->dp_Res1
= dd_Unlock(action
, g
);
510 case ACTION_CURRENT_VOLUME
: // <sendpkt only>
511 action
->dp_Res1
= dd_CurrentVolume(action
, g
);
514 case ACTION_DISK_INFO
: // Info(..)
516 action
->dp_Res1
= dd_Info(action
, g
);
519 case ACTION_IS_FILESYSTEM
: // IsFileSystem(devname)
520 action
->dp_Res1
= DOSTRUE
;
523 case ACTION_FLUSH
: // <sendpkt only>
524 action
->dp_Res1
= DOSTRUE
;
528 * special sleep packets
531 action
->dp_Res1
= dd_Sleep(action
, g
);
534 case ACTION_UPDATE_ANODE
:
535 action
->dp_Res1
= dd_UpdateAnode(action
, g
);
543 NormalCommands(action
, g
);