Add Link (ADDLNK)
Where allowed to run: All environments (*ALL)
Threadsafe: NoParameters
Examples
Error messagesThe 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 information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Restrictions:
- This command works on only one object. If a pattern is specified on the OBJ parameter and more than one object matches the pattern, the user can select the object from a list in an interactive job. If this is a batch job, the command will fail with error message CPFA08E "More than one name matches pattern.". A pattern is not allowed if the LNKTYPE is symbolic, because the object is not required to exist.
- The user must have write (*W) and execute (*X) authority to the directory that contains the new link. If a hard link is to be added, the user must also have object existence (*OBJEXIST) authority to the existing object and *X authority to each of the path name prefixes of the OBJ name.
- A hard link cannot be created to a symbolic link. When LNKTYPE(*HARD) is specified and the OBJ parameter names a symbolic link, the link is created to the resolved object (which must exist).
- A hard link cannot be created to a directory.
- A hard link cannot be created to an object in another file system.
- No links can be created in the QSYS.LIB, independent ASP QSYS.LIB or QDLS portion of the name space.
Top
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
Top
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 concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top
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 concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top
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 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.
Top
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 the 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 from the user's current directory (not in QSYS.LIB, independent ASP QSYS.LIB, or QDLS) to a member in a source file 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.
Top
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.
- CPFA0B0
- Request not allowed to operate from one file system to another.
Top