* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)getcwd.c 5.8 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
register struct dirent
*dp
;
char path
[MAXPATHLEN
], up
[MAXPATHLEN
], *file
;
/* init path pointer; built from the end of the buffer */
pp
= path
+ sizeof(path
) - 1;
/* special case first stat, it's ".", not ".." */
for (pu
= up
, first
= 1;; first
= 0) {
/* save current node values */
if (root_dev
== dev
&& root_ino
== ino
) {
(void) strcpy(store
+ 1, pp
);
/* open and stat parent */
if (!(dir
= opendir(up
)) || fstat(dirfd(dir
), &s
)) {
* if it's a mount point you have to stat each element because
* the inode number in the directory is for the entry in the
* parent directory, not the inode number of the mounted file.
while (dp
= readdir(dir
))
while (dp
= readdir(dir
)) {
bcopy(dp
->d_name
, pu
, dp
->d_namlen
+ 1);
if (s
.st_dev
== dev
&& s
.st_ino
== ino
) {
bcopy(dp
->d_name
, pp
, dp
->d_namlen
);
* We didn't find the current level in its parent
* directory; figure out what to complain about.
(void) sprintf(store
, "%s not found in %s?\n",
(void) sprintf(store
, "getwd: %s: %s", file
, strerror(errno
));