Hard link

A hard link, which is sometimes just called a link, cannot exist unless it is linked to an actual object.

When an object is created in a directory (for example, by copying a file into a directory), the first hard link is established between the directory and the object. Users and application programs can add other hard links. Each hard link is indicated by a separate directory entry in the directory. Links from the same directory cannot have the same name, but links from different directories can have the same name.

If supported by the file system, there can be multiple hard links to an object, either from the same directory or from different directories. The one exception is where the object is another directory. There can be only one hard link from a directory to another directory.

Figure 1. A directory entry defines each hard link
A directory entry defines each hard link

Hard links can be removed without affecting the existence of an object as long as there is at least one remaining hard link to the object. When the last hard link is removed, the object is removed from the server, unless an application has the object open. Each application that has the object open can continue to use it until that application closes the object. When the object is closed by the last application using it, the object is removed from the server. An object cannot be opened after the last hard link is removed.

The concept of a hard link can also be applied to the QSYS.LIB or independent ASP QSYS.LIB file systems and the document library services (QDLS) file system, but with a restriction. A library, in effect, has one hard link to each object in the library. Similarly, a folder has one hard link to each document in the folder. Multiple hard links to the same object are not allowed in QSYS.LIB, independent ASP QSYS.LIB, or in QDLS, however.

A hard link cannot cross file systems. For example, a directory in the QOpenSys file system cannot have a hard link to an object in the QSYS.LIB or independent ASP QSYS.LIB file systems or to a document in the QDLS file system.

Related concepts
Considerations for multiple hard links and journaling