added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / compiler / include / dos / filesystem.h
blobe2dbc81e2f1a57d9a20ac44c7c2660ecd65b53e7
1 #ifndef DOS_FILESYSTEM_H
2 #define DOS_FILESYSTEM_H
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: AROS specific structures and definitions for filesystems.
9 Lang: english
12 #ifndef EXEC_IO_H
13 # include <exec/io.h>
14 #endif
15 #ifndef EXEC_TASKS_H
16 # include <exec/tasks.h>
17 #endif
18 #ifndef DOS_DOS_H
19 # include <dos/dos.h>
20 #endif
21 #ifndef DOS_FILEHANDLER_H
22 # include <dos/filehandler.h>
23 #endif
24 #ifndef DOS_EXALL_H
25 # include <dos/exall.h>
26 #endif
28 /* This file is AROS specific. Do not use the structures and #defines contained
29 in here if you want to stay compatible with AmigaOS! */
32 /* Filesystem handlers are called with so-called actions, whenever they are
33 supposed to do something. See below for a list of currently defined actions
34 and how to use them.
36 Not all filesystems have to support all actions. Filesystems have to return
37 ERROR_ACTION_NOT_KNOWN (<dos/dos.h>) in IOFileSys->io_DosError, if they do
38 not support the specified action. If they know an action but ignore it on
39 purpose, they may return ERROR_NOT_IMPLEMENTED. A purpose may be that the
40 hardware or software the filesystem relies on does not support this kind of
41 action (eg: a net-filesystem protocol may not support renaming of files, so
42 a filesystem handler for this protocol should return ERROR_NOT_IMPLEMENTED
43 for FSA_RENAME). Another example is the nil-device, which does not implement
44 FSA_CREATE_DIR or anything concerning specific files. What does that mean
45 for an application? If an application receives ERROR_NOT_IMPLEMENTED, it
46 knows that the action, it wanted to perform, makes no sense for that
47 filesystem. If it receives ERROR_ACTION_NOT_KNOWN, it knows that the
48 filesystem does not know about this action for whatever reason (including
49 that it makes no sense to perform that action on that specific filesystem).
51 All actions work relative to the current directory (where it makes sense),
52 set in the IOFileSys->IOFS.io_Unit field. This field also serves as a
53 pointer to filehandles for actions that either need a filehandle as argument
54 or return one. When not explicitly stated otherwise this field has to be set
55 to the filehandle to affect or is set to the filehandle that is returned by
56 the action. Note that the filehandle mentioned above is not a pointer to a
57 struct FileHandle as defined in <dos/dosextens.h>, but is an APTR to a
58 device specific blackbox structure. In a struct FileHandle this private
59 pointer is normally to be found in FileHandle->fh_Unit.
61 Whenever a filename is required as argument, this filename has to be
62 stripped from the devicename, ie it has to be relative to the current
63 directory on that volume (set in the io_Unit field). */
65 /* Returns a new filehandle. The file may be newly created (depending on
66 io_FileMode. */
67 #define FSA_OPEN 1
68 struct IFS_OPEN
70 STRPTR io_Filename; /* File to open. */
71 ULONG io_FileMode; /* see below */
74 /* Closes an opened filehandle. Takes no extra arguments. */
75 #define FSA_CLOSE 2
77 /* Reads from a filehandle into a buffer. */
78 #define FSA_READ 3
79 struct IFS_READ_WRITE
81 /* The buffer for the data to read/to write. */
82 char * io_Buffer;
83 /* The length of the buffer. This is filled by the filesystem handler
84 with the number of bytes actually read/written. */
85 LONG io_Length;
88 /* Writes the contents of a buffer into a filehandle. Uses IFS_READ_WRITE. */
89 #define FSA_WRITE 4
91 /* The action does exactly the same as the function Seek(). */
92 #define FSA_SEEK 5
93 struct IFS_SEEK
95 /* Offset from position, specified as mode. This is filled by the
96 filehandler with the old position in the file. */
97 QUAD io_Offset;
98 /* Seek mode as defined in <dos/dos.h> (OFFSET_#?). */
99 LONG io_SeekMode;
102 /* Sets the size of filehandle. Uses IFS_SEEK (see above) as argument array. */
103 #define FSA_SET_FILE_SIZE 6
105 /* Waits for a character to arrive at the filehandle. This is not used for
106 plain files, but for queues only. Optionally a maximum time to wait may be
107 specified. */
108 #define FSA_WAIT_CHAR 7
109 struct IFS_WAIT_CHAR
111 /* Maximum time (in microseconds) to wait for a character. */
112 LONG io_Timeout;
113 /* This is set to FALSE by the filehandler, if no character arrived in
114 time. Otherwise it is set to TRUE. */
115 BOOL io_Success;
118 /* Applies a new mode to a file. If you supply io_Mask with a value of 0,
119 no changes are made and you can just read the resulting io_FileMode. */
120 #define FSA_FILE_MODE 8
121 struct IFS_FILE_MODE
123 /* The new mode to apply to the filehandle. See below for definitions.
124 The filehandler fills this with the old mode bits. */
125 ULONG io_FileMode;
126 /* This mask defines which flags are to be changed. */
127 ULONG io_Mask;
130 /* This action can be used to query if a filehandle is interactive, ie if it
131 is a terminal or not. */
132 #define FSA_IS_INTERACTIVE 9
133 struct IFS_IS_INTERACTIVE
135 /* This boolean is filled by the filehandler. It is set to TRUE, if the
136 filehandle is interactive, otherwise it is set to FALSE. */
137 BOOL io_IsInteractive;
140 /* Compares two locks for equality. */
141 #define FSA_SAME_LOCK 10
142 struct IFS_SAME_LOCK
144 APTR io_Lock[2]; /* The two locks to compare. */
145 LONG io_Same; /* This is set to one of LOCK_DIFFERENT or LOCK_SAME (see
146 <dos/dos.h>). */
149 /* Examines a filehandle, giving various information about it. */
150 #define FSA_EXAMINE 11
151 struct IFS_EXAMINE
153 /* ExAllData structure buffer to be filled by the filehandler. */
154 struct ExAllData * io_ead;
155 LONG io_Size; /* Size of the buffer. */
156 /* With which kind of information shall the buffer be filled with? See
157 ED_* definitions in <dos/exall.h> for more information. */
158 LONG io_Mode;
161 #define FSA_EXAMINE_NEXT 12
162 struct IFS_EXAMINE_NEXT
164 /* FileInfoBlock structure buffer to be used and filled by the
165 filehandler. */
166 struct FileInfoBlock * io_fib;
169 /* Works exactly like FSA_EXAMINE with the exeption that multiple files may be
170 examined, ie the filehandle must be a directory. */
171 #define FSA_EXAMINE_ALL 13
172 struct IFS_EXAMINE_ALL
174 /* ExAllData structure buffer to be filled by the filehandler. */
175 struct ExAllData * io_ead;
176 struct ExAllControl *io_eac;
177 LONG io_Size; /* Size of the buffer. */
178 /* With which kind of information shall the buffer be filled with? See
179 ED_* definitions in <dos/exall.h> for more information. */
180 LONG io_Mode;
183 /* This has to be called, if FSA_EXAMINE_ALL is stopped before all examined
184 files were returned. It takes no arguments except the filehandle in
185 io_Unit. */
186 #define FSA_EXAMINE_ALL_END 14
188 /* Works exactly like FSA_OPEN, but you can additionally specify protection
189 bits to be applied to new files. */
190 #define FSA_OPEN_FILE 15
191 struct IFS_OPEN_FILE
193 STRPTR io_Filename; /* File to open. */
194 ULONG io_FileMode; /* see below */
195 ULONG io_Protection; /* The protection bits. */
198 /* Creates a new directory. The filehandle of that new directory is returned.
200 #define FSA_CREATE_DIR 16
201 struct IFS_CREATE_DIR
203 STRPTR io_Filename; /* Name of directory to create. */
204 ULONG io_Protection; /* The protection bits. */
207 /* Creates a hard link (ie gives one file a second name). */
208 #define FSA_CREATE_HARDLINK 17
209 struct IFS_CREATE_HARDLINK
211 STRPTR io_Filename; /* The filename of the link to create. */
212 APTR io_OldFile; /* Filehandle of the file to link to. */
215 /* Creates a soft link (ie a file is created, which references another by its
216 name). */
217 #define FSA_CREATE_SOFTLINK 18
218 struct IFS_CREATE_SOFTLINK
220 STRPTR io_Filename; /* The filename of the link to create. */
221 STRPTR io_Reference; /* The name of the file to link to. */
224 /* Renames a file. To the old and the new name, the current directory is
225 applied to. */
226 #define FSA_RENAME 19
227 struct IFS_RENAME
229 STRPTR io_Filename; /* The old filename. */
230 STRPTR io_NewName; /* The new filename. */
233 /* Resolves the full path name of the file a softlink filehandle points to. */
234 #define FSA_READ_SOFTLINK 20
235 struct IFS_READ_SOFTLINK
237 STRPTR io_Filename; /* file name which returned ERROR_IS_SOFT_LINK */
238 /* The buffer to fill with the pathname. If this buffer is too small, the
239 filesystem handler is supposed to return ERROR_LINE_TOO_LONG. */
240 STRPTR io_Buffer;
241 /* The size of the buffer pointed to by io_Buffer. */
242 ULONG io_Size;
245 /* Deletes an object on the volume. */
246 #define FSA_DELETE_OBJECT 21
247 struct IFS_DELETE_OBJECT
249 STRPTR io_Filename; /* The name of the file to delete. */
252 /* Sets a filecomment for a file. */
253 #define FSA_SET_COMMENT 22
254 struct IFS_SET_COMMENT
256 STRPTR io_Filename; /* The name of the file to be commented. */
257 STRPTR io_Comment; /* The new filecomment. May be NULL, in which case the
258 current filecomment is deleted. */
261 /* Sets the protection bits of a file. */
262 #define FSA_SET_PROTECT 23
263 struct IFS_SET_PROTECT
265 STRPTR io_Filename; /* The file to change. */
266 ULONG io_Protection; /* The new protection bits. */
269 /* Sets the ownership of a file. */
270 #define FSA_SET_OWNER 24
271 struct IFS_SET_OWNER
273 STRPTR io_Filename; /* The file to change. */
274 UWORD io_UID; /* The new owner. */
275 UWORD io_GID; /* The new group owner. */
278 /* Sets the last modification date of the filename given as first argument.
279 The date is given as standard TimeStamp structure (see <dos/dos.h>) as
280 second to fourth argument (ie as days, minutes and ticks). */
281 #define FSA_SET_DATE 25
282 struct IFS_SET_DATE
284 STRPTR io_Filename; /* The file to change. */
285 struct DateStamp io_Date; /* The new date. (see <dos/dosextens.h>) */
288 /* Check if a filesystem is in fact a FILEsystem, ie can contain different
289 files. */
290 #define FSA_IS_FILESYSTEM 26
291 struct IFS_IS_FILESYSTEM
293 /* This is set to TRUE by the filesystem handler, if it is a filesystem
294 and set to FALSE if it is not. */
295 BOOL io_IsFilesystem;
298 /* Changes the number of buffers for the filesystem. The current number of
299 buffers is returned. The size of the buffers is filesystem-dependent. */
300 #define FSA_MORE_CACHE 27
301 struct IFS_MORE_CACHE
303 /* Number of buffers to add. May be negative to reduce number of buffers.
304 This is to be set to the current number of buffers on success. */
305 LONG io_NumBuffers;
308 /* Formats a volume, ie erases all data on it. */
309 #define FSA_FORMAT 28
310 struct IFS_FORMAT
312 STRPTR io_VolumeName; /* New name for the volume. */
313 ULONG io_DosType; /* New type for the volume. Filesystem specific. */
316 /* Resets/Reads the mount-mode of the volume passed in as io_Unit. The first
317 and second argument work exactly like FSA_FILE_MODE, but the third
318 argument can contain a password, if MMF_LOCKED is set. */
319 #define FSA_MOUNT_MODE 29
320 struct IFS_MOUNT_MODE
322 /* The new mode to apply to the volume. See below for definitions. The
323 filehandler fills this with the old mode bits. */
324 ULONG io_MountMode;
325 /* This mask defines, which flags are to be changed. */
326 ULONG io_Mask;
327 /* A password, which is needed if MMF_LOCKED is set. */
328 STRPTR io_Password;
331 /* The following actions are currently not supported. */
332 #if 0
333 #define FSA_SERIALIZE_DISK 30
334 #define FSA_FLUSH 31
335 #endif
337 #define FSA_INHIBIT 32
338 struct IFS_INHIBIT
340 BOOL io_Inhibit;
344 #if 0
345 #define FSA_WRITE_PROTECT 33
346 #define FSA_DISK_CHANGE 34
347 #endif
349 #define FSA_ADD_NOTIFY 35
350 struct IFS_NOTIFY
352 STRPTR io_FileName; /* Needed for synchronous operation */
353 struct NotifyRequest *io_NotificationRequest;
356 /* Uses IFS_NOTIFY */
357 #define FSA_REMOVE_NOTIFY 36
359 #define FSA_DISK_INFO 37
360 struct IFS_INFO
362 struct InfoData *io_Info;
365 #define FSA_CHANGE_SIGNAL 38
366 struct IFS_CHANGE_SIGNAL
368 struct Task *io_Task;
371 #define FSA_LOCK_RECORD 39
372 struct IFS_RECORD
374 QUAD io_Offset;
375 LONG io_Size;
376 ULONG io_RecordMode;
377 ULONG io_Timeout;
380 #define FSA_UNLOCK_RECORD 40
383 #define FSA_PARENT_DIR 41
384 #define FSA_PARENT_DIR_POST 42
385 struct IFS_PARENT_DIR
387 /* this will contain the return value of the parent directory or
388 NULL, if we are at the root directory already */
389 char * io_DirName;
393 Allows us to change a console between raw and cooked mode.
395 #define FSA_CONSOLE_MODE 43
396 struct IFS_CONSOLE_MODE
398 LONG io_ConsoleMode;
400 #define FCM_COOKED 0
401 #define FCM_RAW (1<<0)
402 #define FCM_NOECHO (1<<1)
405 #define FSA_RELABEL 44
406 struct IFS_RELABEL
408 STRPTR io_NewName;
409 BOOL io_Result;
412 /* FSA_PIPE: create a pair of handles connected to each other
414 * This opens a "file" (which will usually be a pipe device) and returns two
415 * handles such that writing data to the writer will result in that data
416 * appearing on the reader. Both handles must be closed for the underlying
417 * file to be closed. If a NULL/empty path is supplied, an unnamed pipe will
418 * be created, which will be destroyed once both handles are closed.
420 * The read handle is returned in io_Unit. */
421 #define FSA_PIPE 45
422 struct IFS_PIPE {
423 STRPTR io_FileName;
424 struct Unit *io_Writer;
429 /* io_FileMode for FSA_OPEN, FSA_OPEN_FILE and FSA_FILE_MODE. These are flags
430 and may be or'ed. Note that not all filesystems support all flags. */
431 #define FMF_LOCK (1L<<0) /* Lock exclusively. */
432 #define FMF_EXECUTE (1L<<1) /* Open for executing. */
433 /* At least one of the following two flags must be specified. Otherwise expect
434 strange things to happen. */
435 #define FMF_WRITE (1L<<2) /* Open for writing. */
436 #define FMF_READ (1L<<3) /* Open for reading. */
437 #define FMF_CREATE (1L<<4) /* Create file if it doesn't exist. */
438 #define FMF_CLEAR (1L<<5) /* Truncate file on open. */
439 #define FMF_RAW (1L<<6) /* Switch cooked to raw and vice versa. */
440 #define FMF_NONBLOCK (1L<<7) /* Don't block Open() in case it would
441 and return an error in case Write()/Read()
442 would block */
443 #define FMF_APPEND (1L<<8) /* Every write will happen always at the end of the file */
445 #define FMF_AMIGADOS (1L<<9 | 1L<<31) /* Identifies the old AmigaDOS modes:
446 - bit 9 is the first bit set in the MODE_#? modes
447 - bit 31 is the first bit set in ACCESS_#? modes
449 #define FMF_MODE_OLDFILE (FMF_AMIGADOS | FMF_WRITE | FMF_READ)
450 #define FMF_MODE_READWRITE (FMF_MODE_OLDFILE | FMF_CREATE)
451 #define FMF_MODE_NEWFILE (FMF_MODE_READWRITE | FMF_LOCK | FMF_CLEAR)
453 /* io_MountMode for FSA_MOUNT_MODE. These are flags and may be or'ed. */
454 #define MMF_READ (1L<<0) /* Mounted for reading. */
455 #define MMF_WRITE (1L<<1) /* Mounted for writing. */
456 #define MMF_READ_CACHE (1L<<2) /* Read cache enabled. */
457 #define MMF_WRITE_CACHE (1L<<3) /* Write cache enabled. */
458 #define MMF_OFFLINE (1L<<4) /* Filesystem currently does not use the
459 device. */
460 #define MMF_LOCKED (1L<<5) /* Mount mode is password protected. */
463 /* This structure is an extended IORequest (see <exec/io.h>). It is used for
464 requesting actions from AROS filesystem handlers.
465 Note that this structure may grow in the future. Do not depend on its size!
466 You may use sizeof(struct IOFileSys) nevertheless if you are reserving
467 memory for a struct IOFileSys as the size of it will never shrink. */
468 struct IOFileSys
470 struct IORequest IOFS; /* Standard I/O request. */
471 LONG io_DosError; /* Dos error code. */
472 struct DosPacket *io_PacketEmulation; /* Private */
473 LONG io_DirPos; /* The result from telldir() is stored
474 here */
476 /* This union contains all the data needed for the various actions. */
477 union
479 struct {
480 STRPTR io_DeviceName; /* Name of the device to open. */
481 IPTR io_Unit; /* Number of unit to open. */
482 IPTR * io_Environ; /* Pointer to environment array.
483 (see <dos/filehandler.h> */
484 STRPTR io_DosName; /* The name with wich the
485 filesystem is being mounted
486 (the mount point, one might
487 say) */
488 struct DeviceNode *io_DeviceNode; /* The DOS entry for this
489 filesystem. Packet-based
490 filesystems expect to receive
491 this along with the the
492 startup message */
493 } io_OpenDevice;
495 struct {
496 STRPTR io_Filename;
497 } io_NamedFile;
499 struct IFS_OPEN io_OPEN; /* FSA_OPEN */
500 struct IFS_READ_WRITE io_READ_WRITE; /* FSA_READ, FSA_WRITE */
501 #define io_READ io_READ_WRITE
502 #define io_WRITE io_READ_WRITE
503 struct IFS_SEEK io_SEEK; /* FSA_SEEK */
504 #define io_SET_FILE_SIZE io_SEEK
505 struct IFS_WAIT_CHAR io_WAIT_CHAR; /* FSA_WAIT_CHAR */
506 struct IFS_FILE_MODE io_FILE_MODE; /* FSA_FILE_MODE */
507 struct IFS_IS_INTERACTIVE io_IS_INTERACTIVE; /* FSA_IS_INTERACTIVE */
508 struct IFS_SAME_LOCK io_SAME_LOCK; /* FSA_SAME_LOCK */
509 struct IFS_EXAMINE io_EXAMINE; /* FSA_EXAMINE */
510 struct IFS_EXAMINE_ALL io_EXAMINE_ALL; /* FSA_EXAMINE_ALL */
511 struct IFS_EXAMINE_NEXT io_EXAMINE_NEXT; /* FSA_EXAMINE_NEXT */
512 struct IFS_OPEN_FILE io_OPEN_FILE; /* FSA_OPEN_FILE */
513 struct IFS_CREATE_DIR io_CREATE_DIR; /* FSA_CREATE_DIR */
514 struct IFS_CREATE_HARDLINK io_CREATE_HARDLINK;/* FSA_CREATE_HARDLINK */
515 struct IFS_CREATE_SOFTLINK io_CREATE_SOFTLINK;/* FSA_CREATE_SOFTLINK */
516 struct IFS_RENAME io_RENAME; /* FSA_RENAME */
517 struct IFS_READ_SOFTLINK io_READ_SOFTLINK; /* FSA_READ_SOFTLINK */
518 struct IFS_DELETE_OBJECT io_DELETE_OBJECT; /* FSA_DELETE_OBJECT */
519 struct IFS_SET_COMMENT io_SET_COMMENT; /* FSA_SET_COMMENT */
520 struct IFS_SET_PROTECT io_SET_PROTECT; /* FSA_SET_PROTECT */
521 struct IFS_SET_OWNER io_SET_OWNER; /* FSA_SET_OWNER */
522 struct IFS_SET_DATE io_SET_DATE; /* FSA_SET_DATE */
523 struct IFS_IS_FILESYSTEM io_IS_FILESYSTEM; /* FSA_IS_FILESYSTEM */
524 struct IFS_MORE_CACHE io_MORE_CACHE; /* FSA_MORE_CACHE */
525 struct IFS_FORMAT io_FORMAT; /* FSA_FORMAT */
526 struct IFS_MOUNT_MODE io_MOUNT_MODE; /* FSA_MOUNT_MODE */
527 struct IFS_INHIBIT io_INHIBIT; /* FSA_INHIBIT */
528 struct IFS_PARENT_DIR io_PARENT_DIR; /* FSA_PARENT_DIR */
529 struct IFS_CONSOLE_MODE io_CONSOLE_MODE; /* FSA_CONSOLE_MODE */
530 struct IFS_RELABEL io_RELABEL; /* FSA_RELABEL */
531 struct IFS_NOTIFY io_NOTIFY; /* FSA_ADD_NOTIFY */
532 struct IFS_INFO io_INFO; /* FSA_INFO */
533 struct IFS_RECORD io_RECORD; /* FSA_LOCK_RECORD */
534 struct IFS_CHANGE_SIGNAL io_CHANGE_SIGNAL; /* FSA_CHANGE_SIGNAL */
535 struct IFS_PIPE io_PIPE; /* FSA_PIPE */
536 } io_Union;
539 /* Define some AROS' specific errors */
541 #define ERROR_BROKEN_PIPE 400 /* An attempt to write on a pipe without any reader has been made */
542 #define ERROR_WOULD_BLOCK 401 /* A Read() or a Write() on a file opened with the FMF_NONBLOCK flag would block */
543 #define ERROR_INTERRUPTED 402 /* The I/O file operation has been interrupted for some reasons */
544 #endif /* DOS_FILESYSTEM_H */