#include <unistd.h> int symlink(const char *pname, const char *slink);Service Program Name: QP0LLIB1
The symlink() function creates the symbolic link named by slink with the value specified by pname. File access checking is not performed on the file pname, and the file need not exist. In addition, a symbolic link can cross file system boundaries.
If slink names a symbolic link, symlink() fails with the [EEXIST] error.
A symbolic link path name is resolved in the following manner:
If the path name in the symbolic link does not start with / (slash), the symbolic link path name is resolved relative to the directory that contains the symbolic link.
Any files and directories to which a symbolic link refers are checked for access permission.
symlink() sets the access, change, modification, and creation times for the new symbolic link. It also sets the change and modification times for the directory that contains the new symbolic link.
The value of the symbolic link is assumed to be represented in the CCSID (coded character set identifier) currently in effect for the job. If the CCSID of the job is 65535, this parameter is assumed to be represented in the default CCSID of the job.
See QlgSymlink--Make Symbolic Link (using NLS-enabled path name) for a description and an example of supplying the pname in any CCSID.
This parameter is assumed to be represented in the CCSID, language, and country or region currently in effect for the job. If the CCSID of the job is 65535, this parameter is assumed to be represented in the default CCSID of the job.
See QlgSymlink--Make Symbolic Link (using NLS-enabled path name) for a description and an example of supplying the slink in any CCSID.
Note: Adopted authority is not used.
Authorization Required for symlink()
Object Referred to | Authority Required | errno |
---|---|---|
Each directory in the path name preceding the object to be created | *X | EACCES |
Parent directory of object to be created | *WX | EACCES |
If symlink() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
Error condition | Additional information |
---|---|
[EACCES] |
If you are accessing a remote file through the Network File System, update operations to file permissions at the server are not reflected at the client until updates to data that is stored locally by the Network File System take place. (Several options on the Add Mounted File System (ADDMFS) command determine the time between refresh operations of local data.) Access to a remote file may also fail due to different mappings of user IDs (UID) or group IDs (GID) on the local and remote systems. |
[EAGAIN] | |
[EBADFID] | |
[EBADNAME] | |
[EBUSY] | |
[ECONVERT] | |
[EDAMAGE] | |
[EEXIST] | |
[EFAULT] | |
[EFILECVT] | |
[EINTR] | |
[EINVAL] | |
[EIO] | |
[EISDIR] | |
[ELOOP] | |
[ENAMETOOLONG] | |
[ENOENT] | |
[ENOMEM] | |
[ENOSPC] | |
[ENOSYS] | |
[ENOTAVAIL] | |
[ENOTDIR] | |
[ENOTSAFE] | |
[ENOTSUP] | |
[EPERM] | |
[EROOBJ] | |
[ESTALE] |
If you are accessing a remote file through the Network File System, the file may have been deleted at the server. |
[EUNKNOWN] |
The following messages may be sent from this function:
Message ID | Error Message Text |
---|---|
CPE3418 E | Possible APAR condition or hardware failure. |
CPFA0D4 E | File system error occurred. Error number &1. |
CPF3CF2 E | Error(s) occurred during running of &1 API. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
See Code disclaimer information for information pertaining to code examples.
The following example uses symlink():
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> main() { char fn[]="readlink.file"; char sl[]="readlink.symlink"; char buf[30]; int file_descriptor; if ((file_descriptor = creat(fn, S_IWUSR)) < 0) perror("creat() error"); else { close(file_descriptor); if (symlink(fn, sl) != 0) perror("symlink() error"); else { if (readlink(sl, buf, sizeof(buf)) < 0) perror("readlink() error"); else printf("readlink() returned '%s' for '%s'\n", buf, sl); unlink(sl); } unlink(fn); } }
Output:
readlink() returned 'readlink.file' for 'readlink.symlink'
Top | UNIX-Type APIs | APIs by category |