xref: /titanic_52/usr/src/man/man3c/realpath.3c (revision 385cc6b4ad1792caef3f84eb61eed3f27085801f)
te
Copyright (c) 2014, Joyent, Inc.
Copyright 1989 AT&T. Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
REALPATH 3C "Dec 20, 2014"
NAME
realpath - resolve pathname
SYNOPSIS

#include <stdlib.h>

char *realpath(const char *restrict file_name,
 char *restrict resolved_name);

char *canonicalize_file_name(const char *path);
DESCRIPTION

The realpath() function derives, from the pathname pointed to by file_name, an absolute pathname that names the same file, whose resolution does not involve ".", "..", or symbolic links. The generated pathname is stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes (defined in limits.h(3HEAD)), in the buffer pointed to by resolved_name.

The canonicalize_file_name() function is equivalent to calling realpath(path, NULL). This function is only provided for compatibility.

RETURN VALUES

On successful completion, realpath() returns a pointer to the resolved name. Otherwise, realpath() returns a null pointer and sets errno to indicate the error, and the contents of the buffer pointed to by resolved_name are left in an indeterminate state.

ERRORS

The realpath() function will fail if: EACCES

Read or search permission was denied for a component of file_name.

EINVAL

Either the file_name or resolved_name argument is a null pointer.

EIO

An error occurred while reading from the file system.

ELOOP

Too many symbolic links were encountered in resolving file_name.

ELOOP

A loop exists in symbolic links encountered during resolution of the file_name argument.

ENAMETOOLONG

The file_name argument is longer than {PATH_MAX} or a pathname component is longer than {NAME_MAX}.

ENOENT

A component of file_name does not name an existing file or file_name points to an empty string.

ENOTDIR

A component of the path prefix is not a directory.

The realpath() function may fail if: ENAMETOOLONG

Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.

ENOMEM

Insufficient storage space is available.

USAGE

The realpath() function operates on null-terminated strings.

Execute permission is required for all the directories in the given and the resolved path.

The realpath() function might fail to return to the current directory if an error occurs.

ATTRIBUTES

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

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Standard
MT-Level MT-Safe
SEE ALSO

getcwd(3C), limits.h(3HEAD), sysconf(3C), attributes(5), standards(5)