5 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
8 Desc: Basic DOS structures and constants
13 # include <exec/types.h>
16 # include <dos/bptr.h>
19 # include <aros/macros.h>
22 /* The name of the dos.library. Use this constant instead of the string. */
23 #define DOSNAME "dos.library"
25 /* These constants may be used, but preferably, you should only test for
26 (un-)equality against DOSFALSE (i.e. 0). */
28 #define DOSFALSE ( 0L)
30 /**********************************************************************
31 ******************************* Dates ********************************
32 **********************************************************************/
34 /* Other structures and defines for handling dates and time can be found in
37 /* Number of so-called "ticks" in a second. */
38 #define TICKS_PER_SECOND 50
40 /* DateStamp structure as used in different library-functions. This
41 structure sufficiently describes a system-date and -time (i.e. any
42 date since 1.1.1978). */
45 LONG ds_Days
; /* Number of days since 1.1.1978 */
46 LONG ds_Minute
; /* Number of minutes since midnight */
47 LONG ds_Tick
; /* Number of ticks (1/50 second) in the current minute
48 Note that this may not be exact */
51 /**********************************************************************
52 ******************************* Files ********************************
53 **********************************************************************/
55 /* The maximum length of filenames in AmigaOS. You should not depend on
56 this value, as it may change in future versions. */
57 #define MAXFILENAMELENGTH 108
59 /* The maximum length of comments in AmigaOS. You should not depend on
60 this value, as it may change in future versions. */
61 #define MAXCOMMENTLENGTH 80
63 /* Structure used to describe a directory entry. Note that not all fields
64 are supported by all filesystems. This structure should be allocated
65 with AllocDosObject(). */
66 struct FileInfoBlock64
69 /* See <dos/dosextens.h> for definitions. Generally: if this is >= 0
70 the file described is a directory, otherwise it is a plain file. */
71 LONG fib_DirEntryType
;
74 * User applications should always treat this as ASCIIZ.
76 * NOTE: This is created as a BCPL string in the ACTION_EXAMINE_*
77 * filesystem handler code, but is converted to a C style
78 * '\0'-terminated string by the Dos/Examine???() functions.
81 UBYTE fib_FileName
[MAXFILENAMELENGTH
];
82 LONG fib_Protection
; /* The protection bits (see below). */
84 UQUAD fib_Size
; /* The size of the file. */
85 UQUAD fib_NumBlocks
; /* Number of blocks used for file. */
86 struct DateStamp fib_Date
; /* Date of last change to file. */
87 /* The filecomment. Follows the same BSTR/CSTR rules as fib_FileName */
88 UBYTE fib_Comment
[MAXCOMMENTLENGTH
];
89 UWORD fib_OwnerUID
; /* UserID of fileowner. */
90 UWORD fib_OwnerGID
; /* GroupID of fileowner. */
91 UBYTE fib_Reserved
[32]; /* PRIVATE */
94 struct FileInfoBlock32
97 /* See <dos/dosextens.h> for definitions. Generally: if this is >= 0
98 the file described is a directory, otherwise it is a plain file. */
99 LONG fib_DirEntryType
;
102 * User applications should always treat this as ASCIIZ.
104 * NOTE: This is created as a BCPL string in the ACTION_EXAMINE_*
105 * filesystem handler code, but is converted to a C style
106 * '\0'-terminated string by the Dos/Examine???() functions.
109 UBYTE fib_FileName
[MAXFILENAMELENGTH
];
110 LONG fib_Protection
; /* The protection bits (see below). */
112 LONG fib_Size
; /* The size of the file. */
113 LONG fib_NumBlocks
; /* Number of blocks used for file. */
114 struct DateStamp fib_Date
; /* Date of last change to file. */
115 /* The filecomment. Follows the same BSTR/CSTR rules as fib_FileName */
116 UBYTE fib_Comment
[MAXCOMMENTLENGTH
];
117 UWORD fib_OwnerUID
; /* UserID of fileowner. */
118 UWORD fib_OwnerGID
; /* GroupID of fileowner. */
119 UBYTE fib_Reserved
[32]; /* PRIVATE */
123 #define FileInfoBlock FileInfoBlock64
125 #define FileInfoBlock FileInfoBlock32
128 /* Protection bits for files (fib_Protection). */
129 /* Flags for owner (they are active-low, i.e. not set means the action is
131 #define FIBB_DELETE 0 /* File is deleteable. */
132 #define FIBB_EXECUTE 1 /* File is executable (no scripts!). */
133 #define FIBB_WRITE 2 /* File is writable. */
134 #define FIBB_READ 3 /* File is readable. */
135 /* General flags, not owner-dependant. */
136 #define FIBB_ARCHIVE 4 /* File was archived (not used by OS). */
137 #define FIBB_PURE 5 /* Make program resident on execution. */
138 #define FIBB_SCRIPT 6 /* File is a script (DOS or ARexx). */
139 /* Flag number 7 is not defined. It used to describe different conditions
140 in different revisions of AmigaOS and was also misused as hidden flag.
141 Because of this confusion, this flag should not be used! */
142 /* Flags for group (meaning see above, these are high-active!). */
143 #define FIBB_GRP_DELETE 8
144 #define FIBB_GRP_EXECUTE 9
145 #define FIBB_GRP_WRITE 10
146 #define FIBB_GRP_READ 11
147 /* Flags for other/world (meaning see above, these are high-active!). */
148 #define FIBB_OTR_DELETE 12
149 #define FIBB_OTR_EXECUTE 13
150 #define FIBB_OTR_WRITE 14
151 #define FIBB_OTR_READ 15
153 #define FIBF_DELETE (1<<FIBB_DELETE)
154 #define FIBF_EXECUTE (1<<FIBB_EXECUTE)
155 #define FIBF_WRITE (1<<FIBB_WRITE)
156 #define FIBF_READ (1<<FIBB_READ)
157 #define FIBF_ARCHIVE (1<<FIBB_ARCHIVE)
158 #define FIBF_PURE (1<<FIBB_PURE)
159 #define FIBF_SCRIPT (1<<FIBB_SCRIPT)
160 #define FIBF_GRP_DELETE (1<<FIBB_GRP_DELETE)
161 #define FIBF_GRP_EXECUTE (1<<FIBB_GRP_EXECUTE)
162 #define FIBF_GRP_WRITE (1<<FIBB_GRP_WRITE)
163 #define FIBF_GRP_READ (1<<FIBB_GRP_READ)
164 #define FIBF_OTR_DELETE (1<<FIBB_OTR_DELETE)
165 #define FIBF_OTR_EXECUTE (1<<FIBB_OTR_EXECUTE)
166 #define FIBF_OTR_WRITE (1<<FIBB_OTR_WRITE)
167 #define FIBF_OTR_READ (1<<FIBB_OTR_READ)
169 /**********************************************************************
170 ****************************** Devices *******************************
171 **********************************************************************/
173 /* Structure used in Info(). Must be longword-aligned. */
176 LONG id_NumSoftErrors
; /* Number of soft errors on device. */
177 LONG id_UnitNumber
; /* Unit number of device. */
178 LONG id_DiskState
; /* State the current volume is in (see below). */
179 UQUAD id_NumBlocks
; /* Number of blocks on device. */
180 UQUAD id_NumBlocksUsed
; /* Number of blocks in use. */
181 LONG id_BytesPerBlock
; /* Bytes per block. */
182 LONG id_DiskType
; /* Type of disk (see below). */
184 IPTR id_InUse
; /* Set, if device is in use. */
189 LONG id_NumSoftErrors
; /* Number of soft errors on device. */
190 LONG id_UnitNumber
; /* Unit number of device. */
191 LONG id_DiskState
; /* State the current volume is in (see below). */
192 LONG id_NumBlocks
; /* Number of blocks on device. */
193 LONG id_NumBlocksUsed
; /* Number of blocks in use. */
194 LONG id_BytesPerBlock
; /* Bytes per block. */
195 LONG id_DiskType
; /* Type of disk (see below). */
197 IPTR id_InUse
; /* Set, if device is in use. */
201 #define InfoData InfoData64
203 #define InfoData InfoData32
207 #define ID_WRITE_PROTECTED 80 /* Volume is write-protected. */
208 #define ID_VALIDATING 81 /* Volume is currently validating. */
209 #define ID_VALIDATED 82 /* Volume is ready to be read and written. */
211 /* Filesystem Id's, as used for id_DiskType.
212 These are multi-character constants of identifier strings.
213 They are self-descriptive. */
214 /* Standard AmigaOS Filesystems */
215 #define ID_NO_DISK_PRESENT (-1L)
216 #define ID_UNREADABLE_DISK AROS_MAKE_ID('B','A','D',0)
217 #define ID_DOS_DISK AROS_MAKE_ID('D','O','S',0)
218 #define ID_FFS_DISK AROS_MAKE_ID('D','O','S',1)
219 #define ID_INTER_DOS_DISK AROS_MAKE_ID('D','O','S',2)
220 #define ID_INTER_FFS_DISK AROS_MAKE_ID('D','O','S',3)
221 #define ID_FASTDIR_DOS_DISK AROS_MAKE_ID('D','O','S',4)
222 #define ID_FASTDIR_FFS_DISK AROS_MAKE_ID('D','O','S',5)
223 #define ID_NOT_REALLY_DOS AROS_MAKE_ID('N','D','O','S')
224 #define ID_KICKSTART_DISK AROS_MAKE_ID('K','I','C','K')
225 #define ID_MSDOS_DISK AROS_MAKE_ID('M','S','D',0)
227 #include <dos/filesystemids.h>
229 /**********************************************************************
230 **************** Program Execution and Error Handling ****************
231 **********************************************************************/
233 /* Return conditions for programs. */
235 /* Program succeeded. */
236 #define RETURN_WARN 5
237 /* Program succeeded, but there was something not quite right. This value
238 may also be used to express a boolean state (RETURN_WARN meaning TRUE,
239 RETURN_OK meaning FALSE). */
240 #define RETURN_ERROR 10
241 /* Program succeeded partly. This may be returned, if the user aborts a
242 program or some external data were wrong. */
243 #define RETURN_FAIL 20
244 /* Program execution failed. Normally used, if some system resources could
248 /* Secondary errors codes as used for IoErr(), SetIoErr() and in
249 Process->pr_Result2. The term 'object' refers to files of all kinds
250 (ie plain files, directories, links, etc). */
252 /* This is used, if something went wrong, but it is unknown what exactly
253 went wrong. This is especially useful for emulation devices, when the
254 underlying system returned an error that the emulation side does not
256 #define ERROR_UNKNOWN 100
259 /* General system errors */
261 #define ERROR_NO_FREE_STORE 103
262 /* Too many tasks are already running. */
263 #define ERROR_TASK_TABLE_FULL 105
265 /* Errors concerning ReadArgs(). See also <dos/rdargs.h>. */
266 /* Supplied template is broken */
267 #define ERROR_BAD_TEMPLATE 114
268 /* A supplied argument that was expected to be numeric, was not numeric.
269 This is also returned by some functions to expresss that a supplied
270 number is out of range (ie to express application internal errors). */
271 #define ERROR_BAD_NUMBER 115
272 /* An argument that has to be supplied (ie signed with the '/A' flag) was
274 #define ERROR_REQUIRED_ARG_MISSING 116
275 /* Keyword was specified, but not its contents. */
276 #define ERROR_KEY_NEEDS_ARG 117
277 /* There were more arguments than the template needs. */
278 #define ERROR_TOO_MANY_ARGS 118
279 /* An odd number of quotation marks was supplied. */
280 #define ERROR_UNMATCHED_QUOTES 119
281 /* Either the command-line was longer than hardcoded line length limit or the
282 maximum number of multiple arguments (flag '/M') was exceeded. This can
283 also indicate that some argument is too long or a supplied buffer is too
285 #define ERROR_LINE_TOO_LONG 120
287 /* Errors in files. */
288 /* You tried to execute a file that is not an executable. */
289 #define ERROR_FILE_NOT_OBJECT 121
290 /* A library or device could not be opened or that library or device is
292 #define ERROR_INVALID_RESIDENT_LIBRARY 122
293 #define ERROR_NO_DEFAULT_DIR 201
294 /* The accessed object is already in use (eg locked) by another task. */
295 #define ERROR_OBJECT_IN_USE 202
296 /* You tried to overwrite an object. */
297 #define ERROR_OBJECT_EXISTS 203
298 /* The given directory or the path of a given object does not exist. */
299 #define ERROR_DIR_NOT_FOUND 204
300 /* The given object does not exist. */
301 #define ERROR_OBJECT_NOT_FOUND 205
303 /* Miscellaneous errors. */
304 #define ERROR_BAD_STREAM_NAME 206
305 /* The given object is too large for the operation to be done. Object in
306 this context is for example a component of a path name. */
307 #define ERROR_OBJECT_TOO_LARGE 207
308 /* This is usually used to indicate that a filesystem does not support a
309 certain action, but may generally also be used by functions. */
310 #define ERROR_ACTION_NOT_KNOWN 209
311 /* A path component was invalid (eg there were multiple colons in a path
313 #define ERROR_INVALID_COMPONENT_NAME 210
314 #define ERROR_INVALID_LOCK 211
315 /* You tried to perform an action on an object, which this kind of object
316 does not support (eg makedir on a file). */
317 #define ERROR_OBJECT_WRONG_TYPE 212
318 /* Writing failed, because the volume is not validated. */
319 #define ERROR_DISK_NOT_VALIDATED 213
320 /* Writing failed, because the volume is write-protected. */
321 #define ERROR_DISK_WRITE_PROTECTED 214
322 /* You tried to move/rename a file across different devices. Rename does only
323 work on the same device, as only the inode-data has to be changed to
324 perform that action. */
325 #define ERROR_RENAME_ACROSS_DEVICES 215
326 /* You tried to delete a directory that still contains some files. Delete
327 these files first. */
328 #define ERROR_DIRECTORY_NOT_EMPTY 216
329 /* A recursive directory search could not be performed, because the stack
331 #define ERROR_TOO_MANY_LEVELS 217
332 /* You tried to access a device that is currently not mounted. */
333 #define ERROR_DEVICE_NOT_MOUNTED 218
334 /* An error occured, while executing Seek(). */
335 #define ERROR_SEEK_ERROR 219
336 /* The supplied file comment was longer than the hardcoded length limit for
338 #define ERROR_COMMENT_TOO_BIG 220
339 /* A write-operation could not be performed, because the volume has no space
341 #define ERROR_DISK_FULL 221
342 /* You tried to delete a delete-protected object. */
343 #define ERROR_DELETE_PROTECTED 222
344 /* You tried to write to a write-protected object. This does not mean that
345 the volume, you wanted to write to, is write-protected! */
346 #define ERROR_WRITE_PROTECTED 223
347 /* You tried to read a read-protected object. */
348 #define ERROR_READ_PROTECTED 224
349 /* Accessed disk is unreadable. */
350 #define ERROR_NOT_A_DOS_DISK 225
351 /* You tried to perform an action on a device that has no volume mounted
352 (eg. an empty disk drive). */
353 #define ERROR_NO_DISK 226
354 /* This does not indicate an error, but is returned by several functions to
355 indicate that the last entry of a list was reached. */
356 #define ERROR_NO_MORE_ENTRIES 232
357 /* Given action can not be performed on a given object, because it is a
358 soft-link. This is usually only used by filesystem handlers and is catched
359 by dos. Applications should not see this. */
360 #define ERROR_IS_SOFT_LINK 233
361 /* Given action can not be performed on a given object, because it is a link.
363 #define ERROR_OBJECT_LINKED 234
364 /* There was a bad hunk in a file that was to load. */
365 #define ERROR_BAD_HUNK 235
366 /* Indicates that a function does not implement a certain functionality.
367 There are more special error conditions (ERROR_BAD_NUMBER and
368 ERROR_ACTION_NOT_KNOWN), which should be preferred, if applicable. */
369 #define ERROR_NOT_IMPLEMENTED 236
370 /* You tried to access a record that was not locked. */
371 #define ERROR_RECORD_NOT_LOCKED 240
372 /* Somebody already locked a part of the record, you wanted to lock. */
373 #define ERROR_LOCK_COLLISION 241
374 /* LockRecord() timed out. */
375 #define ERROR_LOCK_TIMEOUT 242
376 /* An error occured, while unlocking a record. */
377 #define ERROR_UNLOCK_ERROR 243
379 /* Further errors are defined in dosasl.h amd filesystem.h as well */
381 /* Maximum length of strings got from Fault(). Note that they should be
382 shorter than 60 characters. */
385 /* Signals that are set, if the user presses the corresponding keys on
386 the controlling terminal. They may also be sent by using Signal().
387 For more information see <exec/tasks.h>. */
388 #define SIGBREAKB_CTRL_C 12 /* CTRL-c, usually meaning program abortion. */
389 #define SIGBREAKB_CTRL_D 13 /* CTRL-d */
390 #define SIGBREAKB_CTRL_E 14 /* CTRL-e, usually meaning that the application
391 should iconify itself. */
392 #define SIGBREAKB_CTRL_F 15 /* CTRL-f, usually meaning that the application
393 should uniconify itself. */
395 #define SIGBREAKF_CTRL_C (1L<<SIGBREAKB_CTRL_C)
396 #define SIGBREAKF_CTRL_D (1L<<SIGBREAKB_CTRL_D)
397 #define SIGBREAKF_CTRL_E (1L<<SIGBREAKB_CTRL_E)
398 #define SIGBREAKF_CTRL_F (1L<<SIGBREAKB_CTRL_F)
400 /**********************************************************************
401 ********************** Constants for Functions ***********************
402 **********************************************************************/
404 /* Modes for Open(). */
405 /* Try to open old file. If it does not exist, Open() returns an error. */
406 #define MODE_OLDFILE 1005
407 /* A new file is created, even if a file with the supplied name does
409 #define MODE_NEWFILE 1006
410 /* An old file is opened. If it does not exist, a new one is created. */
411 #define MODE_READWRITE 1004
413 /* Locking mechanism as used in Lock() */
414 /* Non-exclusive lock, other tasks may lock this file as well. This is used
415 for read-only operations. */
416 #define SHARED_LOCK -2
417 #define ACCESS_READ -2
418 /* Exclusive lock, other tasks may not lock this file. This is used for write
420 #define EXCLUSIVE_LOCK -1
421 #define ACCESS_WRITE -1
423 /* Returned by SameLock(). See autodocs for description. */
424 #define LOCK_DIFFERENT -1
426 #define LOCK_SAME_VOLUME 1
428 /* Used in MakeLink() */
433 #define OFFSET_BEGINNING -1
434 #define OFFSET_CURRENT 0
437 /* Limits of the "int" type */
438 #define MAXINT ((int)(((unsigned int)~0)/2))
439 #define MININT (-MAXINT - 1)
441 /* Used in ChangeMode() */
442 #define CHANGE_LOCK 0
445 /* Returned by ReadItem() */
446 #define ITEM_EQUAL -2
447 #define ITEM_ERROR -1
448 #define ITEM_NOTHING 0
449 #define ITEM_UNQUOTED 1
450 #define ITEM_QUOTED 2
452 /* The types for AllocDosObject() and FreeDosObject(). They specifiy which
453 kind of structure is to be allocated. */
454 #define DOS_FILEHANDLE 0 /* struct FileHandle <dos/dosextens.h> */
455 #define DOS_EXALLCONTROL 1 /* struct ExAllControl <dos/exall.h> */
456 #define DOS_FIB 2 /* struct FileInfoBlock (see above) */
457 #define DOS_STDPKT 3 /* struct DosPacket <dos/dosextens.h> */
458 #define DOS_CLI 4 /* struct CommandLineInterface <dos/dosextens.h> */
459 #define DOS_RDARGS 5 /* struct RDArgs <dos/rdargs.h> */
461 #endif /* DOS_DOS_H */