1 #ifndef DOS_FILESYSTEM_H
2 #define DOS_FILESYSTEM_H
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 Desc: AROS specific structures and definitions for filesystems.
16 # include <exec/tasks.h>
21 #ifndef DOS_FILEHANDLER_H
22 # include <dos/filehandler.h>
25 # include <dos/exall.h>
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
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
70 STRPTR io_Filename
; /* File to open. */
71 ULONG io_FileMode
; /* see below */
74 /* Closes an opened filehandle. Takes no extra arguments. */
77 /* Reads from a filehandle into a buffer. */
81 /* The buffer for the data to read/to write. */
83 /* The length of the buffer. This is filled by the filesystem handler
84 with the number of bytes actually read/written. */
88 /* Writes the contents of a buffer into a filehandle. Uses IFS_READ_WRITE. */
91 /* The action does exactly the same as the function Seek(). */
95 /* Offset from position, specified as mode. This is filled by the
96 filehandler with the old position in the file. */
98 /* Seek mode as defined in <dos/dos.h> (OFFSET_#?). */
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
108 #define FSA_WAIT_CHAR 7
111 /* Maximum time (in microseconds) to wait for a character. */
113 /* This is set to FALSE by the filehandler, if no character arrived in
114 time. Otherwise it is set to TRUE. */
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
123 /* The new mode to apply to the filehandle. See below for definitions.
124 The filehandler fills this with the old mode bits. */
126 /* This mask defines which flags are to be changed. */
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
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
149 /* Examines a filehandle, giving various information about it. */
150 #define FSA_EXAMINE 11
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. */
161 #define FSA_EXAMINE_NEXT 12
162 struct IFS_EXAMINE_NEXT
164 /* FileInfoBlock structure buffer to be used and filled by the
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. */
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
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
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
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
226 #define FSA_RENAME 19
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. */
241 /* The size of the buffer pointed to by io_Buffer. */
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
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
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
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. */
308 /* Formats a volume, ie erases all data on it. */
309 #define FSA_FORMAT 28
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. */
325 /* This mask defines, which flags are to be changed. */
327 /* A password, which is needed if MMF_LOCKED is set. */
331 /* The following actions are currently not supported. */
333 #define FSA_SERIALIZE_DISK 30
337 #define FSA_INHIBIT 32
345 #define FSA_WRITE_PROTECT 33
346 #define FSA_DISK_CHANGE 34
349 #define FSA_ADD_NOTIFY 35
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
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
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 */
393 Allows us to change a console between raw and cooked mode.
395 #define FSA_CONSOLE_MODE 43
396 struct IFS_CONSOLE_MODE
401 #define FCM_RAW (1<<0)
402 #define FCM_NOECHO (1<<1)
405 #define FSA_RELABEL 44
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. */
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()
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
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. */
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
476 /* This union contains all the data needed for the various actions. */
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
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
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 */
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 */