some fixes to accented characters
[tangerine.git] / rom / dos / sendpkt.c
blob222fdf64b038413ddef18462efcd10b5dbe8878b
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include "dos_intern.h"
11 #include <dos/dosextens.h>
12 #include <dos/notify.h>
13 #include <proto/exec.h>
14 #include <exec/initializers.h>
15 #include <string.h>
16 #include <proto/utility.h>
18 /* TODO: This can be done much better! */
19 #ifndef AROS_FAST_BPTR
20 #define BStrtoCStr(bstr) ({ \
21 STRPTR cstr; \
22 cstr = AllocMem(AROS_BSTR_strlen(bstr)+1, MEMF_PUBLIC); \
23 if(cstr) \
24 { \
25 CopyMem(AROS_BSTR_ADDR(bstr), cstr, AROS_BSTR_strlen(bstr)); \
26 cstr[AROS_BSTR_strlen(bstr)] = 0; \
27 } \
28 cstr; \
30 #else
31 #define BStrtoCStr(bstr) ((STRPTR)bstr)
32 #endif
35 LONG DoNameAsynch(struct IOFileSys *iofs, STRPTR name,
36 struct DosLibrary *DOSBase);
38 /*****************************************************************************
40 NAME */
41 #include <proto/dos.h>
43 AROS_LH3(void, SendPkt,
45 /* SYNOPSIS */
46 AROS_LHA(struct DosPacket *, dp, D1),
47 AROS_LHA(struct MsgPort *, port, D2),
48 AROS_LHA(struct MsgPort *, replyport, D3),
50 /* LOCATION */
51 struct DosLibrary *, DOSBase, 41, Dos)
53 /* FUNCTION
55 Send a packet to a handler without waiting for the result. The packet will
56 be returned to 'replyport'.
58 INPUTS
60 packet -- the (initialized) packet to send
61 port -- the MsgPort to send the packet to
62 replyport -- the MsgPort to which the packet will be replied
64 RESULT
66 This function is callable from a task.
68 NOTES
70 EXAMPLE
72 BUGS
74 SEE ALSO
76 DoPkt(), WaitPkt(), AbortPkt()
78 INTERNALS
80 *****************************************************************************/
82 AROS_LIBFUNC_INIT
85 * Trying to emulate the packet system by rewriting the
86 * packets to IO Requests. Sometimes there are too many
87 * parameters in the packet but thats fine. If there are
88 * not enough parameters or the wrong type etc. then
89 * it is more difficult to translate the packet.
93 struct IOFileSys *iofs = AllocMem(sizeof(struct IOFileSys), MEMF_CLEAR);
94 struct FileHandle *fh;
95 BPTR oldCurDir;
96 LONG result;
98 if (iofs != NULL)
101 * Also attach the packet to the io request.
102 * Will remain untouched by the driver.
105 iofs->io_PacketEmulation = dp;
108 * In case the packet is to be aborted
109 * I know which IORequest to use. The user will
110 * use the packet itself to abort the operation.
112 dp->dp_Arg7 = (IPTR)iofs;
115 iofs->IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
116 iofs->IOFS.io_Message.mn_ReplyPort = replyport;
117 iofs->IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
118 iofs->IOFS.io_Flags = 0;
121 * Have to rewrite this packet...
124 switch (dp->dp_Type)
126 case ACTION_NIL:
127 case ACTION_READ_RETURN:
128 case ACTION_WRITE_RETURN:
129 case ACTION_TIMER:
130 kprintf("This packet is a reserved one and should not be sent"
131 " by you!\n");
132 // Alert();
133 return;
135 // case ACTION_GET_BLOCK:
136 case ACTION_DISK_CHANGE:
137 case ACTION_DISK_TYPE:
138 case ACTION_EVENT:
139 case ACTION_SET_MAP:
141 kprintf("This packet is obsolete. (ACTION type %d)\n",
142 dp->dp_Type);
143 return;
146 case ACTION_FINDINPUT: // Open() MODE_OLDFILE [*]
147 fh = (struct FileHandle *)dp->dp_Arg2;
149 iofs->IOFS.io_Device = fh->fh_Device;
151 iofs->IOFS.io_Command = FSA_OPEN_FILE;
152 iofs->io_Union.io_OPEN_FILE.io_FileMode = FMF_WRITE | FMF_READ;
154 oldCurDir = CurrentDir((BPTR)dp->dp_Arg2);
155 result = DoNameAsynch(iofs, BStrtoCStr((BSTR)dp->dp_Arg3),
156 DOSBase);
157 CurrentDir(oldCurDir);
159 if (result != 0)
161 kprintf("Error: Didn't find file\n");
162 return;
165 kprintf("Returned from DoNameAsynch()\n");
167 break;
169 case ACTION_FINDOUTPUT: // Open() MODE_NEWFILE [*]
170 fh = (struct FileHandle *)dp->dp_Arg2;
172 iofs->IOFS.io_Device = fh->fh_Device;
174 iofs->IOFS.io_Command = FSA_OPEN_FILE;
175 iofs->io_Union.io_OPEN_FILE.io_FileMode = FMF_LOCK |
176 FMF_CREATE | FMF_CLEAR | FMF_WRITE | FMF_READ;
178 oldCurDir = CurrentDir((BPTR)dp->dp_Arg2);
179 result = DoNameAsynch(iofs, BStrtoCStr((BSTR)dp->dp_Arg3),
180 DOSBase);
181 CurrentDir(oldCurDir);
183 if (result != 0)
185 return;
188 break;
191 case ACTION_FINDUPDATE: // Open() MODE_READWRITE [*]
192 fh = (struct FileHandle *)dp->dp_Arg2;
194 iofs->IOFS.io_Device = fh->fh_Device;
196 iofs->IOFS.io_Command = FSA_OPEN_FILE;
197 iofs->io_Union.io_OPEN_FILE.io_FileMode = FMF_CREATE |
198 FMF_WRITE | FMF_READ;
200 oldCurDir = CurrentDir((BPTR)dp->dp_Arg2);
201 result = DoNameAsynch(iofs, BStrtoCStr((BSTR)dp->dp_Arg3),
202 DOSBase);
203 CurrentDir(oldCurDir);
205 if (result != 0)
207 return;
210 break;
212 case ACTION_READ: // Read() [*]
213 fh = (struct FileHandle *)dp->dp_Arg1;
215 iofs->IOFS.io_Device = fh->fh_Device;
216 iofs->IOFS.io_Unit = fh->fh_Unit;
218 iofs->IOFS.io_Command = FSA_READ;
219 iofs->io_Union.io_READ_WRITE.io_Buffer = (APTR)dp->dp_Arg2;
220 iofs->io_Union.io_READ_WRITE.io_Length = (LONG)dp->dp_Arg3;
222 break;
225 case ACTION_WRITE: // Write() [*]
226 fh = (struct FileHandle *)dp->dp_Arg1;
228 iofs->IOFS.io_Device = fh->fh_Device;
229 iofs->IOFS.io_Unit = fh->fh_Unit;
231 iofs->IOFS.io_Command = FSA_WRITE;
232 iofs->io_Union.io_READ_WRITE.io_Buffer = (APTR)dp->dp_Arg2;
233 iofs->io_Union.io_READ_WRITE.io_Length = (LONG)dp->dp_Arg3;
235 break;
237 case ACTION_SEEK: // Seek() [*] CH
238 fh = (struct FileHandle *)dp->dp_Arg1;
240 iofs->IOFS.io_Device = fh->fh_Device;
241 iofs->IOFS.io_Unit = fh->fh_Unit;
243 /* If the file is in write mode flush it. This is done
244 synchronously as otherwise the seek may be served before
245 the flush. (TODO: What are a reasonable semantics here?) */
246 if (fh->fh_Flags & FHF_WRITE)
248 Flush(MKBADDR(fh));
250 else
252 /* Read mode. Just reinit the buffers. We can't call
253 Flush() in this case as that would end up in recursion. */
254 fh->fh_Pos = fh->fh_End = fh->fh_Buf;
257 iofs->IOFS.io_Command = FSA_SEEK;
258 iofs->io_Union.io_SEEK.io_Offset = (QUAD)dp->dp_Arg2;
259 iofs->io_Union.io_SEEK.io_SeekMode = dp->dp_Arg3;
261 break;
263 case ACTION_SET_FILE_SIZE: // SetFileSize() [*]
264 fh = (struct FileHandle *)dp->dp_Arg1;
266 iofs->IOFS.io_Device = fh->fh_Device;
267 iofs->IOFS.io_Unit = fh->fh_Unit;
269 iofs->IOFS.io_Command = FSA_SET_FILE_SIZE;
270 iofs->io_Union.io_SET_FILE_SIZE.io_Offset = (QUAD)dp->dp_Arg2;
271 iofs->io_Union.io_SET_FILE_SIZE.io_SeekMode = dp->dp_Arg3;
272 break;
274 case ACTION_EXAMINE_FH: // ExamineFH()
275 case ACTION_EXAMINE_OBJECT: // Examine() [*] -- the same thing
276 // in AROS
278 UBYTE *buffer = AllocVec(sizeof(struct ExAllData),
279 MEMF_PUBLIC | MEMF_CLEAR);
281 if (buffer == NULL)
283 dp->dp_Res1 = DOSFALSE;
284 dp->dp_Res2 = ERROR_NO_FREE_STORE;
286 return;
289 fh = (struct FileHandle *)dp->dp_Arg1;
291 iofs->IOFS.io_Device = fh->fh_Device;
292 iofs->IOFS.io_Unit = fh->fh_Unit;
294 iofs->IOFS.io_Command = FSA_EXAMINE;
295 iofs->io_Union.io_EXAMINE.io_ead = (struct ExAllData *)buffer;
296 iofs->io_Union.io_EXAMINE.io_Size = sizeof(struct ExAllData);
297 iofs->io_Union.io_EXAMINE.io_Mode = ED_OWNER;
299 /* A supplied FileInfoBlock (is a BPTR) is in dp_Arg2 */
301 break;
304 case ACTION_EXAMINE_NEXT: // ExNext() [*]
305 fh = (struct FileHandle *)dp->dp_Arg1;
307 iofs->IOFS.io_Device = fh->fh_Device;
308 iofs->IOFS.io_Unit = fh->fh_Unit;
310 iofs->IOFS.io_Command = FSA_EXAMINE_NEXT;
311 iofs->io_Union.io_EXAMINE_NEXT.io_fib = (BPTR)dp->dp_Arg2;
313 break;
315 case ACTION_CREATE_DIR: // CreateDir() [*]
316 fh = (struct FileHandle *)dp->dp_Arg1;
318 iofs->IOFS.io_Device = fh->fh_Device;
319 iofs->IOFS.io_Unit = fh->fh_Unit;
321 iofs->IOFS.io_Command = FSA_CREATE_DIR;
322 iofs->io_Union.io_CREATE_DIR.io_Filename = BStrtoCStr((BSTR)dp->dp_Arg2);
323 iofs->io_Union.io_CREATE_DIR.io_Protection = 0;
325 break;
328 case ACTION_DELETE_OBJECT: // DeleteFile() [*]
329 // ARG1: LOCK Lock to which ARG2 is relative
330 // ARG2: BSTR Name of object to delete (relative to ARG1)
332 fh = (struct FileHandle *)dp->dp_Arg1;
334 iofs->IOFS.io_Device = fh->fh_Device;
335 iofs->IOFS.io_Unit = fh->fh_Unit;
337 /* IFS_DELETE_OBJECT just consists of a STRPTR so we have to
338 use NameFromLock() here -- TODO */
339 // iofs->io_Union.io_DELETE_OBJECT.io_Filename = BStrtoCStr((BSTR)dp->dp_Arg2);
340 iofs->IOFS.io_Command = FSA_DELETE_OBJECT;
342 break;
344 case ACTION_RENAME_OBJECT: // Rename()
345 /* TODO */
346 break;
348 case ACTION_LOCK_RECORD: // LockRecord()
349 fh = (struct FileHandle *)BADDR(dp->dp_Arg1);
351 iofs->IOFS.io_Device = fh->fh_Device;
352 iofs->IOFS.io_Unit = fh->fh_Unit;
354 iofs->io_Union.io_RECORD.io_Offset = (QUAD)dp->dp_Arg2;
355 iofs->io_Union.io_RECORD.io_Size = (LONG)dp->dp_Arg3;
356 iofs->io_Union.io_RECORD.io_RecordMode = (LONG)dp->dp_Arg4;
357 iofs->io_Union.io_RECORD.io_Timeout = (LONG)dp->dp_Arg5;
358 break;
360 case ACTION_FREE_RECORD: // UnlockRecord()
361 fh = (struct FileHandle *)BADDR(dp->dp_Arg1);
363 iofs->IOFS.io_Device = fh->fh_Device;
364 iofs->IOFS.io_Unit = fh->fh_Unit;
366 iofs->io_Union.io_RECORD.io_Offset = (QUAD)dp->dp_Arg2;
367 iofs->io_Union.io_RECORD.io_Size = (LONG)dp->dp_Arg3;
368 iofs->io_Union.io_RECORD.io_RecordMode = (LONG)dp->dp_Arg4;
369 break;
371 case ACTION_PARENT: // ParentDir() [*]
372 fh = (struct FileHandle *)dp->dp_Arg1;
374 iofs->IOFS.io_Device = fh->fh_Device;
375 iofs->IOFS.io_Unit = fh->fh_Unit;
377 iofs->IOFS.io_Command = FSA_OPEN;
378 iofs->io_Union.io_OPEN.io_FileMode = FMF_READ; // Shared lock
380 oldCurDir = CurrentDir((BPTR)dp->dp_Arg1);
381 result = DoNameAsynch(iofs, "/", DOSBase);
382 CurrentDir(oldCurDir);
384 if (result != 0)
386 return;
389 return;
391 case ACTION_SET_PROTECT: // SetProtection() [*]
392 // STRPTR io_Filename; /* The file to change. */
393 // ULONG io_Protection; /* The new protection bits. */
395 fh = (struct FileHandle *)dp->dp_Arg2;
397 iofs->IOFS.io_Device = fh->fh_Device;
398 iofs->IOFS.io_Unit = fh->fh_Unit;
400 iofs->IOFS.io_Command = FSA_SET_PROTECT;
401 iofs->io_Union.io_SET_PROTECT.io_Protection = dp->dp_Arg4;
402 iofs->io_Union.io_SET_PROTECT.io_Filename = BStrtoCStr(dp->dp_Arg3);
404 break;
406 case ACTION_SET_COMMENT: // SetComment() [*]
407 fh = (struct FileHandle *)dp->dp_Arg2;
409 iofs->IOFS.io_Device = fh->fh_Device;
410 iofs->IOFS.io_Unit = fh->fh_Unit;
412 iofs->IOFS.io_Command = FSA_SET_COMMENT;
413 iofs->io_Union.io_SET_COMMENT.io_Filename = BStrtoCStr((BSTR)dp->dp_Arg3);
414 iofs->io_Union.io_SET_COMMENT.io_Comment = BStrtoCStr(dp->dp_Arg4);
416 break;
418 case ACTION_LOCATE_OBJECT: // Lock() [*]
419 fh = (struct FileHandle *)dp->dp_Arg1;
421 iofs->IOFS.io_Device = fh->fh_Device;
422 iofs->IOFS.io_Unit = fh->fh_Unit;
424 iofs->IOFS.io_Command = FSA_OPEN;
426 switch (dp->dp_Arg3)
428 case EXCLUSIVE_LOCK:
429 iofs->io_Union.io_OPEN.io_FileMode = FMF_LOCK | FMF_READ;
430 break;
432 case SHARED_LOCK:
433 iofs->io_Union.io_OPEN.io_FileMode = FMF_READ;
434 break;
436 default:
437 iofs->io_Union.io_OPEN.io_FileMode = dp->dp_Arg3;
438 break;
441 oldCurDir = CurrentDir((BPTR)dp->dp_Arg1);
442 result = DoNameAsynch(iofs, BStrtoCStr((BSTR)dp->dp_Arg2),
443 DOSBase);
444 CurrentDir(oldCurDir);
446 if (result != 0)
448 return;
451 dp->dp_Arg6 = (IPTR)AllocDosObject(DOS_FILEHANDLE, NULL);
453 if (dp->dp_Arg6 == (IPTR)NULL)
455 return;
458 break;
460 case ACTION_COPY_DIR: // DupLock()
461 case ACTION_COPY_DIR_FH: // DupLockFromFH() -- the same thing
462 // in AROS
463 fh = (struct FileHandle *)BADDR(dp->dp_Arg1);
465 iofs->IOFS.io_Device = fh->fh_Device;
466 iofs->IOFS.io_Unit = fh->fh_Unit;
468 iofs->IOFS.io_Command = FSA_OPEN;
470 /* Create a shared lock */
471 iofs->io_Union.io_OPEN.io_FileMode = FMF_READ;
473 oldCurDir = CurrentDir((BPTR)dp->dp_Arg1);
474 result = DoNameAsynch(iofs, "", DOSBase);
475 CurrentDir(oldCurDir);
477 if (result != 0)
479 return;
482 dp->dp_Arg6 = (IPTR)AllocDosObject(DOS_FILEHANDLE, NULL);
484 if (dp->dp_Arg6 == (IPTR)NULL)
486 return;
489 break;
491 case ACTION_END: // Close() [*]
492 case ACTION_FREE_LOCK: // UnLock() -- the same thing in AROS
493 fh = (struct FileHandle *)dp->dp_Arg1;
495 iofs->IOFS.io_Device = fh->fh_Device;
496 iofs->IOFS.io_Unit = fh->fh_Unit;
498 /* If the filehandle has a pending write on it Flush() the buffer.
499 This is made synchronously... */
500 if (fh->fh_Flags & FHF_WRITE)
502 Flush(MKBADDR(fh));
505 iofs->IOFS.io_Command = FSA_CLOSE;
507 break;
509 case ACTION_SET_DATE: // SetFileDate() [*]
510 fh = (struct FileHandle *)dp->dp_Arg2;
512 iofs->IOFS.io_Device = fh->fh_Device;
513 iofs->IOFS.io_Unit = fh->fh_Unit;
515 iofs->IOFS.io_Command = FSA_SET_DATE;
516 memcpy(&iofs->io_Union.io_SET_DATE.io_Date, (APTR)dp->dp_Arg4,
517 sizeof(struct DateStamp));
519 oldCurDir = CurrentDir((BPTR)dp->dp_Arg2);
520 result = DoNameAsynch(iofs, BStrtoCStr((BSTR)dp->dp_Arg3),
521 DOSBase);
522 CurrentDir(oldCurDir);
524 if (result != 0)
526 return;
529 break;
531 case ACTION_SAME_LOCK: // SameLock() [*]
532 fh = (struct FileHandle *)dp->dp_Arg1;
534 iofs->IOFS.io_Device = fh->fh_Device;
535 iofs->IOFS.io_Unit = fh->fh_Unit;
537 iofs->IOFS.io_Command = FSA_SAME_LOCK;
539 iofs->io_Union.io_SAME_LOCK.io_Lock[0] = BADDR((BPTR)dp->dp_Arg1);
540 iofs->io_Union.io_SAME_LOCK.io_Lock[1] = BADDR((BPTR)dp->dp_Arg2);
542 break;
544 case ACTION_MAKE_LINK: // MakeLink()
546 STRPTR name = BStrtoCStr(dp->dp_Arg2);
548 if (dp->dp_Arg4 == LINK_SOFT)
550 /* We want a soft-link. */
551 iofs->IOFS.io_Command = FSA_CREATE_SOFTLINK;
552 iofs->io_Union.io_CREATE_SOFTLINK.io_Reference = (STRPTR)dp->dp_Arg3;
554 else
556 /* We want a hard-link. */
557 struct FileHandle *fh = (struct FileHandle *)BADDR((BPTR)dp->dp_Arg3);
558 struct DevProc *dvp;
560 /* We check, if name and dest are on the same device. */
561 if ((dvp = GetDeviceProc(name, NULL)) == NULL)
563 /* TODO: Simulate packet return */
564 return;
567 if (dvp->dvp_Port != (struct MsgPort *)fh->fh_Device)
569 FreeDeviceProc(dvp);
570 SetIoErr(ERROR_RENAME_ACROSS_DEVICES);
572 /* TODO: Simulate packet return */
573 return;
576 FreeDeviceProc(dvp);
578 iofs->IOFS.io_Command = FSA_CREATE_HARDLINK;
579 iofs->io_Union.io_CREATE_HARDLINK.io_OldFile = fh->fh_Unit;
582 oldCurDir = CurrentDir((BPTR)dp->dp_Arg1);
583 DoNameAsynch(iofs, name, DOSBase);
584 CurrentDir(oldCurDir);
587 break;
589 case ACTION_READ_LINK: // ReadLink()
590 /* TODO */
591 break;
593 case ACTION_EXAMINE_ALL: // ExAll()
594 /* TODO */
595 break;
597 case ACTION_ADD_NOTIFY: // StartNotify()
599 struct NotifyRequest *notify = (struct NotifyRequest *)BADDR(dp->dp_Arg1);
600 struct FileHandle *dir;
602 iofs->IOFS.io_Command = FSA_ADD_NOTIFY;
603 iofs->io_Union.io_NOTIFY.io_NotificationRequest = notify;
605 notify->nr_MsgCount = 0;
607 if (strchr(notify->nr_Name, ':') != NULL)
609 DoNameAsynch(iofs, notify->nr_Name, DOSBase);
611 else
613 dir = BADDR(CurrentDir(NULL));
614 CurrentDir(MKBADDR(dir)); /* Set back the current dir */
616 if (dir == NULL)
618 return;
621 iofs->IOFS.io_Device = dir->fh_Device;
622 iofs->IOFS.io_Unit = dir->fh_Unit;
624 /* Save device for EndNotify() purposes */
625 notify->nr_Handler = (struct MsgPort *) dir->fh_Device;
627 if (iofs->IOFS.io_Device == NULL)
629 return;
634 break;
636 case ACTION_REMOVE_NOTIFY: // EndNotify()
638 struct NotifyRequest *notify = (struct NotifyRequest *)BADDR(dp->dp_Arg1);
640 iofs->IOFS.io_Command = FSA_REMOVE_NOTIFY;
641 iofs->io_Union.io_NOTIFY.io_NotificationRequest = notify;
643 if (strchr(notify->nr_Name, ':'))
645 DoNameAsynch(iofs, notify->nr_Name, DOSBase);
647 else
649 iofs->IOFS.io_Device = (struct Device *)notify->nr_Handler;
651 if (iofs->IOFS.io_Device == NULL)
653 return;
658 break;
661 /* The following five packets are only relative to the
662 message port of the file system to send to. Therefore,
663 we fill in only partial information in the IOFileSys and
664 hope for the best... Specifically, the device cannot
665 use iofs->io_Device. TODO */
666 case ACTION_RENAME_DISK: // Relabel()
667 /* TODO */
668 break;
670 case ACTION_FORMAT: // Format()
671 /* TODO */
672 break;
674 case ACTION_MORE_CACHE: // AddBuffers()
675 /* TODO */
676 break;
678 case ACTION_INHIBIT: // Inhibit()
679 /* TODO */
680 break;
682 case ACTION_IS_FILESYSTEM: // IsFileSystem()
683 /* TODO */
684 break;
686 case ACTION_DISK_INFO: // Info()
687 /* TODO */
688 break;
690 case ACTION_INFO: // No associated function
691 /* TODO */
692 break;
694 case ACTION_CURRENT_VOLUME: // No associated function
695 /* TODO */
696 break;
698 case ACTION_PARENT_FH: // ParentOfFH()
699 /* TODO -- Should be the same as ACTION_PARENT? For some reason
700 ParentDir() and ParentOfFH() is implemented differently
701 in AROS. Have to investigate this further. */
702 break;
704 case ACTION_FH_FROM_LOCK: // OpenFromLock()
705 /* TODO: Have so simulate ReplyMsg() here */
706 return;
708 case ACTION_SET_OWNER: // SetOwner()
709 // Unfortunately, I have no info regardning this packet.
711 // iofs->IOFS.io_Command = FSA_SET_OWNER;
712 // iofs->io_Union.io_SET_OWNER.io_UID = owner_info >> 16;
713 // iofs->io_Union.io_SET_OWNER.io_GID = owner_info & 0xffff;
715 break;
717 case ACTION_CHANGE_MODE: // ChangeMode()
718 /* TODO */
719 break;
721 /* I haven't looked into the following packets in detail */
722 case ACTION_DIE: // No associated function
723 break;
725 case ACTION_WRITE_PROTECT: // No associated function
726 break;
728 case ACTION_FLUSH: // No associated function
729 break;
731 case ACTION_SERIALIZE_DISK: // No associated function
732 break;
735 // --- Console only packets ------------------------------
736 /* I think these should not be implemented as packets except
737 for ACTION_WAIT_CHAR which is not really a console only
738 packet. Instead functions should be added to console.device */
740 case ACTION_SCREEN_MODE: // SetMode()
741 /* TODO*/
742 break;
744 case ACTION_CHANGE_SIGNAL: // No associated function
746 struct MsgPort *msgport;
747 struct Task *task;
749 fh = (struct FileHandle *)dp->dp_Arg1;
750 msgport = (struct MsgPort *)dp->dp_Arg2;
751 task = msgport ? msgport->mp_SigTask : NULL;
753 iofs->IOFS.io_Device = fh->fh_Device;
754 iofs->IOFS.io_Unit = fh->fh_Unit;
756 iofs->IOFS.io_Command = FSA_CHANGE_SIGNAL;
757 iofs->io_Union.io_CHANGE_SIGNAL.io_Task = task;
759 break;
761 case ACTION_WAIT_CHAR: // WaitForChar()
762 /* TODO */
763 break;
765 default:
766 kprintf("Unknown packet type %d found in SendPkt()\n",
767 dp->dp_Type);
768 return;
771 kprintf("Calling SendIO() with command %u\n", iofs->IOFS.io_Command);
773 SendIO((struct IORequest *)iofs);
776 AROS_LIBFUNC_EXIT
777 } /* SendPkt */
780 LONG DoNameAsynch(struct IOFileSys *iofs, STRPTR name,
781 struct DosLibrary *DOSBase)
783 STRPTR volname, pathname, s1 = NULL;
784 BPTR cur, lock = (BPTR)NULL;
785 struct DosList *dl;
786 struct Device *device;
787 struct Unit *unit;
788 struct FileHandle *fh;
789 struct Process *me = (struct Process *)FindTask(NULL);
791 if (!Strnicmp(name, "PROGDIR:", 8) && me->pr_HomeDir)
793 cur = me->pr_HomeDir;
794 volname = NULL;
795 pathname = name + 8;
797 else if (*name == ':')
799 cur = me->pr_CurrentDir;
800 volname = NULL;
801 pathname = name + 1;
803 else
805 /* Copy volume name */
806 cur = me->pr_CurrentDir;
807 s1 = name;
808 pathname = name;
809 volname = NULL;
811 while (*s1)
813 if (*s1++ == ':')
815 volname = (STRPTR)AllocMem(s1-name, MEMF_ANY);
817 if (volname == NULL)
819 return ERROR_NO_FREE_STORE;
822 CopyMem(name, volname, s1 - name - 1);
824 volname[s1 - name - 1] = '\0';
825 pathname = s1;
826 break;
831 if (!volname && !cur && !DOSBase->dl_SYSLock)
833 return ERROR_OBJECT_NOT_FOUND;
836 dl = LockDosList(LDF_ALL | LDF_READ);
838 if (volname != NULL)
840 /* Find logical device */
841 dl = FindDosEntry(dl, volname, LDF_ALL);
843 if (dl == NULL)
845 UnLockDosList(LDF_ALL | LDF_READ);
846 FreeMem(volname, s1 - name);
848 return ERROR_DEVICE_NOT_MOUNTED;
850 else if (dl->dol_Type == DLT_LATE)
852 lock = Lock(dl->dol_misc.dol_assign.dol_AssignName, SHARED_LOCK);
853 UnLockDosList(LDF_ALL | LDF_READ);
855 if (lock != NULL)
857 AssignLock(volname, lock);
858 dl = LockDosList(LDF_ALL | LDF_READ);
859 dl = FindDosEntry(dl, volname, LDF_ALL);
861 if (dl == NULL)
863 UnLockDosList(LDF_ALL | LDF_READ);
864 FreeMem(volname, s1 - name);
866 return ERROR_DEVICE_NOT_MOUNTED;
869 device = dl->dol_Ext.dol_AROS.dol_Device;
870 unit = dl->dol_Ext.dol_AROS.dol_Unit;
872 else
874 FreeMem(volname, s1 - name);
876 return IoErr();
879 else if (dl->dol_Type == DLT_NONBINDING)
881 lock = Lock(dl->dol_misc.dol_assign.dol_AssignName, SHARED_LOCK);
882 fh = (struct FileHandle *)BADDR(lock);
884 if (fh != NULL)
886 device = fh->fh_Device;
887 unit = fh->fh_Unit;
889 else
891 UnLockDosList(LDF_ALL | LDF_READ);
892 FreeMem(volname, s1 - name);
894 return IoErr();
897 else
899 device = dl->dol_Ext.dol_AROS.dol_Device;
900 unit = dl->dol_Ext.dol_AROS.dol_Unit;
903 else if (cur)
905 fh = (struct FileHandle *)BADDR(cur);
906 device = fh->fh_Device;
907 unit = fh->fh_Unit;
909 else
911 #if 0
912 /* stegerg: ?? */
913 device = DOSBase->dl_NulHandler;
914 unit = DOSBase->dl_NulLock;
915 #else
916 fh = (struct FileHandle *)BADDR(DOSBase->dl_SYSLock);
917 device = fh->fh_Device;
918 unit = fh->fh_Unit;
919 #endif
922 iofs->IOFS.io_Device = device;
923 iofs->IOFS.io_Unit = unit;
924 iofs->io_Union.io_NamedFile.io_Filename = pathname;
926 if (volname != NULL)
928 FreeMem(volname, s1 - name);
931 return 0;