13.2 POSIX Path Semantics

POSIX path semantics is not officially supported until NetWare 6.5 SP3 or later, NetWare 6.0 SP6 or later, and NetWare 5.1 SP8 or later. This feature allows you to pass in POSIX-style paths if you create a sys:\etc\pathtab file and if you enable them with the following linker flag:

  FLAG ON 0x00400000
  

For more information on creating a linker definition file, see Section 1.6, Using a Linker Definition File. For more information on the two methods for enabling POSIX semantics, see Selecting A Prelude File.

The following functions have been enabled to accept POSIX path semantics: access, chdir, chmod, creat, dlopen, fdopen, fopen, freopen, lstat, mkdir, mkfifo, open, opendir, pipe_open, popen, procle, procve, realname, remove, rename, rmdir, sopen, stat, statfs, system, unlink, and utime.

LibC examines two states when one of these path functions is called. First, it checks to see if the POSIX semantics flag is enabled. Second, if it is enabled, it checks to see if the path contains a forward slash (/) as the first character. If the path does begin with a /, LibC looks at the sys:\etc\pathtab file to determine if the beginning of the path matches any of the equates in the file.

13.2.1 Equates in the pathtab File

You should add an equate, or make sure one has been added, for each volume on the NetWare server hosting your executing NLM. Each equate has the following format:

  /**  POSIX_path         NetWare_path */
  /volume_name/path       volume_name:\path
  

In addition to an equate for each volume, you also need to create an empty directory in the sys: volume for each volume. This enables NetWare to emulate the POSIX operation of reading the root (/) and listing what is available, including the NetWare volumes.

For example, the sys:\etc\pathtab file would need the following entries for two NetWare volumes, data1: and data2:

  /**  POSIX_path         NetWare_path */
  /data1                   data1:\
  /data2                   data2:\
  

To make these volumes visible to functions that read the POSIX root, you need to create the following directories:

  sys:\data1
  sys:\data2
  

These steps are similar to the steps used to create mount points on Linux and UNIX systems.

Every path is implicit in that if a match for the POSIX_path is not found in the file, the path is assumed to be relative to the root of sys: volume. For example, if a server has the directory sys:\data and a volume named data, the /data path would refer to sys:\data if no entry for the data: volume is found in the sys:\etc\pathtab file. To access the data: volume, the following equate would need to be added to the pathtab file:

  /**  POSIX_path         NetWare_path */
  /data                   data:\
  

Additionally, because of the ambiguity, an entry for the sys:\data directory would need to be added, and the POSIX path would need to be /sys/data to access the sys:\data directory. A better usage might be to specify an alias for the data: volume. For example:

  /**  POSIX_path         NetWare_path */
  /datavol                data:\
  

With this entry, /datavol would specify the data: volume while /data would specify the sys:\data directory and the additional entry would be unnecessary.

Using POSIX path semantics can hasten path operations such as open, rename, delete, and get information because LibC, on a per-NLM basis, retains some associated information about each path equate.

To use POSIX semantics with volumes on remote servers, use equates with the following format:

  /**  POSIX_path                     NetWare_path */
  /server_name/volume_name/path/      server_name\volume_name:\path
  

To actual access the remote volumes, you must first establish an identity on that server. For the procedure, see Section 14.1, Accessing Files on Remote Servers.

To use POSIX semantics to access files on the DOS partition, use equates with the following format:

  /**  POSIX_path                     NetWare_path */
  /nwserver/                          c:\nwserver\
  

13.2.2 Loading an NLM with POSIX Path Semantics

When an NLM with POSIX path semantics is loaded from a volume that isn't mapped in the sys:\etc\pathtab file, its current working directory becomes /. In order for the current working directory to be set to the directory the NLM is loaded from, the sys:\etc\pathtab file must contain an equate for the volume. The one exception to this is the sys volume. If the NLM is loaded from the sys volume, an equate is recommended but not required.