/* @(#)getcwd.c 4.5 (Berkeley) %G% */
#define prexit(s) { strcpy(np, s); return (NULL); }
static struct stat d
, dd
;
static struct direct
*dir
;
if (d
.st_ino
==rino
&& d
.st_dev
==rdev
)
if ((file
= opendir(dotdot
)) == NULL
)
prexit("getwd: cannot open ..");
prexit("getwd: cannot chdir to ..");
if (d
.st_dev
== dd
.st_dev
) {
if(d
.st_ino
== dd
.st_ino
)
if ((dir
= readdir(file
)) == NULL
)
prexit("getwd: read error in ..");
while (dir
->d_ino
!= d
.st_ino
);
if ((dir
= readdir(file
)) == NULL
)
prexit("getwd: read error in ..");
} while(dd
.st_ino
!= d
.st_ino
|| dd
.st_dev
!= d
.st_dev
);
prexit("getwd: can't change back");
while (dir
->d_name
[++i
] != 0);
name
[i
] = dir
->d_name
[i
];