[UP]


Manual Reference Pages  - system_link (3)

NAME

system_link(3f) - [M_system:FILE_SYSTEM] link one file to another file relative to two directory file descriptors (LICENSE:PD)

CONTENTS

Synopsis
Description
Return Value
Examples

SYNOPSIS

elemental impure integer function link(oldpath,newpath);

    character(len=*),intent(in) :: oldpath
    character(len=*),intent(in) :: newpath

DESCRIPTION

The link() function shall create a new link (directory entry) for the existing file, path1.

The path1 argument points to a pathname naming an existing file. The path2 argument points to a pathname naming the new directory entry to be created. The link() function shall atomically create a new link for the existing file and the link count of the file shall be incremented by one.

If path1 names a directory, link() shall fail unless the process has appropriate privileges and the implementation supports using link() on directories.

If path1 names a symbolic link, it is implementation-defined whether link() follows the symbolic link, or creates a new link to the symbolic link itself.

Upon successful completion, link() shall mark for update the last file status change timestamp of the file. Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.

If link() fails, no link shall be created and the link count of the file shall remain unchanged.

The implementation may require that the calling process has permission to access the existing file.

The linkat() function shall be equivalent to the link() function except that symbolic links shall be handled as specified by the value of flag (see below) and except in the case where either path1 or path2 or both are relative paths. In this case a relative path path1 is interpreted relative to the directory associated with the file descriptor fd1 instead of the current working directory and similarly for path2 and the file descriptor fd2. If the file descriptor was opened without O_SEARCH, the function shall check whether directory searches are permitted using the current permissions of the directory underlying the file descriptor. If the file descriptor was opened with O_SEARCH, the function shall not perform the check.

Values for flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in <fcntl.h>:

    AT_SYMLINK_FOLLOW

If path1 names a symbolic link, a new link for the target of the symbolic link is created.

If linkat() is passed the special value AT_FDCWD in the fd1 or fd2 parameter, the current working directory shall be used for the respective path argument. If both fd1 and fd2 have value AT_FDCWD, the behavior shall be identical to a call to link(), except that symbolic links shall be handled as specified by the value of flag.

Some implementations do allow links between file systems.

If path1 refers to a symbolic link, application developers should use linkat() with appropriate flags to select whether or not the symbolic link should be resolved.

If the AT_SYMLINK_FOLLOW flag is clear in the flag argument and the path1 argument names a symbolic link, a new link is created for the symbolic link path1 and not its target.

RETURN VALUE

Upon successful completion, these functions shall return
0. Otherwise, these functions shall return -1 and set errno to indicate the error.

EXAMPLES

Creating a Link to a File

   program demo_system_link
   use M_system, only : system_link, system_perror
   integer :: ierr
   ierr = system_link(’myfile1’,’myfile2’)
   if(ierr.ne.0)then
      call system_perror(’*demo_system_link*’)
   endif
   end program demo_system_link


system_link (3) March 11, 2021
Generated by manServer 1.08 from 623d09d3-cb5c-4dec-8e3e-3e16a2a7e374 using man macros.