readlink(2) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

readlink(2)

readlink(2)                      System Calls                      readlink(2)



NAME
       readlink, readlinkat - read the contents of a symbolic link

SYNOPSIS
       #include <unistd.h>

       ssize_t readlink(const char *restrict path, char *restrict buf,
            size_t bufsiz);


       ssize_t readlinkat(int fd, const char *restrict path,
       char *restrict buf, size_t bufsize);


DESCRIPTION
       The  readlink()  function  places  the  contents  of  the symbolic link
       referred to by path in the buffer buf which has size  bufsiz.   If  the
       number  of bytes in the symbolic link is less than bufsiz, the contents
       of the remainder of buf are left unchanged. If the buf argument is  not
       large  enough  to contain the link content, the first bufsize bytes are
       placed in buf.


       Upon successful completion, readlink() marks for update the  last  data
       access timestamp of the symbolic link.


       The  readlinkat()  function  is  equivalent  to the readlink() function
       except in the case where path specifies a relative path. In  this  case
       the  symbolic  link  whose content is read is relative to the directory
       associated with the file descriptor fd instead of the  current  working
       directory.  If  the  file  descriptor  was opened without O_SEARCH, the
       function checks whether directory searches are permitted using the cur‐
       rent  permissions  of  the directory underlying the file descriptor. If
       the file descriptor was opened with O_SEARCH,  the  function  does  not
       perform the check.


       If  readlinkat() is passed the special value AT_FDCWD in the fd parame‐
       ter, the current working directory is used and the behavior is  identi‐
       cal to a call to readlink().

RETURN VALUES
       Upon  successful  completion,  readlink()  and  readlinkat() return the
       count of bytes placed in the buffer.  Otherwise, it returns  −1, leaves
       the buffer unchanged, and sets errno to indicate the error.

ERRORS
       The readlink() and readlinkat() functions will fail if:

       EACCES          Search permission is denied for a component of the path
                       prefix of path.


       EFAULT          path or buf points to an illegal address.


       EINVAL          The path argument names a file that is not  a  symbolic
                       link.


       EIO             An  I/O error occurred while reading from the file sys‐
                       tem.


       ENOENT          A component of path does not name an existing  file  or
                       path is an empty string.


       ELOOP           A loop exists in symbolic links encountered during res‐
                       olution of the path argument.


       ENAMETOOLONG    The length of path exceeds {PATH_MAX},  or  a  pathname
                       component    is    longer    than    {NAME_MAX}   while
                       _POSIX_NO_TRUNC is in effect.


       ENOTDIR         A component of the path prefix is not a directory.


       ENOSYS          The file system does not support symbolic links.



       The readlinkat() function will fail if:

       EACCES    fd was not opened with O_SEARCH and the  permissions  of  the
                 directory underlying fd do not permit directory searches.


       EBADF     The  path  argument does not specify an absolute path and the
                 fd argument is neither AT_FDCWD nor a valid  file  descriptor
                 open for reading or searching.



       The readlink() and readlinkat() functions may fail if:

       EACCES          Read permission is denied for the directory.


       ELOOP           More than {SYMLOOP_MAX} symbolic links were encountered
                       in resolving path.


       ENAMETOOLONG    As a result of encountering a symbolic link in  resolu‐
                       tion  of  the  path argument, the length of the substi‐
                       tuted pathname string exceeded {PATH_MAX}.



       The readlinkat() function may fail if:

       ENOTDIR    The path argument is not an absolute path and fd is  neither
                  AT_FDCWD nor a file descriptor associated with a directory.


USAGE
       Portable  applications  should not assume that the returned contents of
       the symbolic link are null-terminated.

ATTRIBUTES
       See attributes(5) for descriptions of the following attributes:




       tab()  box;  cw(2.75i)  |cw(2.75i)  lw(2.75i)   |lw(2.75i)   ATTRIBUTE
       TYPEATTRIBUTE  VALUE _ Interface StabilityCommitted _ MT-LevelAsync-
       Signal-Safe _ StandardSee standards(5).


SEE ALSO
       stat(2), symlink(2), attributes(5), standards(5)



SunOS 5.11                        6 Jul 2010                       readlink(2)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3