1 #ifndef DOS_DOSEXTENS_H
2 #define DOS_DOSEXTENS_H
5 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
8 Desc: LibBase and some important structures
13 # include <exec/types.h>
16 # include <exec/tasks.h>
19 # include <exec/ports.h>
21 #ifndef EXEC_LIBRARIES_H
22 # include <exec/libraries.h>
24 #ifndef EXEC_DEVICES_H
25 # include <exec/devices.h>
27 #ifndef EXEC_SEMAPHORES
28 # include <exec/semaphores.h>
30 #ifndef DEVICES_TIMER_H
31 # include <devices/timer.h>
33 #ifndef EXEC_INTERRUPTS_H
34 # include <exec/interrupts.h>
40 /**********************************************************************
41 ***************************** DosLibrary *****************************
42 **********************************************************************/
44 /* This is how the base of dos.library looks like. */
47 /* A normal library-base as defined in <exec/libraries.h>. */
48 struct Library dl_lib
;
50 struct RootNode
* dl_Root
;
52 /* private BCPL fields. Do not use. */
58 /* The following fields are PRIVATE! */
59 struct ErrorString
* dl_Errors
;
60 struct timerequest
* dl_TimeReq
;
61 struct Library
* dl_UtilityBase
;
62 struct Library
* dl_IntuitionBase
;
65 /* dl_Flags/rn_Flags */
66 #define RNB_WILDSTAR 24 /* Activate '*' as wildcard character. */
67 #define RNF_WILDSTAR (1L << RNB_WILDSTAR)
72 /* (IPTR *) Pointer to an array containing pointers to CLI processes.
73 The CLI process number is equal to the index of that array. The
74 first field (index 0) contains the maximal number of CLI processes.
75 See also rn_CliList. */
77 /* (void *) Pointer to the SegList for CLIs. */
78 BPTR rn_ConsoleSegment
;
79 /* The current time. */
80 struct DateStamp rn_Time
;
81 /* (APTR) The SegList of the process that handles validation of devices.
84 /* (struct DosInfo *) see below for DosInfo */
86 /* BPTR to default (FFS) filesystem, used for example by WB C:Mount
87 * when mountlist filesystem is not specified */
88 BPTR rn_FileHandlerSegment
;
89 /* List of all CLI processes (struct CliProcList - see below). See also
91 struct MinList rn_CliList
;
92 /* Message port of boot filesystem. (PRIVATE) */
93 struct MsgPort
* rn_BootProc
;
94 /* (void *) Pointer to the SegList for shells. */
96 /* Additional flags (see above). */
99 /* RootNode arbitrator */
100 struct SignalSemaphore rn_RootLock
;
104 /* Structure that is linked into the rootnode's rn_CliList. Completely
105 private, of course! ... and it's not compatible to AmigaOS. */
109 struct Process
*ci_Process
;
114 BPTR di_McName
; /* Used as resident segment list (says official documentation but it is wrong) */
115 BPTR di_DevInfo
; /* Devices list */
116 BPTR di_Devices
; /* Reserved */
117 BPTR di_Handlers
; /* Reserved */
118 BPTR di_NetHand
; /* Reserved (actually resident segment list) */
120 /* The following semaphores are PRIVATE. */
121 struct SignalSemaphore di_DevLock
;
122 struct SignalSemaphore di_EntryLock
;
123 struct SignalSemaphore di_DeleteLock
;
125 #define di_ResList di_NetHand
127 /**********************************************************************
128 ***************************** Processes ******************************
129 **********************************************************************/
131 /* Standard process structure. Processes are just extended tasks. */
134 /* Embedded task structure as defined in <exec/tasks.h>. */
137 /* Processes standard message-port. Used for various puposes. */
138 struct MsgPort pr_MsgPort
;
139 WORD pr_Pad
; /* PRIVATE */
140 /* SegList array, used by this process. (void **) */
142 /* StackSize of the current process. */
145 /* CLI process number. This may be 0, in which case the process is not
146 connected to a CLI. */
148 /* Pointer to upper end of stack. (void *) */
150 /* Secondary return-value, as defined in <dos/dos.h>. As of now this
151 field is declared PRIVATE. Use IoErr()/SetIoErr() to access it. */
153 /* Lock of the current directory. As of now this is declared READ-ONLY.
154 Use CurrentDir() to set it. (struct FileLock *) */
156 /* Standard input file. As of now this is declared WRITE-ONLY. Use
157 Input() to query it. */
159 /* Standard output file. As of now this is declared WRITE-ONLY. Use
160 Output() to query it. */
162 /* Task to handle the console associated with process. */
164 /* The task that is responsible for handling the filesystem. */
165 APTR pr_FileSystemTask
;
166 /* CLI the process is connected to. (struct CommandLineInterface *) */
169 /* Function to be called, when process waits for a packet-message. */
171 /* Standard-Window of process. */
173 /* Lock to home-directory of process. (struct FileLock *) */
175 LONG pr_Flags
; /* see below */
177 /* Code that is called, when the process exits. pr_ExitData takes an
178 argument to be passed to this code. */
179 void (* pr_ExitCode
)();
181 /* Arguments passed to the process from caller. */
184 /* List of local environment variables. This list should be in
185 alphabetical order. Multiple entries may have the same name, if they
186 are of different types. See <dos/var.h> for more information. */
187 struct MinList pr_LocalVars
;
188 ULONG pr_ShellPrivate
;
189 /* Standard error file. May be NULL, in which case pr_COS is to be used.
190 Use this instead of Output() to report errors. */
194 /* pr_Flags (all PRIVATE) They mainly descibe what happens if the process
195 exits, i.e. which resources the process should clean itself. The flags
196 are self-explaining. */
197 #define PRB_FREESEGLIST 0
198 #define PRB_FREECURRDIR 1
199 #define PRB_FREECLI 2
200 #define PRB_CLOSEINPUT 3
201 #define PRB_CLOSEOUTPUT 4
202 #define PRB_FREEARGS 5
203 #define PRB_CLOSEERROR 6
204 /* The following are AROS-specific */
205 #define PRB_SYNCHRONOUS 18
206 #define PRB_WAITINGFORCHILD 19 /* This one is subject to change! */
207 #define PRB_NOTIFYONDEATH 20
209 #define PRF_FREESEGLIST (1L << PRB_FREESEGLIST)
210 #define PRF_FREECURRDIR (1L << PRB_FREECURRDIR)
211 #define PRF_FREECLI (1L << PRB_FREECLI)
212 #define PRF_CLOSEINPUT (1L << PRB_CLOSEINPUT)
213 #define PRF_CLOSEOUTPUT (1L << PRB_CLOSEOUTPUT)
214 #define PRF_FREEARGS (1L << PRB_FREEARGS)
215 #define PRF_CLOSEERROR (1L << PRB_CLOSEERROR)
216 #define PRF_SYNCHRONOUS (1L << PRB_SYNCHRONOUS)
217 #define PRF_WAITINGFORCHILD (1L << PRB_WAITINGFORCHILD)
218 #define PRF_NOTIFYONDEATH (1L << PRB_NOTIFYONDEATH)
220 /* Structure used for CLIs and Shells. Allocate this structure with
221 AllocDosObject() only! */
222 struct CommandLineInterface
224 /* Secondary error code, set by last command. */
226 /* Name of the current directory. */
228 /* Lock of the first directory in path. (struct FileLock *) */
230 /* Error code, the last command returned. See <dos/dos.h> for
233 /* Name of the command that is currently executed. */
234 BSTR cli_CommandName
;
235 /* Fail-Level as set by the command "FailAt". */
237 /* Current prompt in the CLI window. */
239 /* Standard/Default input file. (struct FileLock *) */
240 BPTR cli_StandardInput
;
241 /* Current input file. (struct FileLock *) */
242 BPTR cli_CurrentInput
;
243 /* Name of the file that is currently executed. */
244 BSTR cli_CommandFile
;
245 /* TRUE if the currently CLI is connected to a controlling terminal,
247 LONG cli_Interactive
;
248 /* FALSE if there is no controlling terminal, otherwise TRUE. */
250 /* Current output file. (struct FileLock *) */
251 BPTR cli_CurrentOutput
;
252 /* Default stack size as set by the command "Stack". */
253 LONG cli_DefaultStack
;
254 /* Standard/Default output file. (struct FileLock *) */
255 BPTR cli_StandardOutput
;
256 /* SegList of currently loaded command. */
259 /* Here begins the aros specific part */
260 /* Standard/Default Error file. (struct FileLock *) */
261 BPTR cli_StandardError
;
264 /* CLI_DEFAULTSTACK_UNIT * cli_DefaultStack = stack in bytes */
266 #define CLI_DEFAULTSTACK_UNIT sizeof(IPTR)
268 /* Devices process structure as returned by GetDeviceProc(). */
271 struct MsgPort
* dvp_Port
;
272 BPTR dvp_Lock
; /* struct FileLock * */
273 ULONG dvp_Flags
; /* see below */
274 struct DosList
* dvp_DevNode
; /* PRIVATE */
278 #define DVPB_UNLOCK 0
279 #define DVPB_ASSIGN 1
280 #define DVPF_UNLOCK (1L<<DVPB_UNLOCK)
281 #define DVPF_ASSIGN (1L<<DVPB_ASSIGN)
283 /**********************************************************************
284 ******************************* Files ********************************
285 **********************************************************************/
287 /* Standard file-handle as returned by Open() (as BPTR). Generally said, you
288 should not use this structure in any way and only use library-calls to
289 access files. Note that this structure is very different to the structure
290 used in AmigaOS! Treat this structure as PRIVATE. If you want to create
291 this structure nevertheless, use AllocDosObject(). */
294 /* The next three are used with packet-based filesystems */
296 LONG fh_Interactive
; /* interactive handle flag */
297 struct MsgPort
* fh_Type
; /* port to send packets to */
310 IPTR fh_BufSize
; /* Size of buffered io buffer */
311 BPTR fh_OrigBuf
; /* Always the same as fh_Buf */
316 /* The next three are used with packet-based filesystems */
318 LONG fh_Interactive
; /* interactive handle flag */
319 struct MsgPort
* fh_Type
; /* port to send packets to */
332 ULONG fh_BufSize
; /* Size of buffered io buffer */
333 BPTR fh_OrigBuf
; /* Always the same as fh_Buf */
337 #define FileHandle FileHandle64
339 #define FileHandle FileHandle32
342 /* Original AmigaOS aliases */
343 #define fh_Port fh_Interactive
344 #define fh_Func1 fh_Funcs
345 #define fh_Arg1 fh_Args
347 /* Structure of a lock. This is provided as it may be required internally by
348 * packet-based filesystems.
352 BPTR fl_Link
; /* (struct FileLock *) Pointer to next lock. */
355 struct MsgPort
* fl_Task
;
356 BPTR fl_Volume
; /* (struct DeviceList * - see below) */
359 /* Constants, defining of what kind a file is. These constants are used in
360 many structures, including FileInfoBlock (<dos/dos.h>) and ExAllData
362 #define ST_PIPEFILE -5 /* File is a pipe */
363 #define ST_LINKFILE -4 /* Hard link to a file */
364 #define ST_FILE -3 /* Plain file */
365 #define ST_ROOT 1 /* Root directory of filesystem */
366 #define ST_USERDIR 2 /* Normal directory */
367 #define ST_SOFTLINK 3 /* Soft link (may be a file or directory) */
368 #define ST_LINKDIR 4 /* Hard link to a directory */
370 /**********************************************************************
371 ****************************** DosLists ******************************
372 **********************************************************************/
374 /* This structure is returned by LockDosList() and similar calls. This
375 * structure is identical the AmigaOS one, but this structure is PRIVATE
376 * anyway. Use system-calls for dos list-handling.
380 /* PRIVATE pointer to next entry. */
382 /* Type of the current node (see below). */
384 /* Filesystem task handling this entry (for old-style filesystems) */
385 struct MsgPort
* dol_Task
;
386 /* The lock passed to AssignLock(). Only set if the type is
390 /* This union combines all the different types. */
392 /* See struct DevInfo below. */
401 /* See struct DeviceList below. */
403 struct DateStamp dol_VolumeDate
;
408 /* Structure used for assigns. */
410 /* The name for the late or nonbinding assign. */
411 UBYTE
*dol_AssignName
;
412 /* A list of locks, used by AssignAdd(). */
413 struct AssignList
*dol_List
;
417 /* Name as a BCPL string */
421 /* dol_Type/dl_Type/dvi_Type. Given to MakeDosEntry(). */
422 #define DLT_DEVICE 0 /* A real filesystem (or similar) */
423 #define DLT_DIRECTORY 1 /* Just a simple assign */
424 #define DLT_VOLUME 2 /* Volume node (for removable media) */
425 #define DLT_LATE 3 /* Late binding assign (not yet) */
426 #define DLT_NONBINDING 4 /* Nonbinding assign (not yet) */
429 /* The following structures are essentially the same as DosList above. The
430 difference is that they support just one type of entry. You can use them
431 instead of DosList if you have a list containing just one type of
432 entry. For more information see above.
433 Note that these two entries have the same size, and dl_Name has the same
434 offset. Also they have to correspond to the union above.
440 LONG dl_Type
; /* see above, always = DLT_VOLUME */
441 struct MsgPort
* dl_Task
;
444 struct DateStamp dl_VolumeDate
; /* At this date the volume was created. */
445 /* ULONG padding is inserted here on 64 bits */
446 BPTR dl_LockList
; /* (void *) List of all locks on the volume. */
447 LONG dl_DiskType
; /* Type of the disk. (see <dos/dos.h> for definitions) */
448 /* ULONG padding is inserted here on 64 bits */
449 BPTR dl_unused
; /* PRIVATE */
455 /* Structure that describes a device. This is essentially the same structure
456 as DeviceNode, defined in <dos/filehandler.h>. */
460 LONG dvi_Type
; /* see above, always = DLT_DEVICE */
461 struct MsgPort
* dvi_Task
;
464 BSTR dvi_Handler
; /* Device name for handler. */
465 LONG dvi_StackSize
; /* Packet-handler initial stack size */
466 LONG dvi_Priority
; /* Packet-handler initial priority */
467 BPTR dvi_Startup
; /* (struct FileSysStartupMsg *) */
468 BPTR dvi_SegList
; /* SegList for the handler */
469 BPTR dvi_GlobalVec
; /* Global Vector, should be (BPTR)-1 */
474 /* Dos list scanning and locking modes as used in LockDosList() */
475 /* Specify either LDF_READ, if you want a non-exclusive lock, or LDF_WRITE,
476 if you want an exclusive lock (i.e. if you want to modify the list).
478 #define LDB_READ 0 /* Non-exclusive/read lock */
479 #define LDB_WRITE 1 /* Exclusive/write lock */
480 /* Specify which list(s) to lock. */
481 #define LDB_DEVICES 2 /* Device list */
482 #define LDB_VOLUMES 3 /* Volume list */
483 #define LDB_ASSIGNS 4 /* Assign list */
487 #define LDF_READ (1L<<LDB_READ)
488 #define LDF_WRITE (1L<<LDB_WRITE)
489 #define LDF_DEVICES (1L<<LDB_DEVICES)
490 #define LDF_VOLUMES (1L<<LDB_VOLUMES)
491 #define LDF_ASSIGNS (1L<<LDB_ASSIGNS)
492 #define LDF_ENTRY (1L<<LDB_ENTRY)
493 #define LDF_DELETE (1L<<LDB_DELETE)
494 #define LDF_ALL (LDF_DEVICES | LDF_VOLUMES | LDF_ASSIGNS)
497 /* Used for assigns that point to multiple directories. */
500 struct AssignList
* al_Next
; /* Pointer to next assign node. */
501 BPTR al_Lock
; /* (struct FileLock *) Lock of on of the
505 /**********************************************************************
506 ********************** Low Level File Handling ***********************
507 **********************************************************************/
509 /* Allocate this structure with AllocDosObject(). */
512 struct Message
* dp_Link
; /* Pointer to a standard exec message. */
513 struct MsgPort
* dp_Port
; /* Reply-Port of that packet. */
515 LONG dp_Type
; /* see below */
516 SIPTR dp_Res1
; /* Normal return value. */
517 SIPTR dp_Res2
; /* Secondary return value (as returned by IoErr()). See
518 <dos/dos.h> for possible values. */
520 /* The actual data. */
529 #define dp_Action dp_Type
530 #define dp_Status dp_Res1
531 #define dp_Status2 dp_Res2
532 #define dp_BufAddr dp_Arg1
535 /* These are defined for DOS Packet filesystems, and are
536 * passed by DoPkt(), SendPkt(), and others
541 #define ACTION_STARTUP 0
542 #define ACTION_GET_BLOCK 2 /* Obsolete */
543 #define ACTION_SET_MAP 4
545 #define ACTION_EVENT 6
546 #define ACTION_CURRENT_VOLUME 7
547 #define ACTION_LOCATE_OBJECT 8
548 #define ACTION_RENAME_DISK 9
549 #define ACTION_FREE_LOCK 15
550 #define ACTION_DELETE_OBJECT 16
551 #define ACTION_RENAME_OBJECT 17
552 #define ACTION_MORE_CACHE 18
553 #define ACTION_COPY_DIR 19
554 #define ACTION_WAIT_CHAR 20
555 #define ACTION_SET_PROTECT 21
556 #define ACTION_CREATE_DIR 22
557 #define ACTION_EXAMINE_OBJECT 23
558 #define ACTION_EXAMINE_NEXT 24
559 #define ACTION_DISK_INFO 25
560 #define ACTION_INFO 26
561 #define ACTION_FLUSH 27
562 #define ACTION_SET_COMMENT 28
563 #define ACTION_PARENT 29
564 #define ACTION_TIMER 30
565 #define ACTION_INHIBIT 31
566 #define ACTION_DISK_TYPE 32
567 #define ACTION_DISK_CHANGE 33
568 #define ACTION_SET_DATE 34
569 #define ACTION_SAME_LOCK 40
571 #define ACTION_WRITE 'W'
572 #define ACTION_READ 'R'
574 #define ACTION_SCREEN_MODE 994
575 #define ACTION_CHANGE_SIGNAL 995
576 #define ACTION_READ_RETURN 1001
577 #define ACTION_WRITE_RETURN 1002
578 #define ACTION_FINDUPDATE 1004
579 #define ACTION_FINDINPUT 1005
580 #define ACTION_FINDOUTPUT 1006
581 #define ACTION_END 1007
582 #define ACTION_SEEK 1008
583 #define ACTION_FORMAT 1020
584 #define ACTION_MAKE_LINK 1021
585 #define ACTION_SET_FILE_SIZE 1022
586 #define ACTION_WRITE_PROTECT 1023
587 #define ACTION_READ_LINK 1024
588 #define ACTION_FH_FROM_LOCK 1026
589 #define ACTION_IS_FILESYSTEM 1027
590 #define ACTION_CHANGE_MODE 1028
591 #define ACTION_COPY_DIR_FH 1030
592 #define ACTION_PARENT_FH 1031
593 #define ACTION_EXAMINE_ALL 1033
594 #define ACTION_EXAMINE_FH 1034
595 #define ACTION_EXAMINE_ALL_END 1035
596 #define ACTION_SET_OWNER 1036
598 #define ACTION_LOCK_RECORD 2008
599 #define ACTION_FREE_RECORD 2009
601 #define ACTION_ADD_NOTIFY 4097
602 #define ACTION_REMOVE_NOTIFY 4098
604 #define ACTION_SERIALIZE_DISK 4200
606 #define ACTION_CHANGE_FILE_POSITION64 8001
607 #define ACTION_GET_FILE_POSITION64 8002
608 #define ACTION_CHANGE_FILE_SIZE64 8003
609 #define ACTION_GET_FILE_SIZE64 8004
611 /* Structure for easy handling of DosPackets. DosPackets don't have to be in
612 this structure, but this struture may ease the use of it. */
613 struct StandardPacket
615 struct Message sp_Msg
;
616 struct DosPacket sp_Pkt
;
620 /* NOTE: AROS doesn't use startup packets. This will ONLY make a difference
621 for shell writers... */
623 /* Types of command execution */
624 #define RUN_EXECUTE -1
625 #define RUN_SYSTEM -2
626 #define RUN_SYSTEM_ASYNCH -3
629 /**********************************************************************
630 ****************************** Segments ******************************
631 **********************************************************************/
633 /* Resident list structure as returned by AddSegment(). */
636 BPTR seg_Next
; /* Pointer to next segment. */
637 LONG seg_UC
; /* Usage count/type */
638 BPTR seg_Seg
; /* Actual Segment */
639 UBYTE seg_Name
[4]; /* The first characters of the name (BSTR). */
642 #define CMD_SYSTEM -1
643 #define CMD_INTERNAL -2
644 #define CMD_DISABLED -999
646 /**********************************************************************
647 *************************** Error Handling ***************************
648 **********************************************************************/
656 /* Return values for ErrorReport(). */
657 #define REPORT_STREAM 0
658 #define REPORT_TASK 1
659 #define REPORT_LOCK 2
660 #define REPORT_VOLUME 3
661 #define REPORT_INSERT 4
663 #define ABORT_BUSY 288
664 #define ABORT_DISK_ERROR 296
666 #endif /* DOS_DOSEXTENS_H */