readlink function: get the program running path

readlink (referred obtain symbolic link file)
correlation function stat, lstat, symlink
header file #include <unistd.h>
defined function int readlink (const char * path, char * buf, size_t bufsiz);
Function Description readlink () SUMMARY symbolic link path parameters will be stored into the memory space referred buf parameter, the content is not returned as a NULL terminated string, but the number of characters in the string will be returned. If the content is less than the length of the parameter bufsiz symbolic link, long content will be truncated.
Return Value successful execution path string symbolic link file is referred to pass, -1 on failure, an error code is stored in errno.
The error code is rejected take EACCESS file, enough authority
EINVAL parameter bufsiz negative
EIO I / O access error.
ELOOP want to have too many open files symbolic links problem.
ENAMETOOLONG path name parameter path is too long
ENOENT parameter specifies the path to the file does not exist
insufficient ENOMEM core memory
but not a true directory exists ENOTDIR Parameters path path directory.

Released eight original articles · won praise 1 · views 3303

Guess you like

Origin blog.csdn.net/hengju/article/details/51274172