DOS services library
Purpose
Provides access to DOS files and diskettes.
Library
DOS Services Library (libdos.a)
Syntax
#include <dos.h>
Description
The DOS Services subroutines provide a programming envi-
ronment for applications that utilize DOS Services.
DOS Services is an AIX Operating System shell that inter-
acts with the system user like DOS and provides access to
both AIX and DOS file systems. The dos command starts
this shell. (The dos command is discussed in AIX Oper-
ating System Commands Reference.)
The DOS Services library provides access to DOS file
systems on fixed disks and on diskettes in addition to
AIX file systems. The access is transparent; that is,
applications do not need to know which type of file
system provides the files.
Applications intended to be run under DOS Services are
actually AIX applications. While the user interface to
DOS Services is as similar to DOS as possible, the appli-
cations programming interface follows the conventions of
AIX and AIX system calls wherever possible. Many AIX
applications can be converted to use the DOS Services
library with few modifications.
The DOS Services subroutines require that your programs
include the dos.h header file. When an error occurs, the
DOS Services subroutines set the global variable doserrno
to indicate the error, resembling the error reporting
performed by system calls. If you want your program to
check doserrno, then you must also include the doserrno.h
header file. For detailed information about header
files, see "Header Files."
An application program receives parameters in the
standard argc, argv, envp format used to pass parameters
to ordinary AIX processes. (See "exec: execl, execv,
execle, execve, execlp, execvp" for details about this
parameter-passing convention.) The application can use
most of the services provided by AIX, but must use the
DOS Services subroutines for file access to ensure com-
patibility with DOS file systems.
Any application can use the exec system call and the
dosexecve subroutine to invoke another AIX program,
including another DOS Services application program.
There is no way for the invoked program to tell which
program invoked it other than by the content of the
parameters or the environment. The exec system call and
the dosexecve subroutine do not process DOS Services path
information. The DOS path information must be processed
by the application program, using the DOS_PATH environ-
ment variable.
A .BAT file cannot be directly invoked by exec or
dosexecve. To execute a .BAT file, an application
program must run the dos command with the appropriate
flags and parameters. For example, the following call
runs the batch file "hello.bat":
execl ("/usr/bin/dos", "dos", "-a", "-c", "hello.bat", 0);
See the dos command in AIX Operating System Commands Ref-
erence for details about the flags and their meanings.
The DOS Services library performs transparent translation
of textual data between DOS ASCII and AIX ASCII formats.
This translation takes place for a given file if the
DO_ASCII bit is set set when the file is opened with the
dosopen subroutine. The application program operates on
the data in AIX ASCII format whether the file is located
on an AIX file system or on a DOS file system. See
"dosread" and "doswrite" for more details about the
translation performed.
The DOS Services library provides no direct support for
interaction with an attached coprocessor. Access to a
file system is mediated by the VRM, which prevents the
sharing of a file system between the coprocessor and AIX.
The DOS Services library supports the DOS file systems in
both diskette and fixed disk formats. It uses the
content of the device rather than the device itself to
determine the format of the file system. Therefore, it
is possible to copy a diskette to a fixed disk using the
cp command, and to access the diskette data from the
fixed disk.
The DOS Services library supports multiplexed disk
drives. A multiplexed drive is a single physical drive
that is configured as several logical drives (such as
drives A: and B:). As one or the other of these is
accessed, the DOS Services system prompts the user to
insert the appropriate diskette.
The DOS Services library provides recovery from diskette
I/O errors in the form of "Abort, Retry, Ignore" mes-
sages.
The DOS Services library maps DOS file attributes into
AIX file modes whenever possible so that the application
programmer need think only in terms of AIX file modes.
The directory, read-only, and hidden attributes map to
corresponding facilities in AIX. The system, volume, and
archive attributes are not directly supported, but are
recognized by the DOS commands that need to use them.
The dosstat and dosfstat subroutines provide access to
the attributes of both DOS and AIX files.
If both a parent and a child process use DOS Services
subroutines, then the parent must call dosunopen before
starting the child process, and it must call dosreopen
after the child finishes. This synchronizes the informa-
tion shared by the two processes.
Standard header information required for many of the
DOS Services library routines is defined in the file
dos.h.
DOS Services library routines return diagnostic codes
like the AIX system calls. Subroutines return a value of
-1 or NULL in case of an error, and the variable doserrno
is set to indicate the error. The file doserrno.h con-
tains definitions of each possible DOS diagnostic code.
The majority of these codes conform to AIX diagnostic
codes.
DEVICE NAMES
DOS emulation requires binding DOS devices to AIX files.
Device names in the DOS environment are mapped to AIX
files according to definitions found in the environment
at the time the dosinit subroutine is first invoked in a
process family. Generally, this will be performed by the
dos command.
Device Environment Variable and Default Setting
NUL: DOS_NUL=/dev/null
CON: DOS_CON=/dev/tty
COM1: DOS_COM1=/dev/tty0
COM2: DOS_COM2=/dev/tty1
AUX: DOS_AUX=/dev/tty0
LP0: DOS_LP0=/dev/lp0
LP1: DOS_LP1=/dev/lp1
LP2: DOS_LP2=/dev/lp2
. .
LP7: DOS_LP7=/dev/lp7
A: DOS_A=/dev/fd0
B: DOS_B=/dev/fd0
C: DOS_C=$HOME
D: DOS_D=/
A DOS disk drive name can be bound to an AIX directory,
file, or device formatted as an AIX or a DOS file system.
Typically, this is /dev/fdn or /dev/vdn. Any uppercase
alphabetic character can be used for a DOS disk name.
A DOS nondisk device can be bound to an AIX file or
device or to a program. Only the names listed in the
preceding table can be used as nondisk devices. If the
first character of the value of the AIX path name bound
to a DOS nondisk device is a "|" (vertical bar), the
associated device will be a pipe into the shell command
given by the rest of the symbol value. If it is not a
vertical bar, the value will be interpreted as an AIX
file name.
The dosinit subroutine creates a configuration table
which is propagated to subordinate processes. The envi-
ronment is not inspected after this table is initialized.
Files and devices are not actually opened until they are
accessed.
FILE NAMING
A DOS file name has the following format:
[d:|[path|filename[.ext|
DOS file names are converted to AIX file names as
follows:
The characters" A-Z 0-9 $ & # @ ! % ' ` - _ ^ ~"
When file name specifications refer to DOS file
systems, lowercase characters in file name specifi-
cations are converted to uppercase by the DOS Ser-
vices subroutines. No translation is made when file
names refer to AIX file systems.
d:
The drive name can be any single letter followed by
a colon. The DOS Services library translates it to
uppercase.
path
The directory path is of the form:
[\|[dirname|[\dirname . . . |
If the file is on an AIX file system, then each
directory level is translated to an AIX directory
level with the same name.
filename[.ext|
A DOS file name consists of a filename of one to
eight characters that can be followed by an exten-
sion. The extension, if present, consists of a .
(period) and up to three characters. AIX file names
are 1 to 14 characters long, including the exten-
sion. The extension can be from 1 to 13 characters
long, including the period. Incompatibilities may
arise when copying files from AIX file systems to
DOS file systems.
Diagnostics
When a DOS Services subroutine encounters an error, it
returns the value -1 and sets the global variable
doserrno to a code that identifies the error. This
scheme resembles the one used by AIX system calls.
All of the possible error codes are listed in the
doserrno.h header file. For your convenience, they are
also listed here:
DE_FNAME (-2) Syntax error in file name
DE_NOMNT (-3) AIX file system is not mounted
DE_UNOPEN (-4) File unopened and not reopened
DE_EXDOS (-5) Attempt to execute a DOS file
DE_RFULL (-6) DOS root directory is full
DE_ROOT (-7) Cannot modify DOS root directory
DE_BADMNT (-8) Bad header or FAT for DOS file system
DE_NEMPTY (-9) Directory is not empty
DE_INIT (-10) dosinit configuration error
DE_ENVT (-11) Environment file error
In addition, doserrno may be set to any of the values set
by the AIX system calls. These values are redefined in
the doserrno.h header file with the prefix DE_ added.