Saving objects that have more than one name

You can give more than one name to objects on the system. An additional name for an object is sometimes called a link. This information describes how linking works.

Some links, referred to as hard links, point directly to the object. Other links are more like a nickname for an object. The nickname does not point directly to the object. Instead, you can think of the nickname as an object that contains the name of the original object. This type of link is referred to as a soft link, or a symbolic link.

If you create links for objects, study the examples that follow to ensure that your save strategy saves both the contents of objects and all their possible names.

The following figure shows an example of a hard link: The root (/) directory contains UserDir. UserDir contains JCHDIR and DRHDIR. JCHDIR contains FILEA that has a hard link to Object A. DRHDIR contains FILEB which also contains a hard link to Object A.

Figure 1. An Object with Hard Links–Example
Example of an object with hard links

You can save Object A with either of the following commands. For both commands, you get the description of the specified object and the contents of object.

  • SAV OBJ('/UserDir/JCHDIR/FILEA')
  • SAV OBJ('/UserDir/DRHDIR/FILEB')

If you use only the first command (JCHDIR), only the FILEA link name is saved for 'Object A'. The FILEB link name is not saved in this case. FILEB will not be found on the media, if it is specified on subsequent restore operations.

You can use any of the following commands to get the data once and both names (hard links) for the file:

  • SAV OBJ(('/UserDir'))
  • SAV OBJ(('/UserDir/JCHDIR') ('/UserDir/DRHDIR'))
  • SAV OBJ(('/UserDir/JCHDIR/FILEA') ('/UserDir/DRHDIR/FILEB'))

The following figure shows an example of a symbolic link: The root (/) directory contains QSYS.LIB and Customer. QSYS.LIB contains CUSTLIB.LIB. CUSTLIB.LIB contains CUSTMAS.FILE. Customer is a symbolic link to CUSTMAS.FILE.

Figure 2. An Object with a Symbolic Link–Example
Example of An Object with a Symbolic Link

Following are several commands you can use to save the CUSTMAS file (both description and data):

  • SAVLIB LIB(CUSTLIB)
  • SAVOBJ OBJ(CUSTMAS) LIB(CUSTLIB)
  • SAV ('/QSYS.LIB/CUSTLIB.LIB/CUSTMAS.FILE')
  • SAV ('/QSYS.LIB/CUSTLIB.LIB')

None of these commands saves the fact that the CUSTMAS file has an alias of customer in the root (/) directory.

If you specify SAV OBJ('/customer'), you save the fact that customer is an alias for the CUSTMAS file. You do not save the description of the CUSTMAS file or its contents.