2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
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>
16 #include <proto/utility.h>
18 /* TODO: This can be done much better! */
19 #ifndef AROS_FAST_BPTR
20 #define BStrtoCStr(bstr) ({ \
22 cstr = AllocMem(AROS_BSTR_strlen(bstr)+1, MEMF_PUBLIC); \
25 CopyMem(AROS_BSTR_ADDR(bstr), cstr, AROS_BSTR_strlen(bstr)); \
26 cstr[AROS_BSTR_strlen(bstr)] = 0; \
31 #define BStrtoCStr(bstr) ((STRPTR)bstr)
35 LONG
DoNameAsynch(struct IOFileSys
*iofs
, STRPTR name
,
36 struct DosLibrary
*DOSBase
);
38 /*****************************************************************************
41 #include <proto/dos.h>
43 AROS_LH3(void, SendPkt
,
46 AROS_LHA(struct DosPacket
*, dp
, D1
),
47 AROS_LHA(struct MsgPort
*, port
, D2
),
48 AROS_LHA(struct MsgPort
*, replyport
, D3
),
51 struct DosLibrary
*, DOSBase
, 41, Dos
)
55 Send a packet to a handler without waiting for the result. The packet will
56 be returned to 'replyport'.
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
66 This function is callable from a task.
76 DoPkt(), WaitPkt(), AbortPkt()
80 *****************************************************************************/
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
;
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...
127 case ACTION_READ_RETURN
:
128 case ACTION_WRITE_RETURN
:
130 kprintf("This packet is a reserved one and should not be sent"
135 // case ACTION_GET_BLOCK:
136 case ACTION_DISK_CHANGE
:
137 case ACTION_DISK_TYPE
:
141 kprintf("This packet is obsolete. (ACTION type %d)\n",
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
),
157 CurrentDir(oldCurDir
);
161 kprintf("Error: Didn't find file\n");
165 kprintf("Returned from DoNameAsynch()\n");
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
),
181 CurrentDir(oldCurDir
);
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
),
203 CurrentDir(oldCurDir
);
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
;
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
;
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
)
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
;
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
;
274 case ACTION_EXAMINE_FH
: // ExamineFH()
275 case ACTION_EXAMINE_OBJECT
: // Examine() [*] -- the same thing
278 UBYTE
*buffer
= AllocVec(sizeof(struct ExAllData
),
279 MEMF_PUBLIC
| MEMF_CLEAR
);
283 dp
->dp_Res1
= DOSFALSE
;
284 dp
->dp_Res2
= ERROR_NO_FREE_STORE
;
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 */
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
;
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;
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
;
344 case ACTION_RENAME_OBJECT
: // Rename()
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
;
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
;
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
);
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
);
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
);
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
;
429 iofs
->io_Union
.io_OPEN
.io_FileMode
= FMF_LOCK
| FMF_READ
;
433 iofs
->io_Union
.io_OPEN
.io_FileMode
= FMF_READ
;
437 iofs
->io_Union
.io_OPEN
.io_FileMode
= dp
->dp_Arg3
;
441 oldCurDir
= CurrentDir((BPTR
)dp
->dp_Arg1
);
442 result
= DoNameAsynch(iofs
, BStrtoCStr((BSTR
)dp
->dp_Arg2
),
444 CurrentDir(oldCurDir
);
451 dp
->dp_Arg6
= (IPTR
)AllocDosObject(DOS_FILEHANDLE
, NULL
);
453 if (dp
->dp_Arg6
== (IPTR
)NULL
)
460 case ACTION_COPY_DIR
: // DupLock()
461 case ACTION_COPY_DIR_FH
: // DupLockFromFH() -- the same thing
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
);
482 dp
->dp_Arg6
= (IPTR
)AllocDosObject(DOS_FILEHANDLE
, NULL
);
484 if (dp
->dp_Arg6
== (IPTR
)NULL
)
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
)
505 iofs
->IOFS
.io_Command
= FSA_CLOSE
;
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
),
522 CurrentDir(oldCurDir
);
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
);
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
;
556 /* We want a hard-link. */
557 struct FileHandle
*fh
= (struct FileHandle
*)BADDR((BPTR
)dp
->dp_Arg3
);
560 /* We check, if name and dest are on the same device. */
561 if ((dvp
= GetDeviceProc(name
, NULL
)) == NULL
)
563 /* TODO: Simulate packet return */
567 if (dvp
->dvp_Port
!= (struct MsgPort
*)fh
->fh_Device
)
570 SetIoErr(ERROR_RENAME_ACROSS_DEVICES
);
572 /* TODO: Simulate packet return */
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
);
589 case ACTION_READ_LINK
: // ReadLink()
593 case ACTION_EXAMINE_ALL
: // ExAll()
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
);
613 dir
= BADDR(CurrentDir(NULL
));
614 CurrentDir(MKBADDR(dir
)); /* Set back the current dir */
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
)
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
);
649 iofs
->IOFS
.io_Device
= (struct Device
*)notify
->nr_Handler
;
651 if (iofs
->IOFS
.io_Device
== NULL
)
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()
670 case ACTION_FORMAT
: // Format()
674 case ACTION_MORE_CACHE
: // AddBuffers()
678 case ACTION_INHIBIT
: // Inhibit()
682 case ACTION_IS_FILESYSTEM
: // IsFileSystem()
686 case ACTION_DISK_INFO
: // Info()
690 case ACTION_INFO
: // No associated function
694 case ACTION_CURRENT_VOLUME
: // No associated function
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. */
704 case ACTION_FH_FROM_LOCK
: // OpenFromLock()
705 /* TODO: Have so simulate ReplyMsg() here */
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;
717 case ACTION_CHANGE_MODE
: // ChangeMode()
721 /* I haven't looked into the following packets in detail */
722 case ACTION_DIE
: // No associated function
725 case ACTION_WRITE_PROTECT
: // No associated function
728 case ACTION_FLUSH
: // No associated function
731 case ACTION_SERIALIZE_DISK
: // No associated function
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()
744 case ACTION_CHANGE_SIGNAL
: // No associated function
746 struct MsgPort
*msgport
;
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
;
761 case ACTION_WAIT_CHAR
: // WaitForChar()
766 kprintf("Unknown packet type %d found in SendPkt()\n",
771 kprintf("Calling SendIO() with command %u\n", iofs
->IOFS
.io_Command
);
773 SendIO((struct IORequest
*)iofs
);
780 LONG
DoNameAsynch(struct IOFileSys
*iofs
, STRPTR name
,
781 struct DosLibrary
*DOSBase
)
783 STRPTR volname
, pathname
, s1
= NULL
;
784 BPTR cur
, lock
= (BPTR
)NULL
;
786 struct Device
*device
;
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
;
797 else if (*name
== ':')
799 cur
= me
->pr_CurrentDir
;
805 /* Copy volume name */
806 cur
= me
->pr_CurrentDir
;
815 volname
= (STRPTR
)AllocMem(s1
-name
, MEMF_ANY
);
819 return ERROR_NO_FREE_STORE
;
822 CopyMem(name
, volname
, s1
- name
- 1);
824 volname
[s1
- name
- 1] = '\0';
831 if (!volname
&& !cur
&& !DOSBase
->dl_SYSLock
)
833 return ERROR_OBJECT_NOT_FOUND
;
836 dl
= LockDosList(LDF_ALL
| LDF_READ
);
840 /* Find logical device */
841 dl
= FindDosEntry(dl
, volname
, LDF_ALL
);
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
);
857 AssignLock(volname
, lock
);
858 dl
= LockDosList(LDF_ALL
| LDF_READ
);
859 dl
= FindDosEntry(dl
, volname
, LDF_ALL
);
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
;
874 FreeMem(volname
, s1
- name
);
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
);
886 device
= fh
->fh_Device
;
891 UnLockDosList(LDF_ALL
| LDF_READ
);
892 FreeMem(volname
, s1
- name
);
899 device
= dl
->dol_Ext
.dol_AROS
.dol_Device
;
900 unit
= dl
->dol_Ext
.dol_AROS
.dol_Unit
;
905 fh
= (struct FileHandle
*)BADDR(cur
);
906 device
= fh
->fh_Device
;
913 device
= DOSBase
->dl_NulHandler
;
914 unit
= DOSBase
->dl_NulLock
;
916 fh
= (struct FileHandle
*)BADDR(DOSBase
->dl_SYSLock
);
917 device
= fh
->fh_Device
;
922 iofs
->IOFS
.io_Device
= device
;
923 iofs
->IOFS
.io_Unit
= unit
;
924 iofs
->io_Union
.io_NamedFile
.io_Filename
= pathname
;
928 FreeMem(volname
, s1
- name
);