Chapter Contents |
Previous |
Next |
Developing Applications for Use with UNIX System Services OS/390 |
Hierarchical File System (HFS) Files |
When you start a shell session, a process is created.
Each process maintains a location in the HFS. This location is called the working directory. The initial working directory you are placed
in when you start a shell session is called your home directory. You can use the USS shell command
cd
to change the current
working directory location for the shell.
Pathnames are used
to specify the location of files within
the directory structure. A pathname starts with the root directory and works
its way down the directory hierarchy, separating each directory name with
a single slash (/), until you come to the name of the file. For example, the
following pathname specifies a file named
qsort.c
located in the
src
subdirectory of the
userxyz
directory.
/u/userxyz/src/qsort.c
Notice that the
userxyz
directory is a subdirectory
of the
u
directory, which is located in the root directory. The root directory
is signified by the single slash (/) at the beginning of the pathname. This
type of pathname, which shows the complete path from the root directory to
the file, is called an absolute pathname.
There is a second type of pathname, called a relative pathname, that specifies a path
relative to your current
working directory. To specify a relative pathname for a file, simply enter
the pathname to the file from your current location in the HFS. For example,
if the current working directory is
userxyz
, the
qsort.c
file could specified
as follows:
src/qsort.c
Notice that the beginning slash (/) is not used in a relative pathname.
The following special fields can also be used when specifying a relative pathname:
.
|
is used to specify the current directory. |
..
|
is used to specify the parent directory. |
For example, we could have specified the
qsort.c
file from the
userxyz
directory
in either of the following ways:
./src/qsort.c ../userxyz/src/qsort.c
To put all this in the context of a SAS/C program,
we could open the
scrambled.txt
file from our
qsort.c
program with any of the following
statements, provided the current working directory is
/u/userxyz/src
.
datafile = fopen("./scrambled.txt", O_RDWR); datafile = fopen("../scrambled.txt", O_RDWR); datafile = fopen("../src/scrambled.txt", O_RDWR);
We could also use the following absolute pathname to
specify the
scrambled.txt
file:
datafile = open("./scrambled.txt", O_RDWR);
Note:
The exact format of the filename specification depends
upon whether or not the
posix
option was used at compile time.
In this case the
scramble.txt
file will be found no
matter where the working directory is when the program is executed.
OS/390 Data Sets |
OS/390 data
sets can also be accessed from an
exec
-linkage program running
under the USS shell. If a
//
precedes a filename, the filename is assumed to
be either of the
tso
styles. For example, the following statement could be used to reference
a PDS member from the shell:
datafile = fopen("//scramble.text(eggnog)", "r+");
In an
exec
-linkage program compiled with the
posix
option, you must
precede the filename with
//
even if you are using a style prefix such as
tso:
.
If the filename does not begin with exactly two slashes, it will be interpreted
as an HFS file. For example, the following statement will attempt to open
the file named
tso:scramble.text(eggnog)
in the current working directory of the HFS:
datafile = fopen("tso:scramble.text(eggnog)", "r+");
Obviously, this is not the desired result. To correctly
open the
userid.scramble.text(eggnog)
PDS member, you must precede the
tso:
with two slashes.
Note:
This convention of using two
slashes to access OS/390 data sets or CMS files from your
exec
-linkage programs cannot
be used with USS shell commands. For example, you cannot use
//
to concatenate a PDS
member with an HFS file using the
cat
command.
Accessing the Transient Library |
When an application is called by the shell (or, more
generally, invoked by the POSIX
exec
system call), it runs in an address space that
has no preallocated DD statements. This creates problems for transient library
access under the shell. The SAS/C Library
solves this problem as follows:
fork
function, the same file is allocated
to CTRANS in the child before
fork
returns.
exec
, the environment variable ddn_CTRANS
is generated to contain the name of the CTRANS data set, unless this variable
already exists. This variable is passed to the called program, so that if
it is a SAS/C compiled program, it
will have access to the same CTRANS data set.
When a program is linked with the all-resident library,
it normally does not access CTRANS; however, if such a program issues an
exec
call, the CTRANS data set name is still recorded in the ddn_CTRANS environment
variable, since the called program might require transient library access.
It is recommended that you update
/etc/profile
so that ddn_CTRANS
is set to an appropriate value automatically whenever the shell starts up.
USS supports a feature similar to the SAS/C CTRANS
support for STEPLIB data sets, using the environment variable STEPLIB. If
the value of STEPLIB is CURRENT, an existing STEPLIB data set is propagated
on
exec
. Alternately, STEPLIB may name one or more data sets to be allocated
to STEPLIB in the new address space. This support will also work for access
to the SAS/C Transient Library.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.