Add Link (ADDLNK)

The Add Link (ADDLNK) command adds a link to an object. The New link (NEWLNK) parameter specifies the name for the new link. The Object (OBJ) parameter specifies the current name of the object that is to receive the new link. After the link is established the object may be referred to by either the old name or the new name.

For more information about integrated file system commands, see the Integrated file system topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Restrictions:

Parameters

Keyword Description Choices Notes
OBJ Object Path name Required, Positional 1
NEWLNK New link Path name Required, Positional 2
LNKTYPE Link type *SYMBOLIC, *HARD Optional, Positional 3

Object (OBJ)

Specifies the path name of the object the user wants to add a link to. This object must exist unless a symbolic link is to be added.

For more information on specifying path names, refer to "Object naming rules" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Note: This parameter is Unicode-enabled. See "Unicode support in CL" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/ for additional information.

New link (NEWLNK)

Specifies the new path name that can be used to refer to the object. The new name must not exist.

For more information on specifying path names, refer to "Object naming rules" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Note: This parameter is Unicode-enabled. See "Unicode support in CL" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/ for additional information.

Link type (LNKTYPE)

Specifies whether the link is hard or symbolic.

*SYMBOLIC
The link to the object is a representation of a path name. This representation is in the form of a path contained in a file. The actual path is determined by doing a path search based on the contents of the file. A symbolic link is also called a soft link.

Symbolic links can cross file systems. An object need not exist. An existing object can be deleted without removing the symbolic link.

*HARD
The link to the object is an actual path to an existing object. A hard link is established by creating a directory entry.

Hard links cannot cross file systems. When all hard links to an object are removed, the space occupied by the object is freed and the object can no longer be accessed. An object cannot be removed while a hard link to it exists.

Examples

Example 1: Adding a Symbolic Link

ADDLNK   OBJ('DECEMBER-1994-MONTHLY-PAYROLL-FILE')
         NEWLNK('PAY')

This command adds a symbolic link named PAY to DECEMBER-1994-MONTHLY-PAYROLL-FILE.

Example 2: Adding a Symbolic Link to a Source File

ADDLNK   OBJ('/QSYS.LIB/MYLIB.LIB/F1.FILE/P1.MBR')
         NEWLNK('PGM1')  LNKTYPE(*SYMBOLIC)

This command adds a symbolic link named PGM1 from the user's directory (not in QSYS.LIB, independent ASP QSYS.LIB, or QDLS) to member P1 in source file F1 in QSYS.LIB.

Example 3: Adding a Hard Link

ADDLNK   OBJ('/QOpenSys/MYDIR/FILE1')  NEWLNK('FILE2')
         LNKTYPE(*HARD)

This command adds a hard link from the user's current directory, with the name FILE2, to FILE1 in /QOpenSys/MYDIR.

Error messages

*ESCAPE Messages

CPFA085
Home directory not found for user &1.
CPFA089
Pattern not allowed in path name.
CPFA08E
More than one name matches pattern.
CPFA093
Name matching pattern not found.
CPFA09C
Not authorized to object. Object is &1.
CPFA0A1
An input or output error occurred.
CPFA0A7
Path name too long.
CPFA0A9
Object not found. Object is &1.
CPFA0B0
Request not allowed to operate from one file system to another.