zLink

Creates a hard link to an already existing file object.

Service:File System Services (64-Bit)
Version:OES 2

Syntax

#include <zPublics.h>

STATUS zLink(
   Key_t        key,
   Xid_t        xid,
   NINT         srcNameSpace,
   const void  *srcPath,
   NINT         srcMatchAttributes,
   NINT         dstNameSpace,
   const void  *dstPath
   NINT         renameFlags);

Parameters

key

(IN) Specifies who is creating the link on a file. If either srcpath or dstpath are relative paths, the key is the starting directory for pathname resolution.

xid

(IN) Specifies the transaction to which to bind operations. If the requested action is not part of a transaction, pass zNILXID.

srcNameSpace

(IN) Specifies the starting namespace for the path. In addition to the normal namespace identifiers (zNSPACE_DOS | zNSPACE_MAC | zNSPACE_UNIX | zNSPACE_LONG), nameSpace can be augmented by ORing the following mode bits:

  • zMODE_UTF8

    The default character set for the path is Unicode. However, by ORing zMODE_UTF8, UTF-8 character strings can be used.

  • zMODE_LINK

    If the last name in the path is a symbolic link, a junction, or a URL link, the scanning does not follow the link but acts on the link object itself.

srcPath

(IN) Points to the path of the file object to be accessed. If the path is not fully qualified, the key must represent a directory for starting the path parsing. Wildcards are not allowed in the path string. The default character set for the pathname is Unicode unless it is specified by srcNameSpace.

srcMatchAttributes

(IN) Specifies whether the file to be linked must match the given attributes (optional) (see Match Attributes Values).

dstNameSpace

(IN) Specifies the starting namespace for the path. In addition to the normal namespace identifiers (zNSPACE_DOS | zNSPACE_MAC | zNSPACE_UNIX | zNSPACE_LONG), nameSpace can be augmented by ORing the following mode bits:

  • zMODE_UTF8 The default character set for the path is Unicode; however, by ORing zMODE_UTF8, UTF-8 character strings can be used.

dstPath

(IN) Points to the path of the target name of the file object to be linked. This cannot be NULL. If the path is not fully qualified, the key must represent a directory where the path parsing should begin. This path must resolve to a directory file that exists, and it must also contain a leaf (link) name that does not yet exist. The target directory must reside in the same volume as the source directory. The default character set for the pathname is Unicode unless it is specified by dstNameSpace.

renameFlags

(IN) Specifies a bit mask that identifies various modes to the rename function (see also Rename Flags Values):

  • zRENAME_ALLOW_RENAMES_TO_MYSELF Allows a file to be named to its same place without returning an error
  • zRENAME_THIS_NAME_SPACE_ONLY Specifies the source and destination namespaces must be the same

Return Values

zOK

The operation completed successfully.

non-0

An error occurred (see Section 4.1, Return Values for a description).

Remarks

No wildcards are allowed.

The srcPath must fully resolve to an existing file object, which cannot be a directory object, a data stream, or an extended attribute.

The hard link is created in the directory that is identified by the key and/or dstPath, with the new name being the leaf name specified in dstPath.

See Also

zRename