getcwd.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "_synonyms.h"
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <limits.h>
#include <stdlib.h>
#include <strings.h>
#include "_rtld.h"
#include "msg.h"
#ifndef EXPAND_RELATIVE
/*
* Included here (instead of using libc's) to reduce the number of stat calls.
*/
static DIR *
{
int fd;
return (0);
return (0);
}
return (dirp);
}
static struct dirent *
{
int saveloc = 0;
/* LINTED */
}
/* LINTED */
return (0);
}
/* LINTED */
return (denp);
}
static int
{
}
/*
* Simplified getcwd(3C), stolen from raf's proc(1) pwdx.
*/
char *
{
/*
* Stat the present working directory to establish the initial device
* and inode pair.
*/
return (NULL);
/* LINTED */
while (1) {
/*
* Open parent directory
*/
return (NULL);
/*
* Find subdirectory of parent that matches current directory.
*/
/*
* At root, return the pathname we've
* established.
*/
return (path);
}
do {
return (NULL);
}
} else {
/*
* The parent director is a different filesystem, so
* determine filenames of subdirectories and stat.
*/
/* LINTED */
while (1) {
return (NULL);
}
continue;
continue;
}
/*
* Silently ignore non-stat'able entries.
*/
continue;
break;
}
}
/*
* Copy name of current directory into pathname.
*/
}
}
return (NULL);
}
#endif
/*
* directory.
*/
{
/*
* If a resolved path isn't provided, establish one from the PATHNAME().
*/
if (rpath)
else {
char *path;
if (path[0] != '/') {
/*
* If we can't determine the current directory (possible
* if too many files are open - EMFILE), or if the
* created path is too big, simply revert back to the
* initial pathname.
*/
NULL) {
}
}
/*
* See if the pathname can be reduced further.
*/
if (rtld_flags & RT_FL_EXECNAME) {
}
}
/*
* If the pathname is different from the original, duplicate it
* so that it is available in a core file. If the duplication
* fails simply leave the original pathname alone.
*/
}
}
/*
* Establish the directory name size - this also acts as a flag that the
* directory name has been computed.
*/
}