static char * getcwd_logical(void) { struct stat lg, phy; char *pwd; /* * Check that $PWD is an absolute logical pathname referring to * the current working directory. */ if ((pwd = getenv("PWD")) != NULL && *pwd == '/') { if (stat(pwd, &lg) == -1 || stat(".", &phy) == -1) return (NULL); if (lg.st_dev == phy.st_dev && lg.st_ino == phy.st_ino) return (pwd); } errno = ENOENT; return (NULL); }