Description: add get_current_dir_name() - the GNU extension We cannot add it to getcwd.c, because libc_pic.a goes to ld.so.1 and it gets some functions multiple defined (e. g. malloc, read) Index: b/usr/src/head/unistd.h =================================================================== --- a/usr/src/head/unistd.h +++ b/usr/src/head/unistd.h @@ -335,6 +335,9 @@ extern int fsync(int); extern int ftruncate(int, off_t); #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ extern char *getcwd(char *, size_t); +#if defined(_GNU_SOURCE) || defined(__EXTENSIONS__) +char *get_current_dir_name(void); +#endif #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \ defined(__EXTENSIONS__) extern int getdtablesize(void); Index: b/usr/src/lib/libc/port/mapfile-vers =================================================================== --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -280,6 +280,7 @@ SYMBOL_VERSION DYSON_1 { fts_open; fts_read; fts_set; + get_current_dir_name; getgrouplist; gnu_strerror_r; mempcpy; Index: b/usr/src/lib/libc/port/gen/get_current_dir_name.c =================================================================== --- /dev/null +++ b/usr/src/lib/libc/port/gen/get_current_dir_name.c @@ -0,0 +1,39 @@ + +/* +Written by Igor Pashev + +The author has placed this work in the Public Domain, +thereby relinquishing all copyrights. Everyone is free +to use, modify, republish, sell or give away this work +without prior consent from anybody. +*/ + +#include +#include +#include +#include +#include +#include + +char * +get_current_dir_name (void) +{ + char *pwd, *cwd; + struct stat64 st1, st2; + + pwd = getenv ("PWD"); + if (pwd && !stat64 (".", &st1) + && !stat64 (pwd, &st2) + && (st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino)) + return strdup (pwd); + + cwd = getcwd (NULL, PATH_MAX); + if (cwd) + { + pwd = strdup (cwd); + free (cwd); + return pwd; + } + + return NULL; +} Index: b/usr/src/lib/libc/i386/Makefile.com =================================================================== --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -428,6 +428,7 @@ PORTGEN= \ fts.o \ ftw.o \ gcvt.o \ + get_current_dir_name.o \ getauxv.o \ getcwd.o \ getdate_err.o \ Index: b/usr/src/lib/libc/amd64/Makefile =================================================================== --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -396,6 +396,7 @@ PORTGEN= \ fts.o \ ftw.o \ gcvt.o \ + get_current_dir_name.o \ getauxv.o \ getcwd.o \ getdate_err.o \