0

For some reason pset6 is really giving me problems. One is that on line 564 (original) root = realpath(path, NULL); is called. Where is this realpath() function and what does it do?

1

According to

man 3 realpath
REALPATH(3)                                                Linux Programmer's Manual                                               REALPATH(3)



NAME
       realpath - return the canonicalized absolute pathname

SYNOPSIS
       #include <limits.h>
       #include <stdlib.h>

       char *realpath(const char *path, char *resolved_path);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       realpath():
           _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED

DESCRIPTION
       realpath() expands all symbolic links and resolves references to /./, /../ and extra '/' characters in the null-terminated string named
       by path to produce a canonicalized absolute pathname.  The resulting pathname is stored as a null-terminated string, up to a maximum of
       PATH_MAX bytes, in the buffer pointed to by resolved_path.  The resulting path will have no symbolic link, /./ or /../ components.

       If resolved_path is specified as NULL, then realpath() uses malloc(3) to allocate a buffer of up to PATH_MAX bytes to hold the resolved
       pathname, and returns a pointer to this buffer.  The caller should deallocate this buffer using free(3).

RETURN VALUE
       If there is no error, realpath() returns a pointer to the resolved_path.

       Otherwise, it returns NULL, the contents of the array resolved_path are undefined, and errno is set to indicate the error.

You can man it yourself to see more.

And to really answer your question, it's located in stdlib.h. It uses some constants from limits.h and that's why this header file should also be included.


If this answers your question please accept it by clicking the gray check-mark to the left, so that it becomes green. You can also vote it up by pressing the up arrow above the check-mark. And don't forget to keep coding!

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .