HP 3000 Manuals

Symbolic Links on MPE/iX [ COMMUNICATOR 3000 MPE/iX General Release 5.0 (Core Software Release C.50.00) ] MPE/iX Communicators


COMMUNICATOR 3000 MPE/iX General Release 5.0 (Core Software Release C.50.00)

Symbolic Links on MPE/iX 

Ali Shehk 
Commercial Systems Division 

Overview 

Symbolic linking is the concept of indirectly referring (pointing) to
another file on the system.  This concept is similar to MPE/iX file
equations.  A symbolic link is a type of file that contains another
pathname.  It is a permanent file in the system directory.

A symbolic link file may contain a relative or absolute pathname.  If a
symbolic link to a relative pathname is encountered during pathname
traversal, the contents of the symbolic link replace the symbolic link
component and is expanded into the pathname being interpreted.  If a
symbolic link to an absolute pathname is encountered, the contents of the
symbolic link replaces all components up to and including the symbolic
link and is expanded into the remainder of the pathname.

For example, if the pathname /dir1/dir2/syml/file is being traversed
and the component syml is a symbolic link that points to the
relative path dir3/dir4, then the final pathname resolved is:
/dir1/dir2/dir3/dir4/file.  However, if syml contains the absolute path
/dir4/dir5, then the final pathname resolved is:  /dir4/dir5/file.

All symbolic links are interpreted in this manner except when the
symbolic link is the last component of a pathname passed as a parameter
to one of the following POSIX functions:  readlink, rename, symlink,
unlink, and lstat.  With these calls, the symbolic link itself is
accessed or affected.

Operations on Symbolic Links 

Symbolic links are permanent MPE/iX files that can be created, removed,
renamed, and archived.

Creating Symbolic Links.   

Symbolic links can be created in one of four ways by using:

1) POSIX C-library function symlink()
2) MPE/iX Command Interpreter (CI) command NEWLINK 
3) MPE/iX pseudo intrinsic HPNEWLINK 
4) POSIX shell command ln -s

Removal of Symbolic Links.   

Symbolic links can be removed in one of three ways by using:

1) POSIX C-library function unlink()
2) MPE/iX CI command PURGELINK 
3) POSIX shell command rm

Renaming Symbolic Links.   

Symbolic links can be renamed by calling the POSIX C-library function of
rename().

The MPE/iX command RENAME does not rename the symbolic link itself but
rather the file pointed to by the symbolic link.

Archiving Symbolic Links.   

Symbolic links can be stored and restored to your MPE/iX system by using
the MPE/iX STORE and RESTORE commands like any other file on the system.

The MPE/iX LISTFILE Command.   

The LISTFILE command was enhanced to display information about the
symbolic link file and its contents.  For example:

If the file /SYS/PUB/syml is a symbolic link to /SYS/PUB/NL, then

LISTFILE /SYS/PUB/syml,5

displays information about the file "syml" and in addition it displays:

SYMLINK TARGET: /SYS/PUB/NL 

Symbolic Links and File Equations 

File equations are resolved at the high levels of the file system, while
symbolic links are resolved at the directory subsystem levels, which do
not resolve or know about file equations.

If, when you open a file, a name is file equated to another filename,
then the file equation is resolved first regardless if the name is a
symbolic link.

For example:

File "X" is symbolically linked to file "Y".  If you issue the following
file equation prior to calling HPFOPEN of file "X",

     :file X=Z 

the file system resolves the file equation first and opens the file "Z".

If the system does not find a file equation, then it searches the
directory subsystem for a symbolic link and resolves the contents of the
symbolic link.

For example:

File "X" is symbolically linked to file "Y".  If the following file
equation exists,

     :file Y=Z

and you are opening file "X", the symbolic link file "X" is opened and
resolved to file "Y".

Symbolic Link Examples 

:NEWLINK ./syml, /SYS/PUB/SYSSTART

Creates the file syml in the current working directory as a symbolic link
to the pathname /SYS/PUB/SYSSTART 

:PRINT ./syml

Prints the contents of the file SYSSTART 

:PURGE ./syml

Purges the file SYSSTART 

:PURGELINK ./syml

Purges the file syml 

"Polite" Unlink 

The POSIX function unlink () removes a filename from the directory
hierarchy.  In the MPE/iX Release 4.5, the unlink () function removed
files that traditionally could not be purged.  In MPE/iX Release 5.0, the
unlink () function is restricted (will fail) for the following
situations:

   1) A file is opened for exclusive access
   2) A file is being stored/restored
   3) A file is protected (write protected)
   4) A file privilege level is less than the caller privilege level
   5) An output spool file that is linked to the SPF directory

The space occupied by the file being unlinked is not deallocated until
the last accessor of the file closes the file.  For this reason, once the
unlink function successfully completes and the link count of the object
becomes zero, the file domain changes to NEW. The MPE/iX FCLOSE intrinsic
then saves the unlinked filename back into the directory.  This is done
to preserve previous MPE/iX behavior.



MPE/iX Communicators