MagiC, just as MultiTOS, enables the incorporation of alternative filesystems (so-called XFSs) and with that the use of long filenames. However, for several reasons a different approach was chosen in MagiC to Atari's solution. This has the unfortunate consequence that the XFS's available for MultiTOS (Minix-XFS, CD-ROM-XFS, ...) cannot be used under MagiC. This chapter describes the following points:
See also: VFAT-XFS in MagiC MagiC's DFS-concept
GEMDOS was until now the most conservative part of the MagiC operating system. For network drivers, practically all DOS calls, including Pexec, had to be recreated without being able to intervene at a deeper level. In Mag!X 1.x (as in TOS) the DOS was not even reentrant because a statically constructed stack was used.
In MultiTOS/MiNT the problem is circumvented in such a way that a virtual system is laid over the GEMDOS which takes care of all higher management tasks, can incorporate other filesystems and uses GEMDOS only as a dumb filesystem driver. An advantage of this solution is its great flexibility and extendibility, but a decided drawback is the towering overhead when using the 'normal' DOS filesystem. But this is just the one that is utilized most frequently. In addition, the GEMDOS filesystem can gain no functionality, comfort or speed with the use of MiNT, since the old routines only execute with additional overhead. File-system accesses under MiNT are therefore generally not reentrant, i.e., as under MS-Windows, every floppy disk access paralyses the whole computer.
A further property of MiNT is the attempt to undertake functions that all filesystems have in common in the kernel. Although this leaves the filesystem drivers (MiNT-XFSs) compact, due to the Inode-oriented format of the kernel functions an unfavourable structure is forced on the file drivers in some circumstances; in addition, generally many calls of the filesystem driver are required for one DOS call. Finally the MiNT kernel itself is very long, but to a large extent lies fallow as long as no filesystems other than DOS are in use.
Under MagiC a different approach was chosen, which included rewriting all GEMDOS functions from the ground up, including the low-level ones for the sector buffering, and to carve them up into three, four or five layers in which one can intervene from the outside (with loaded- in drivers). A side-effect resulted in an extension of the DOS file system functionality and an additional filesystem on the logical drive U:.
The whole concept inclusive of accesses to the DOS filesystems is reentrant and runs in the background. Thus it is possible to amend files on drive A: without markedly slowing down the computer during floppy disk accesses. Despite this MagiC has till now grown only by 10kB. Compared to MiNT, more functions were offloaded into the file system drivers, and while this makes them longer, it gives them the possibility of executing the functions much more efficiently. Also, the DOS filesystem has become somewhat faster rather than slower.
Although realized completely in Assembler, we are dealing with an object-oriented operating system with virtual functions and multi- level heredity. A file descriptor (FD), as used by the kernel and made available by the XFS, is an object with special data and functions. But the XFS realizes also a derived object with further data fields and functions. Finally the DFS subdriver of the DOS_XFS must in turn accommodate further functions and data in the FD and extrapolate the class further. Things look exactly the same with the DMD (drive medium descriptor). The kernel requires only a few statements, but the lower layers appreciably more, though always different ones.
The layers in detail:
Notes:
In contrast to MiNT, U:\PROC, U:\DEV etc. are not their own
file systems but simply just subdirectories of the DFS for drive
U:. Depending on the subdirectory, the U-DFS creates various file-
types and -drivers. As the control of the directory is encumbent on the
DOS_XFS, write accesses to a workstation, for instance, are logged in
the directory by the file date-stamp. This even goes so far that a
write access to the root of drive A: will alter the file date-stamp of
U:\A automatically.
Devices, pipes and shared memory blocks can be moved, deleted or
renamed. Symbolic links can be created in all directories of drive U:;
for instance, with 'ln -s U:\CON U:\CONSOLE' one can create an alias
for the device file CON. One can also create empty files simply,
though not folders since the drive U: has no memory allocated to it.
In contrats to MiNT, U:\ is not its own special filesystem. One
just has to respect that only symbolic links can be created. The
directories U:\A etc. are simply symbolic links, which can also be
removed or renamed.
All directories of U: are restricted to 32 entries at present
The construction of all internal structures and the fast
register- based parameter passing and return requires an
implementation of all filesystems and drivers to be written in
Assembler, at least for most of the functions
The construction of the MX_DDEV file driver has changed since
MagiC V2.10. The sample driver DEV_LPT1 may not be used under MagiC
V3.00 and higher. Actually the concepts have stayed the same, only a
few constants have changed. A new sample driver is not yet available
(at the time this was written).
See also: MagiC's XFS-concept Test for pipes
Since the implementation of an XFS can only be performed in Assembler, its description is given in Assembler syntax:
xfs_name: DS.B 8 /* Name of the filesystem */ xfs_next: DS.L 1 /* Next driver */ xfs_flags: DS.L 1 /* Flags, analogous to MiNT */ xfs_init: DS.L 1 /* Initialization */ xfs_sync: DS.L 1 /* Synchronization of the filesystem */ xfs_pterm: DS.L 1 /* Notifies a program termination */ xfs_garbcoll: DS.L 1 /* Garbage collection, or NULL */ xfs_freeDD: DS.L 1 /* Releases DD */ xfs_drv_open: DS.L 1 /* Tests/initializes DMD (Mediach) */ xfs_drv_close: DS.L 1 /* Forces a disk media change */ xfs_path2DD: DS.L 1 /* Returns a DD to a pathname */ xfs_sfirst: DS.L 1 /* Searches for first matching file */ xfs_snext: DS.L 1 /* Searches for next matching file */ xfs_fopen: DS.L 1 /* Opens or creates a file */ xfs_fdelete: DS.L 1 /* Deletes a file */ xfs_link: DS.L 1 /* Required for Frename and Flink */ xfs_xattr: DS.L 1 /* Required for Fxattr */ xfs_attrib: DS.L 1 /* Required for Fattrib */ xfs_chown: DS.L 1 /* Required for Fchown */ xfs_chmod: DS.L 1 /* Required for Fchmod */ xfs_dcreate: DS.L 1 /* Creates a directory */ xfs_ddelete: DS.L 1 /* Deletes a directory */ xfs_DD2name: DS.L 1 /* Returns the absolute pathname */ xfs_dopendir: DS.L 1 /* Opens a directory */ xfs_dreaddir: DS.L 1 /* Reads the next directory entry */ xfs_drewinddir: DS.L 1 /* Sets the dirhandle to 1st entry */ xfs_dclosedir: DS.L 1 /* Closes the dirhandle */ xfs_dpathconf: DS.L 1 /* Obtains various limits */ xfs_dfree: DS.L 1 /* Obtains number of free blocks etc. */ xfs_wlabel: DS.L 1 /* Writes the disk name */ xfs_rlabel: DS.L 1 /* Reads the disk name */ xfs_symlink: DS.L 1 /* Creates a symbolic link */ xfs_readlink: DS.L 1 /* Reads a symbolic link */ xfs_dcntl: DS.L 1 /* Required for Dcntl */
See also: Make-up of a DFS MagiC's XFS-concept
Name: | »xfs_attrib« - Required for Fattrib.
| ||||||||||||
Parameters: |
| ||||||||||||
Description: | Unlike MiNT, MagiC does not implement this function as Fxattr,
because this can mean a huge overhead in some circumstances. Here
symbolic links must followed, i.e. the return of ELINK is permissible.
The function xfs_attrib is not yet carried out tidily by DOS_XFS, symbolic links are not recognised. | ||||||||||||
Group: | Make-up of an XFS
| ||||||||||||
See also: | MagiC's XFS-concept Fattrib Fxattr
|
Name: | »xfs_chmod« - Required for Fchmod.
| ||||||||
Parameters: |
| ||||||||
Description: | xfs_chmod alters the access rights of a file. The parameters
correspond to those of Fchmod. Note that symbolic links are not
followed.
It is not supported by DOS_XFS. | ||||||||
Group: | Make-up of an XFS
| ||||||||
See also: | MagiC's XFS-concept Fchmod
|
Name: | »xfs_chown« - Required for Fchown.
| ||||||||||
Parameters: |
| ||||||||||
Description: | xfs_chown alters the owner (user ID and group ID) of a file.
The parameters correspond to those of Fchown. Symbolic links are not
followed, i.e. owner and group of the symbolic link are modified.
It is not supported by DOS_XFS. | ||||||||||
Group: | Make-up of an XFS
| ||||||||||
See also: | MagiC's XFS-concept Fchown
|
Name: | »xfs_dclosedir« - schließt ein Verzeichnis
| ||||
Parameters: |
| ||||
Description: | Analogous to MiNT.
| ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept Dclosedir
|
Name: | »xfs_dcntl« - Required for Dcntl.
| ||||||||||
Parameters: |
| ||||||||||
Description: | xfs_dcntl is required for Dcntl. Every XFS should support
FUTIME.
| ||||||||||
Group: | Make-up of an XFS
| ||||||||||
See also: | MagiC's XFS-concept
|
Name: | Create a directory.
| ||||||
Parameters: |
| ||||||
Description: | xfs_dcreate is required for Dcreate.
| ||||||
Group: | Make-up of an XFS
| ||||||
See also: | MagiC's XFS-concept Dcreate
|
Name: | »xfs_ddelete« - Delete a directory.
| ||||
Parameters: |
| ||||
Description: | The call xfs_ddelete had to be altered as of MagiC Version
4.01.
For MagiC < 4.01 (kernel version < 3) the following applies: During deletion one must ensure that no directory may be referenced by the kernel except by the call itself (i.e. dd_refcnt must == 1). In addition one must ensure that there are no files in the directory. ELINK may not be returned, symbolic links may not be processed. The access rights (if they exist) must be tested by the XFS. For MagiC < 4.01 (kernel version >= 3) the following applies: Reentrance problems gave rise to some changes, whereby the kernel takes over access control from the XFS and furthermore the kernel releases the DD, not the XFS: The kernel first of all opens the parent of the directory to be deleted with xfs_path2DD, then it tests with xfs_xattr whether it is dealing with a symlink, and if appropriate deletes it with xfs_fdelete. If it is dealing with a directory, the kernel opens this again with xfs_path2DD (mode 1) and releases the parent again with xfs_freeDD. The check of dd_refcnt is performed by the kernel, hence the counter can and must be ignored by the XFS. The XFS must now ensure that the directory to be deleted or the DD cannot be opened or used by others (important for reentrant XFSs). The XFS then deletes the directory, but does not (!) release the DD, so that the kernel if successful (return value E_OK) can release its standard paths beforehand. The kernel then calls xfs_freeDD. As usual the XFS must check that the directory is empty, or if access rights exist if appropriate. Again in context:
| ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept Ddelete
|
Name: | »xfs_dfree« - Obtain number of free blocks.
| ||||||
Parameters: |
| ||||||
Description: | xfs_dfree is required for Dfree. DOS_XFS calls the appropriate
DFS driver directly.
| ||||||
Group: | Make-up of an XFS
| ||||||
See also: | MagiC's XFS-concept Dfree
|
Name: | »xfs_DD2name« - Return the absolute pathname.
| ||||||||
Parameters: |
| ||||||||
Description: | xfs_DD2name is required for Dgetpath and Dgetcwd. The path that
belongs to the passed directory is copied after name. The path
must be returned without the trailing '\', i.e. an empty string for
the root directory. bufsize, as ever, is to be interpreted as
including the terminating NULL-byte. If the buffer is too small
(bufsize shorler than the path), then as in MiNT ERANGE must
be returned.
| ||||||||
Group: | Make-up of an XFS
| ||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_dopendir« - Open a directory.
| ||||||
Parameters: |
| ||||||
Description: | xfs_dopendir is required for Dopendir. As tosflag only
0 and 1 are permitted at present. If tosflag == 0, filenames
are not truncated, and the first four bytes returned by D(x)readdir contain
the file index.
If tosflag == 1, Dreaddir must truncate the filenames to 8+3 and convert them to upper case, and may not return a file ID. | ||||||
Group: | Make-up of an XFS
| ||||||
See also: | MagiC's XFS-concept Dopendir Dreaddir Dxreaddir
|
Name: | »xfs_dpathconf« - Obtain various limits.
| ||||||||||||||||||||||||||||||||
Parameters: |
| ||||||||||||||||||||||||||||||||
Description: | Analogous to MiNT. The DOS_XFS directly calls the appropriate
DFS driver. which can take the following values:
As of the MagiC version of 21.5.95 the following are supported as well:
| ||||||||||||||||||||||||||||||||
Group: | Make-up of an XFS
| ||||||||||||||||||||||||||||||||
See also: | MagiC's XFS-concept Dpathconf
|
Name: | »xfs_dreaddir« - Read next directory entry.
| ||||||||||||
Parameters: |
| ||||||||||||
Description: | Analogous to MiNT. Supplants both Dreaddir as well as
Dxreaddir.
| ||||||||||||
Group: | Make-up of an XFS
| ||||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_drewinddir« - Set directory handle to 1st entry.
| ||||
Parameters: |
| ||||
Description: | Analogous to MiNT.
| ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept Drewinddir
|
Name: | »xfs_drv_close« - Force a disk media change.
| ||||||
Parameters: |
| ||||||
Description: | The function xfs_drv_close also performs two tasks, depending
on mode:
The internal DOS_XFS passes the call on to the DFS function of the same name, and in addition the XFS structures will be released if necessary. | ||||||
Group: | Make-up of an XFS
| ||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_drv_open« - Test/initialize the DMD (Mediach).
| ||||
Parameters: |
| ||||
Description: | MagiC supports exactly 26 simultaneously active filesystems
that are assigned letters 'A'..'Z'. xfs_drv_open has two tasks:
The internal DOS_XFS passes on the call to the DFS function of the same name, i.e. all DFS drivers are tried in turn. | ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_fdelete« - Delete a file.
| ||||||
Parameters: |
| ||||||
Description: | xfs_fdelete is required for Fdelete. When deleting a symlink,
only this may be deleted but not a referenced file. This means that a
return value of ELINK is not permissible here.
Access right checks are left completely to the XFS. During deletion one should pay attention that no file may be referenced by the kernel (i.e. fd_refcnt != 0). | ||||||
Group: | Make-up of an XFS
| ||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_flags« -Flags, analogous to MiNT.
|
Parameters: | —
|
Description: | Reserved. Should actually contain flags, but it is not used by
the MagiC kernel. So please do not use it!
|
Group: | Make-up of an XFS
|
See also: | MagiC's XFS-concept
|
Name: | »xfs_fopen« - Open or create a file.
| ||||||||||||
Parameters: |
| ||||||||||||
Description: | xfs_fopen is used by the functions Fopen and Fcreate. The
open-mode in the lower-value byte is different to MiNT, because the
MiNT modes are unfavourable for the implementation of inquiries. When
calling Fopen via TRAP #1, the MiNT modes are converted by the kernel
to the internal modes.
These are the internal modes which have to be handled by the XFS driver (NOINHERIT is not supported, because according to TOS convention only the handles 0..5 are inherited). Otherwise the high byte corresponds to the MiNT conventions: OM_RPERM EQU 1 // File is opened for reading OM_WPERM EQU 2 // File is opened for writing OM_EXEC EQU 4 // File is opened for execution OM_APPEND EQU 8 // Write accesses at end (kernel!) OM_RDENY EQU 16 // Others may not read at same time OM_WDENY EQU 32 // Others may not write at same time OM_NOCHECK EQU 64 // No check by the kernel The bit OM_APPEND is taken note of by the kernel at a Fwrite call automatically; the kernel performs an Fseek before every write access. OM_NOCHECK is set by the kernel if a file is opened or redirected (Fforce) as a device, i.e. as handle -1, -2, -3 or -4. If this bit is set, then the XFS should not perform a check for multiple opening of the file (see also below for fd_mode), but leave this to the device driver. Here are the bits, which are used as in MiNT: O_CREAT EQU $200 // Create file, if it doesn't exist O_TRUNC EQU $400 // Clear file, if it exists O_EXCL EQU $800 // Don't open file, if it exists The kernel performs Fcreate as Fopen (O_CREAT +O_RDWR + O_TRUNC). O_COMPAT (i.e. specify only the TOS mode 0, 1 or 2), is in MagiC always equivalent to O_WDENY. The checking of the access rights is completely up to the XFS, the kernel does nothing; that would be fairly pointless anyway, since every filesystem has its own mechanisms and rights. The kernel is returned a pointer to an opened FD, i.e. the opening of the file driver must be performed by the XFS. The reference counter of the returned FD is to be incremented by the XFS, or initialized as 1 at the first opening. For symbolic links and disk media changes the same applies as for xfs_sfirst. Fopen is implemented as follows under MiNT:
This procedure is very protracted. DOS returns a pointer to the 32-byte directory entry already when searching for a file, which serves directly for the checking of the attributes and with that the access rights, and also for opening the file. Hence MagiC expects direct implementation of the Fopen call with all checks of the access rights. The return is an FD structure, in which the file driver was entered and opened. | ||||||||||||
Group: | Make-up of an XFS
| ||||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_freeDD« - Release a DD.
| ||||
Parameters: |
| ||||
Description: | The kernel has decremeted the reference counter of a DD to
0, so that the DD is no longer referenced by the kernel. The function
xfs_freeDD is called, say, when the kernel after the Fopen no longer
requires the path in which the opened file lies and which was passed
to xfs_fopen. XFSs that do not perform garbage collection can release
their DDs via this function.
One must ensure that the root is never released. Either one builds in a special inquiry here, or (more elegant) already sets the reference counter of the root with xfs_drv_open to 1. | ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_garbcoll« - Garbage collection.
| ||||
Parameters: |
| ||||
Description: | The kernel urgently requires internal GEMDOS memory and uses
xfs_garbcoll to perform a garbage collection. An XFS that does not
use the kernel's internal memory management can place a NULL-pointer
as a function here.
Warning: As many blocks as possible should be released. The return value is 1 if (at least) one block could be released. During a garbage collection the kernel runs through the whole list of mounted logical drives, so the XFS requests a garbage collection as many times as the number of drives it is managing at the time. | ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_init« - Initialization.
|
Parameters: | —
|
Description: | Reserved. For MagiC-internal XFSs it contains their
initialization. Not used with loaded-in XFSs.
|
Group: | Make-up of an XFS
|
See also: | MagiC's XFS-concept
|
Name: | »xfs_link« - Required for Frename and Flink.
| ||||||||||||
Parameters: |
| ||||||||||||
Description: | xfs_link is used both for Frename (d2 = 0) and also for Flink
(d2 = 1). In the case of Frename a new directory entry has to be
created and the old entry (reference to the file) deleted or
overwritten.
In the case of Flink a further reference to the same file is created and the old entry is not deleted. Both DDs always lie in the same filesystem, so have the same DMD. As for Fdelete, in the case of a symbolic link this has to be renamed or a further link created. This means that an ELINK return value is impermissible here (as for xfs_fdelete). Flink is not supported by the DOS_XFS. | ||||||||||||
Group: | Make-up of an XFS
| ||||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_name« - Name of the filesystem.
|
Parameters: | —
|
Description: | The name is up till now just a comment; perhaps in the future
it may offer the possibility of ascertaining which drivers are
installed and what, say, the driver responsible for drive A: is called
(i.e. what sort of filesystem the floppy disk contains).
The name of the integrated XFS is 'DOS_XFS ' (extended to 8 characters with a space). |
Group: | Make-up of an XFS
|
See also: | MagiC's XFS-concept
|
Name: | »xfs_next« - Next driver.
|
Parameters: | —
|
Description: | xfs_next is simply a chaining pointer to the next driver. A new
driver is always incorporated at the front, so always has the highest
priority. This makes it possible to load a driver in place of the
intergated DOS driver, for instance.
|
Group: | Make-up of an XFS
|
See also: | MagiC's XFS-concept
|
Name: | »xfs_path2DD« - Return a directory descriptor (DD) to a pathname.
| ||||||||||||||||||||||||||||
Parameters: |
| ||||||||||||||||||||||||||||
Description: | The kernel differentiates between two different types of
descriptors, file descriptors (FD) and directory descriptors (DD),
which can have an identical structure however. The xfs_path2DD
function returns a descriptor for a path.
The reference counter of the DD must be incremented by 1 each time it is returned as a function value, as it is referenced by the kernel. The xfs_path2DD function corresponds to an 'opening' of the path; a kind of 'file handle' is returned to the kernel, which the kernel has to close again. The parsing of the path must always be taken care of by the XFS. Input parameters:
Output parameters: 1st case: An error has arisen d0 contains the error-code 2nd case: A directory descriptor (DD) could not be obtained
3rd case: The XFS hit on a symbolic link during the )path evaluation
Warning: The length must include the terminating NULL-byte and also be even. The link has to lie at an even memory address. The buffer for the link may be static or volatile since the kernel immediately copies the data elsewhere, with no possibility of a context change happening inbetween. If a1 == NULL is passed, a signal is sent to the kernel that the parent of the root directory was selected. If the path resides, say, on U:\A, then the kernel can fall back to U:\. The value of the return register a0 is ignored by the kernel, so no reference counter may be incremented. | ||||||||||||||||||||||||||||
Group: | Make-up of an XFS
| ||||||||||||||||||||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_pterm« - Notify a program termination.
| ||||
Parameters: |
| ||||
Description: | The call xfs_pterm is made at every program termination and
gives the XFS the opportunity to release internal structures or
remove locks. The files visible to the kernel (i.e. those that are
assigned a handle) are closed by the kernel beforehand. The reference
counter for the standard directories is likewise decremented
beforehand by the kernel.
A pointer to a process descriptor is passed in a0. | ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_readlink« - Read a symbolic link.
| ||||||||||
Parameters: |
| ||||||||||
Description: | xfs_readlink is used for Freadlink. It is supported by DOS_XFS.
| ||||||||||
Group: | Make-up of an XFS
| ||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_rlabel« - liest den Disknamen.
| ||||||||||
Parameters: |
| ||||||||||
Description: | xfs_rlabel serves for reading the medium name. It is called by
the kernel when Fsfirst with attribute == 8 is performed. name
is generally "*.*" and can be ignored. len is the
length of the buffer buf; on overflow ERANGE must be returned.
xfs_rlabel is also called for Dreadlabel. In this case name == NULL. | ||||||||||
Group: | Make-up of an XFS
| ||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_sfirst« - Search for first matching file.
| ||||||||||||
Parameters: |
| ||||||||||||
Description: | xfs_sfirst is required for Fsfirst. MiNT uses instead of this
function a combination of Dreaddir and Fxattr, which however makes
very many calls of the XFS driver necessary. The reserved area of
the DTA can be used freely by the XFS; if this is too small, one
has to proceed with similar heuristic methods to MiNT, i.e. pointers
must be entered in the DTA that point to fixed descriptors.
These descriptors however can be released again only with heuristic methods, because one never knows whether another Fsnext is coming or not. The kernel already gets the complete path with xfs_path2DD, so that only the pure pathname is passed in a1. As with all DOS calls that process a path, the XFS must ensure that the DD is protected for the duration of the processing. This is particularly critical if the filesystem is reentrant. If a file searched for is a symbolic link, then one has to pass ELINK as error-code in d0 and the pointer to the link in a0. The kernel then simply calls Fxattr} to fill the DTA. If a disk media change has occurred, then E_CHNG is to be returned; the kernel then automatically repeats the function. This also applies for all other functions. In every case xfs_dta_drive has to be initialized correctly, e.g. with: dta.dta_drive = srchdir->dd_dmd->d_drive. If E_OK or ELINK is returned without xfs_dta_drive being initialized, then the result is indeterminate. | ||||||||||||
Group: | Make-up of an XFS
| ||||||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_snext« - Search for the next matching file.
| ||||||||
Parameters: |
| ||||||||
Description: | xfs_snext is required for Fsnext. The kernel has already
obtained from the DTA the relevant filesystem whose DMD is passed
in a1. Here too a symbolic link may occur.
| ||||||||
Group: | Make-up of an XFS
| ||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_symlink« - Create a symbolic link.
| ||||||||
Parameters: |
| ||||||||
Description: | xfs_symlink is required for Fsymlink. A file has to be created
under the new name name in the directory dir that
points to the file to. The call is supported by DOS_XFS.
| ||||||||
Group: | Make-up of an XFS
| ||||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_sync« - Synchronize the filesystem.
| ||||
Parameters: |
| ||||
Description: | The kernel notifies the XFS that on drive d all the
buffers have been written back. Passed in register a0 is a pointer to
a DMD (drive medium descriptor). This is created by the kernel.
The return value will be an error-code. If the DFS does not manage the buffer (e.g. a RAMdisk), then a 0 has to be returned. The internal DOS_XFS simply calls the DFS function with the same name. | ||||
Group: | Make-up of an XFS
| ||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_wlabel« - Write the disk name.
| ||||||
Parameters: |
| ||||||
Description: | xfs_wlabel serves for (re)naming media. It is called by the
kernel when Fcreate with attribute 8 is performed. If the disk name is
stored as a special file, as for the DOS filesystem, then all other
path-based XFS functions have to ignore the disk name.
An empty name, or one consisting of '0xe5' (for TOS compatibility) must delete the disk name (provided that media without names are allowable). xfs_wlabel is also called for Dwritelabel. | ||||||
Group: | Make-up of an XFS
| ||||||
See also: | MagiC's XFS-concept
|
Name: | »xfs_xattr« - Required for Fxattr.
| ||||||||||||
Parameters: |
| ||||||||||||
Description: | xfs_xattr is used for Fxattr. In the case mode == 0
(i.e. follow symbolic links) one can return ELINK in d0 and a link in
a0, else ELINK is inadmissible.
| ||||||||||||
Group: | Make-up of an XFS
| ||||||||||||
See also: | MagiC's XFS-concept
|
When working with an XFS the following data structures are important:
DD | (Directory descriptor) |
DHD | (Directory handle descriptor) |
DMD | (Drive medium descriptor) |
DTA | (Disk transfer area) |
FD | (File descriptor) |
MX_DEV | (Device driver) |
See also: DFS structures MagiC's XFS-concept
The directory descriptors must be created and managed by the XFS. All descriptors that are known to the kernel (i.e. those that are used as a standard path for a process) have a non-zero reference counter. The only exception is the DD for the root directory of a drive; here the reference counter is always 0, irrespective of whether a process has the root directory as a standard directory or not.
For the kernel a DD looks like the following; these entries have to be created by the XFS:
dd_dmd: DS.L 1 /* 0x00: Pointer to DMD */ dd_refcnt: DS.W 1 /* 0x04: Ref. counter for standard paths */
See also: MagiC's XFS-concept
The associated filesystem is found here.
The reference counter. dd_refcnt is used only by the kernel, has to be initialized to 0 by the XFS on creation of a DD (for the root better to 1, see above for xfs_drv_open) and incremented by 1 at each handing over to the kernel (-> xfs_path2DD).
This means that on returning a new DD (which is thus not otherwise referenced by the kernel) xfs_path2DD must set the reference counter to 1.
If the reference counter is non-zero, the kernel has a pointer to this DD and it may in no way be released by the XFS. The kernel decrements the reference counter by 1 each time it no longer requires a DD. If the counter reaches 0 during this, then xfs_freeDD is called. The XFS can then release the DD, or else only at a call of xfs_garbcoll (the garbage collection) or at xfs_drv_close.
Warning: The root may not be released during the lifetime of the mounted filesystem. The root's reference counter should be preset to 1 to prevent it being released with xfs_freeDD.
See also: MagiC's XFS-concept Data structures for an XFS
The directory handles are required for Dopendir/Dclosedir/Drewinddir. Unlike the file descriptors (FDs) the kernel does not hold a list of opened directory handles (DH). When a process terminates, the XFS is called via the function xfs_pterm and must release all DHs created for the process.
The XFS can obtain the owner of a DH with the kernel pointer act_pd. For the kernel a DH looks like the following; these entries have to be created by the XFS:
dhd_dmd: DS.L 1 /* 0x00: Pointer to DMD */
See also: MagiC's XFS-concept DMD
The associated filesystem is found here.
The DMD is created by the kernel (!) for each opened drive and also released again if necessary. The XFS stores all data here that it has to memorize for the drive. The following fields are the ones that the kernel requires (the ancestor object from which the XFS derives its XFS-DMD):
d_xfs: DS.L 1 /* 0x00: The filesystem driver */ d_drive: DS.W 1 /* 0x04: Drive number 0..25 */ d_root: DS.L 1 /* 0x06: Pointer to DD of the root */ d_biosdev: DS.W 1 /* 0x0a: BIOS drive, or -1 */ d_driver: DS.L 1 /* 0x0c: With devcode, defines the medium */ d_devcode: DS.L 1 /* 0x10: e.g. SCSI target and drive */ d_dfs: DS.L 1 /* 0x14: DOS-specific filesystem driver */
Other XFSs or DFSs enter further data into the DMD. One can envisage the DMD as an object class. A DMD derived for the DOS_XFS only has the additional entry d_dfs. The FAT enters extra data such as the cluster size and the number of sectors.
See also: MagiC's XFS-concept DD
The associated filesystem driver (XFS) is found here. It is entered by xfs_drv_open.
d_drive specifies which logical drive ('A' .. 'Z') the filesystem is assigned to. This does not always have to correspond to a BIOS drive. This value is always(!) entered by the kernel when a drive is opened, before an XFS is entered.
A pointer to the DD of the root directory can be found here.
If dealing with a partition that is handled by BIOS's Rwabs, then the BIOS device number will be found here. Else -1 must be entered here (e.g. for drive U: or a Macintosh partition).
Together with d_devcode, this determines the medium. That means that if d_driver and d_devcode are identical, both drives lie on the same medium, and if the medium is to be ejected then both filesystems have to be locked. With a hard disk partition, d_biosdev is the BIOS drive, d_driver is arbitrary (e.g. pointer to the XHDI structure), d_devcode is the XHDI code of a medium, i.e. SCSI target and device number (one WORD in each case).
Together with d_driver, this determines the medium. That means that if d_driver and d_devcode are identical, both drives lie on the same medium, and if the medium is to be ejected then both filesystems have to be locked. With a hard disk partition, d_biosdev is the BIOS drive, d_driver is arbitrary (e.g. pointer to the XHDI structure), d_devcode is the XHDI code of a medium, i.e. SCSI target and device number (one WORD in each case).
This entry is mandatory only for DOS filesystems (i.e. already for a derived object) and contains a pointer to the DFS subdriver.
The DTA is used by the old DOS functions Fsfirst and Fsnext, whose clumsy conception by the MS-DOS originators still weighs down the system like a curse. For the kernel the structure looks as follows:
dta_res1: DS.B 20 /* 0x00: Not used by the kernel */ dta_drive: DS.B 1 /* 0x14: Logical drive */ dta_attribute: DS.B 1 /* 0x15: Found attribute */ dta_time: DS.W 1 /* 0x16: Found time */ dta_date: DS.W 1 /* 0x18: Found date */ dta_len: DS.L 1 /* 0x1a: Found length */ dta_name: DS.B 14 /* 0x1e: Found filename */
Note: The components dta_attribute to dta_name represent the documented user area; this has to be handled according to GEMDOS specifications.
See also: MagiC's XFS-concept
dta_res1 (from XFS) is not used by the kernel. Here the XFS may muck about.
xfs_dta_drive contains the associated logical drive (0 corresponds to drive A: etc). With this information the kernel can decide at Fsnext which XFS has to perform the task.
The file descriptors must be created and managed by the XFS. All the descriptors that are known to the kernel have a non-zero reference counter. For the kernel an FD looks exactly like a DD, which is why the same data structure is used in the DOS_XFS.
For the kernel an FD looks like the following; these entries have to be created by the XFS:
fd_dmd: DS.L 1 /* 0x00: Pointer to DMD */ fd_refcnt: DS.W 1 /* 0x04: Reference counter for closing, or -1 */ fd_mode: DS.W 1 /* 0x06: Open-mode and flags */ fd_dev: DS.L 1 /* 0x08: Pointer to MX_DEV */
The class derived from DOS_XFS (a 'DOS-FD') also has the additional fields:
fd_ddev: DS.L 1 /* 0x0c: Pointer to MX_DDEV */ fd_name: DS.B 11 /* 0x10: DD_FD: Name in internal format */ fd_attr: DS.B 1 /* 0x1b: Attribute */ fd_owner: DS.L 1 /* 0x1c: DD_FD: Owner of an FD, or NULL */ fd_parent: DS.L 1 /* 0x20: Pointer to the parent DD_FD */ fd_children: DS.L 1 /* 0x24: DD_FD: List of all children */ fd_next: DS.L 1 /* 0x28: Pointer to FDs im same directory */ fd_multi: DS.L 1 /* 0x2c: Pointer to FD of the same file */ fd_multi1: DS.L 1 /* 0x30: Pointer to first list element */ fd_fpos: DS.L 1 /* 0x34: Position of the file pointer */ fd_dirch: DS.B 1 /* 0x38: Bit0: 'dirty' */ fd_unused: DS.B 1 /* 0x39: Not used */ fd_time: DS.W 1 /* 0x3a: Time (8086) */ fd_date: DS.W 1 /* 0x3c: Date (8086) */ fd_stcl: DS.W 1 /* 0x3e: Starting cluster */ fd_len: DS.L 1 /* 0x40: File length in bytes */ fd_dirpos: DS.L 1 /* 0x44: Pos. of matching entry in directory */ fd_user1: DS.L 1 /* 0x48: Available for user allocation */ fd_user2: DS.L 1 /* 0x4c: Available for user allocation */
See also: MagiC's XFS-concept DMD MX_DDEV MX_DEV
fd_dmd contains a pointer to the associated filesystem.
The reference counter. This entry is used only by the kernel, has to be decremented by 1 at each dev_close call and initialized (to 1) by xfs_fopen.
A reference counter of -1 signals that the FD may never be released. This is necessary for, say, the device files U:\DEV\CON, U:\DEV\AUX etc. that are always available.
fd_mode contains the mode, as described for xfs_fopen. If two FDs point to the same file, then the modes have to be compatible. Thanks to the simple MagiC-internal mode notation, a plain rotation and ANDing of the bits is sufficient, e.g.:
move.w fd_mode(a0),d1 btst #BOM_NOCHECK,d1 ; No check by the XFS? bne.b _opf_nxt ; Yes, ddev_open checks ror.b #4,d1 and.b d0,d1 bne opd_eaccdn ; Conflict: return(EACCDN)
fd_dev is the pointer to the device driver.
Here the DFS has to enter the MX_DDEV (i.e. the device driver) at a dfs_dir2FD call.
Here the name (8+3) is stored in an internal format. The name is valid only when it refers to a subdirectory, and only in a prototype FD, i.e. in fd_multi1. The name of the root is an empty character string.
Here the file attribute is stored. This is valid only in a prototype FD, i.e. in fd_multi1. From the attribute one can recognize whether the FD represents a directory.
Here a pointer to the owner of an FD is stored (i.e. a pointer to the basepage). A value of NULL signifies that the FD is not allocated at present.
This is a chaining pointer to the parent, i.e. to the directory in which the file lies, or the parent directory of a subdirectory. fd_parent is valid only for the prototype FD.
This is a list of all opened files and opened subdirecories. fd_children is valid only for the prototype FD.
This is a pointer to the next FD in the same directory, i.e.
the next sibling; this can be an opened file or a subdirectory - in
principle these are not differentiated.
fd_next is valid only for the prototype FD.
If a file is opened several times, then a 'clone' of the prototype FD is created. Most of the FD fields are invalid for this clone; in essence only driver, mode and file position are valid. fd_multi is a chained list, wich is NULL-terminated.
This is the associated prototype FD that contains the valid file data. If a file is only opened once, then: fd->fd_multi1 == fd.
fd_fpos is the position of the file pointer; it is 0L for a device.
Bit 0 of fd_dirch indicates whether a file has been altered and hence on closing the file the directory (fd_parent) has to be updated (does not happen when dealing with a folder). The other bits are reserved and are used in part by the DOS_XFS.
Unused and reserved.
fd_time is the time of day from the directory entry in Intel format.
fd_date is the date from the directory entry in Intel format.
fd_stcl is the starting cluster in Motorola format.
fd_len is the file length in bytes in Motorola format.
fd_dirpos is the position of the associated entry in the parent. It is valid only for the prototype FD.
Together with fd_user2, 2 LONGwords available for free allocation by the user. The FAT_DFS stores here additional information for fd_fpos, namely the current cluster. Other DFSs can store other data. These fields are valid initially only for the prototype FD, except that on opening (ddev_open) the data are copied explicitly from the prototype FD into the clone.
Together with fd_user1, 2 LONGwords available for free allocation by the user. The FAT_DFS stores here additional information for fd_fpos, namely the current cluster. Other DFSs can store other data. These fields are valid initially only for the prototype FD, except that on opening (ddev_open) the data are copied explicitly from the prototype FD into the clone.
The device driver is inserted by the XFS into the file descriptor at the opening of a file, and called directly by the kernel. The device driver must make the following functions available:
typedef struct _mx_dev { LONG (*dev_close)(); LONG (*dev_read)(); LONG (*dev_write)(); LONG (*dev_stat)(); LONG (*dev_seek)(); LONG (*dev_datime)(); LONG (*dev_ioctl)(); LONG (*dev_getc)(); LONG (*dev_getline)(); LONG (*dev_putc)(); } MX_DEV;
See also: MagiC's XFS-concept
Name: | »dev_close«
| ||||
Parameters: |
| ||||
Description: | If fd_refcnt is not 0 already, fd_refcnt must be decremented
(this must be accomplished by the MX_DEV). On this occasion any
buffers that may be present should be written back and directory
entries updated. If fd_refcnt is 0, the FD can be released. At a disk
media change fd_refcnt is already 0 at a dev_close call, i.e. the FD just
needs to be released.
The file driver installed by DOS_XFS writes back the directory data and then calls the MX_DDEV subdriver. | ||||
Group: | Workstation driver
| ||||
See also: | —
|
For Fdatime. The file driver installed by DOS_XFS passes the call on to the MX_DDEV subdriver, if the function is supported in the MX_DDEV driver (pointer != NULL), otherwise the function will be performed automatically with the help of the FD data.
Parameters:
a0 | = | FD *file |
a1 | = | int d[2] |
d0 | = | int setflag |
-> d0 | = | long errcode |
Name: | »dev_getc«
| ||||||
Parameters: |
| ||||||
Description: | dev_getc is used by the kernel for Fgetchar and the
character-oriented functions (Cconin, Cconout, Cauxin etc.). In the
case of a device, the return value may be a LONGword (e.g. for CON
having the scancode of the key in the high-WORD), else a byte (always
extended to 'unsigned'). At EOF, 0x0000FF1A must be returned.
mode means:
The file driver installed by DOS_XFS passes the call on to the MX_DDEV subdriver if the function is supported in the MX_DDEV driver (pointer != NULL), otherwise the function is implemented automatically as dev_fread. | ||||||
Group: | Workstation driver
| ||||||
See also: | —
|
For line-oriented input. mode as in dev_getc. The return will be the number of characters input without terminatng characters or similar. The file driver installed by DOS_XFS passes the dev_getline call on to the MX_DDEV subdriver if the function is supported in the MX_DDEV driver (pointer != NULL); otherwise the function is implemented auto matically as dev_fread. The line is then terminated with CR and LF;
Parameters:
a0 | = | FD *file |
a1 | = | char *buf |
d1 | = | long size |
d0 | = | int mode |
-> d0 | = | long amount |
For Fcntl. The file driver installed by DOS_XFS passes the dev_ioctl call directly to the MX_DDEV subdriver. Only the following functions are handled however: FSTAT and FUTIME. These should also be executed by other XFSs. Every file driver should support FIONREAD and FIONWRITE.
Parameters:
a0 | = | FD *file |
d0 | = | int cmd |
a1 | = | void *buf |
-> d0 | = | long errcode |
Name: | »dev_putc«
| ||||||||
Parameters: |
| ||||||||
Description: | dev_putc is used by the kernel for Fgetchar and the
character-oriented functions (Cconin, Cconout, Cauxin etc.). In the
case of a terminal the return value must be 4L (i.e. 4 bytes written),
otherwises 1L if writing was successful.
mode means:
The file driver installed by DOS_XFS passes the call on to the MX_DDEV subdriver if the function is supported in the MX_DDEV driver (pointer != NULL), otherwise the function is automatically implemented as dev_fwrite. | ||||||||
Group: | Workstation driver
| ||||||||
See also: | —
|
From the file file, count bytes are read into the buffer buffer. The return is the number of characters actually read. The file driver installed by DOS_XFS passes the dev_read call directly to the MX_DDEV subdriver.
Parameters:
a0 | = | FD *file |
d0 | = | long count |
a1 | = | char *buffer |
-> d0 | = | long amount |
For Fseek. mode is, as in TOS, 0, 1 or 2. The return value will be the current position of the write/read pointer; device drivers must always return a 0L here. The file driver installed by DOS_XFS passes the dev_seek call directly to the MX_DDEV subdriver.
Parameters:
a0 | = | FD *file |
d0 | = | long where |
d1 | = | int mode |
-> d0 | = | long position |
Name: | »dev_stat«
| ||||||||||
Parameters: |
| ||||||||||
Description: | dev_stat specifies the read/write status of the file. It is
called for Fselect (or for Cconos/Cconis etc.) for instance. In
contrast to MiNT, it is left to the driver here whether it is
interrupt-capable or not, i.e. whether it is able to call a waiting
application in interrupt again or not. rwflag specifies
whether the write or read status is inquired for.
unselect is either NULL or a pointer to the following structure: typedef struct { union { void (*unsel) (MAGX_UNSEL *un); long status; } long param; } MAGX_UNSEL; Procedure: Generally the following applies: If unselect is non-0, the return value must be returned not only as the function result (in d0.L) but also in unselect->status. This applies for all kinds of return values. One can optionally store a parameter in unsel->param. If apcode == NULL, polling will be performed, i.e. the application is not put to sleep. So the return will be: 0 = Not ready, 1 = Ready, <0 = Error. If apcode ! = NULL (then unselect != NULL as well) then the return will be:
If the device is not ready and is interrupt-capable, then one proceeds as follows:
The interrupt routine does the following:
The clean-up routine does the following:
The DOS functions Finstat and Foutstat at first attempt to execute the call as Fcntl} (FIONREAD or FIONWRITE). If this subfunction of dev_ioctl does not exist (the file driver has to return EINVFN!), then dev_stat is called. In that case one can state either that a 'character is available' (value == 1) or 'no character is available' (value == 0). The file driver installed by DOS_XFS passes on the call directly to the MX_DDEV subdriver. | ||||||||||
Group: | Workstation driver
| ||||||||||
See also: | —
|
To the file file, count bytes are written from the buffer buffer. The return is the number of characters actually written. The file driver installed by DOS_XFS updates the date/timestamp of the file and then passes the dev_write call to the MX_DDEV subdriver.
Parameters:
a0 | = | FD *file |
d0 | = | long count |
a1 | = | char *buffer |
-> d0 | = | long amount |
An XFS is just a program that installs the driver and then
terminates itself resident. The installation is performed with:
kernel = Dcntl(KER_INSTXFS, NULL, &myxfs).
The return is a pointer to important kernel functions, or an error- code. The kernel functions can also be inquired for independently of the installation of an XFS, namely with: kernel = Dcntl(KER_GETINFO, NULL, NULL).
The deinstallation of an XFS is not provided for.
MagiC makes available to the installed XFSs, DFSs or device drivers some kernel information as well as kernel functions. The same register conventions apply for the kernel functions as for the XFS functions, i.e. d0-d2 and a0-a2 may be destroyed. One can obtain a pointer to the structure that contains the kernel functions with:
kernel = Dcntl (KER_INSTXFS, NULL, &myxfs); or kernel = Dcntl (KER_GETINFO, NULL, NULL);
In the first case an XFS is installed, in the second case one only gets the kernel structure (perhaps for a DFS or a device driver). The build-up of the kernel structure in detail:
typedef struct { WORD mxk_version; VOID (*mxk_fast_clrmem) ( void *von, void *bis ); BYTE (*mxk_toupper) ( char c ); VOID (*mxk__sprintf) ( char *dest, char *source, LONG *p ); VOID *mxk_mxk_act_pd; APPL *mxk_act_appl; APPL *mxk_keyb_app; WORD *mxk_pe_slice; WORD *mxk_pe_timer; VOID (*mxk_appl_yield) ( void ); VOID (*mxk_appl_suspend) ( void ); VOID (*mxk_appl_begcritic) ( void ); VOID (*mxk_appl_endcritic) ( void ); LONG (*mxk_evnt_IO) ( LONG ticks_50hz, void *unsel ); VOID (*mxk_evnt_mIO) ( LONG ticks_50hz, void *unsel, WORD cnt ); VOID (*mxk_evnt_emIO) ( APPL *ap ); VOID (*mxk_appl_IOcomplete) ( APPL *ap ); LONG (*mxk_evnt_sem) ( WORD mode, void *sem, LONG timeout ); VOID (*mxk_Pfree) ( void *pd ); WORD mxk_int_msize; VOID *mxk_int_malloc ( void ); VOID mxk_int_mfree ( void *memblk ); VOID mxk_resv_intmem ( void *mem, LONG bytes ); LONG mxk_diskchange ( WORD drv ); LONG mxk_DMD_rdevinit ( DMD *dmd ); LONG mxk_proc_info ( WORD code, PD *pd ); LONG mxk_mxalloc ( d0 = LONG amount, d1 = WORD mode, a0 = PD *pd ); LONG mxk_mfree ( a0 = void *block ); LONG mxk_mshrink ( d0 = LONG newlen, a0 = void *block ); } MX_KERNEL;
See also: MagiC's XFS-concept
mxk_version is the version number, which is simply 3 at present. For each change of the kernel structure the version number is increased, so that programs may adapt themselves accordingly.
mxk_fast_clrmem is a fast memory clearance routine, which sets the memory block between from and to (exclusive) to 0.
The following apply for this:
a0 | = | void *from |
a1 | = | void *to |
mxk_toupper converts the character c to upper case, respecting the national special characters (accents, umlauts etc.).
The following apply for this:
d0 | = | char c |
mxk__sprintf is a function that expects its arguments on the stack. Items to pass are the destination character string dest, the template source and the values to be entered p[]. Depending on the formatting statement, the LONGwords are interpreted as 'unsigned int' (%W), 'signed long' (%L) or character string (%S).
With %W the WORD lying further down in memory is used, the sequence %% inserts a 'percent' character.
mxk_act_pd is the pointer to the current basepage; the address can be obtained also from the system header or the DOS variables.
mxk_act_appl is a pointer to the current application (i.e. the running task). The build-up of the structure is not documented. Due to faster access, the pointer is used as the descriptor in place of the ap_id.
mxk_keyb_app is the pointer to the application that currently 'owns' the keyboard. The pointer can be used by device drivers that have to process the keyboard-owning application in a different way, for instance.
mxk_pe_slice is used for preemptive multitasking. If *pe_slice == -1 then preemptive multitasking is switched off, and disk accesses are not interrupted.
mxk_pe_timer is used for preemptive multitasking. If *pe_slice == -1 then preemptive multitasking is switched off, and disk accesses are not interrupted.
mxk_appl_yield allocates CPU time to the system. It is important for drivers that cannot wait for an interrupt and have to prevent that their 'busy waiting' paralyses the system.
mxk_appl_suspend works like appl_yield, though it allocates a lower priority to the application, perhaps as a background process.
mxk_appl_begcritic signals that the current application has entered a critical phase and may not be terminated.
mxk_appl_endcritic signals the end of the critical phase for the current application. If a termination command has arrived in the meantime then the program will be terminated.
Name: | »evnt_IO«
| ||||
Parameters: |
| ||||
Description: | mxk_evnt_IO makes it possible to wait for one external
event. The external event in question is either an interrupt or
another application (which perhaps writes to a pipe for awakening).
The function is used for the creation of device drivers:
Procedure (see DEV_LPT1 as an example):
| ||||
Group: | Kernel functions
| ||||
See also: | —
|
Name: | »evnt_mIO«
| ||||||||
Parameters: |
or
| ||||||||
Description: | mxk_evnt_mIO makes it possible to wait for several
external events; this function is used by Fselect (several files!) for
instance.
Procedure:
Applications waiting for evnt_(m)IO events appear in the program manager as waiting for 'io' (input/output) or 'io ti' (input/output with timeout). | ||||||||
Group: | Kernel functions
| ||||||||
See also: | —
|
mxk_appl_IOcomplete wakes up an application that is waiting for evnt_(m)IO.
The following apply for this:
a0 | = | APPL *ap |
Name: | »evnt_sem«
| ||||||||||||||
Parameters: |
| ||||||||||||||
Description: | mxk_evnt_sem is used for controlling semaphores. The following
subfunctions are possible for mode:
SEM_SET and SEM_CSET are the only subfunctions that can initiate a task-switch. In contrast to wind_update, the setting and releasing of semaphores can not be nested with these calls. If one attempts to reserve again a semaphore that is already reserved then this results in an error-code. On releasing the semaphores no task-switching will take place, i.e. though the semaphores may now belong to another application that has a 'ready' status, it has not yet been allocated any CPU time. If the situation is not critical then an appl_yield should be performed subsequently in each case. The screen semaphore has the name _SCR and may use mxk_evnt_sem only with the subfunction SEM_TEST. SEM_CREATE does not set the creator automatically as the owner. This is not necessary as no task-switching has taken place, so SEM_SET can be performed afterwards without further ado. SEM_DEL requires that the deleter is also the owner. On deletion all waiting applications are released; they receive, if waiting via evnt_sem(SEM_SET, ..), a -2 as return value. People deleting system semaphores (those whose names start with a '_') have only themselves to blame! | ||||||||||||||
Group: | Kernel functions
| ||||||||||||||
See also: | —
|
Parameters:
a0 = | Pointer to semaphore
|
Parameters:
a0 = | Pointer to semaphore | ||||||||
d1 = | Timeout in 50Hz ticks
|
Parameters:
a0 = | Pointer to semaphore
|
Parameters:
a0 = | Pointer to semaphore | ||||||
d1 = | Timeout in 50Hz ticks
|
Parameters:
d1 = | Name of semaphore
|
Parameters:
a0 = | Pointer to semaphore (32 bytes at even address) |
d1 = | Name void |
Parameters:
a0 = | Pointer to semaphore
|
mxk_Pfree releases the memory for a process that was terminated with Ptermres. This is necessary to remove a device driver correctly.
The following apply for this:
a0 | = | void *pd |
mxk_int_msize gives the length of a memory block of the internal (kernel) memory management.
mxk_int_malloc allocates an internal memory block. If there is no free memory any more then first a global 'garbage collection' will be performed (see description of the XFS), and if this fails the system will be halted. Internal memory blocks may be reserved only in small lots, else one soon gets 'Out of internal memory' messages and the system locks up.
mxk_int_mfree releases a memory block once more.
The following apply for this:
a0 | = | void *memblk |
mxk_resv_intmem extends the kernel memory. There is no possibility foreseen to claim memory back. As the kernel only reserves internal memory sufficient for the FAT drives on booting, it may be necessary for an XFS to reserve further kernel memory with this function at the start.
The following apply for this:
a0 | = | void *mem |
d0 | = | long bytes |
mxk_diskchange must be called when an XFS or DFS driver has recognized a disk media change. The XFS driver releases its files and structures and subsequently the kernel.
Return values:
EDRIVE | Invalid drive |
E_CHNG | Valid drive with new disk medium |
The following apply for this:
d0 | = | int drv |
As of kernel version 1.
mxk_DMD_rdevinit initializes the fields d_driver and d_devcode of the DMD and uses the field d_biosdev for this. It is required for interchangeable disk mechanisms.
The following apply for this:
a0 | = | DMD *dmd |
As of kernel version 2.
mxk_proc_info obtains data for the current process:
d0 = 0: | 0: Highest available subfunction number |
1: Domain | |
2: Process ID |
The following apply for this:
d0 | = | WORD code |
a0 | = | PD *pd |
As of kernel version 4.
mxk_mxalloc enables fast memory allocation, e.g. for a RAMdisk-XFS, without having to go via a trap.
pd specifies the process that is entered as the owner of the new block, therefore normally the basepage of the XFS driver should be passed.
As of kernel version 4.
mxk_mfree releases the memory allocated by mxk_mxalloc.
As of kernel version 4.
mxk_mshrink alters the size of a memory block.
Symbolic links (also called aliases in the user documentation in accordance with Macintosh nomenclature) are files that are specially labelled in some way, and instead of data contain a path which in turn points to another file. Such a path can also point to a no longer or not yet existing file. Paths can be absolute or relative, where the latter have the directory in which the link lies as a reference.
In memory such links are managed as structures:
{ WORD n; /* Rounded up to an even number, incl. EOS */ char path[n]; /* Path with EOS at end */ }
Note: When some XFS functions come across a symlink they have to dereference it, i.e. they return to the kernel in d0 the error-code ELINK and in a0 a pointer to a structure of the above form. The kernel then looks after the dereferencing and the limiting of the maximum nesting depth (if the symlink points to another one).
XFS functions that may return ELINK are:
xfs_path2DD, xfs_sfirst, xfs_snext, xfs_fopen, xfs_xattr, xfs_attrib.
See also: MagiC's XFS-concept
This structure is defined as follows:
typedef struct { UWORD version; /* Version number */ UWORD num_drives; /* Max. number of drives */ ULONG max_secsizb; /* Max. sector size in bytes */ UWORD min_nfats; /* Min. number of FATs */ UWORD max_nfats; /* Max. number of FATs */ ULONG min_nclsiz; /* Min. number of sectors/cluster */ ULONG max_nclsiz; /* Max. number of sectors/cluster */ ULONG max_ncl; /* Max. number of clusters */ ULONG max_nsec; /* Max. number of sectors */ } MX_DOSLIMITS;
See also: Dcntl KER_DOSLIMITS MagiC's XFS-concept
This structure is defined as follows:
struct dev_descr { DEVDRV *driver; SHORT dinfo; SHORT flags; struct tty *tty; LONG devdrvsiz; LONG reserved[4]; };
Note: The component devdrvsiz describes the size of the DEVDRV structure.
See also: Dcntl MagiC's XFS-concept
This structure is defined as follows:
typedef struct devdrv { LONG (*open) (FILEPTR *f); LONG (*write) (FILEPTR *f, BYTE *buf, LONG bytes); LONG (*read) (FILEPTR *f, BYTE *buf, LONG bytes); LONG (*lseek) (FILEPTR *f, LONG where, WORD whence); LONG (*ioctl) (FILEPTR *f, WORD mode, VOID *buf); LONG (*datime) (FILEPTR *f, WORD *timeptr, WORD rwflag); LONG (*close) (FILEPTR *f, WORD pid); LONG (*select) (FILEPTR *f, LONG proc, WORD mode); VOID (*unselect) (FILEPTR *f, LONG proc, WORD mode); LONG reserved[3]; } DEVDRV;
See also: Dcntl dev_descr FILESYS MagiC's XFS-concept
This structure is defined as follows:
typedef struct filesys { struct filesys *next; LONG fsflags; LONG (*root) (WORD drv, fcookie *fc); LONG (*lookup) (fcookie *dir, BYTE *name, fcookie *fc); LONG (*creat) (fcookie *dir, BYTE *name, UWORD mode, WORD attrib, fcookie *fc); DEVDRV *(*getdev) (fcookie *fc, LONG *devspecial); LONG (*getxattr) (fcookie *fc, XATTR *xattr); LONG (*chattr) (fcookie *fc, WORD attr); LONG (*chown) (fcookie *fc, WORD uid, WORD gid); LONG (*chmode) (fcookie *fc, UWORD mode); LONG (*mkdir) (fcookie *dir, BYTE *name, UWORD mode); LONG (*rmdir) (fcookie *dir, BYTE *name); LONG (*remove) (fcookie *dir, BYTE *name); LONG (*getname) (fcookie *relto, fcookie *dir, BYTE *pathname, WORD size); LONG (*rename) (fcookie *olddir, BYTE *oldname, fcookie *newdir, BYTE *newname); LONG (*opendir) (DIR *dirh, WORD tosflag); LONG (*readdir) (DIR *dirh, BYTE *nm, WORD nmlen, fcookie *fc); LONG (*rewinddir) (DIR *dirh); LONG (*closedir) (DIR *dirh); LONG (*pathconf) (fcookie *dir, WORD which); LONG (*dfree) (fcookie *dir, LONG *buf); LONG (*writelabel) (fcookie *dir, BYTE *name); LONG (*readlabel) (fcookie *dir, BYTE *name, WORD namelen); LONG (*symlink) (fcookie *dir, BYTE *name, BYTE *to); LONG (*readlink) (fcookie *dir, BYTE *buf, WORD len); LONG (*hardlink) (fcookie *fromdir, BYTE *fromname, fcookie *todir, BYTE *toname); LONG (*fscntl) (fcookie *dir, BYTE *name, WORD cmd, LONG arg); LONG (*dskchng) (WORD drv); LONG (*release) (fcookie *fc); LONG (*dupcookie) (fcookie *dest, fcookie *src); } FILESYS;
See also: Dcntl fs_descr MagiC's XFS-concept
This structure is defined as follows:
struct fs_descr { FILESYS *file_system; SHORT dev_no; LONG flags; LONG reserved[4]; };
See also: Dcntl MagiC's XFS-concept