[PATCH] Add get_current_dir_name(3)

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Sun Jan 1 02:45:00 GMT 2012


This patchset adds get_current_dir_name(3), a GNU extension:

http://www.gnu.org/software/libc/manual/html_node/Working-Directory.html
http://www.kernel.org/doc/man-pages/online/pages/man3/getcwd.3.html

The test code will show the difference between get_current_dir_name()
and getcwd(NULL, 0) when you cd into a directory via a symlink:

$ gcc -Wall -o test-get_current_dir_name.exe test-get_current_dir_name.c
$ mkdir /tmp/real
$ ln -s real /tmp/symlink
$ cd /tmp/symlink
$ /path/to/test-get_current_dir_name.exe
                  PWD: /tmp/symlink
               getcwd: /tmp/real
 get_current_dir_name: /tmp/symlink

: now try spoofing PWD
$ PWD=$HOME /path/to/test-get_current_dir_name.exe
                  PWD: /home/Yaakov
               getcwd: /tmp/real
 get_current_dir_name: /tmp/real

Patches for newlib, winsup/cygwin, and winsup/doc, plus the STC,
attached.


Yaakov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin-get_current_dir_name.patch
Type: text/x-patch
Size: 2936 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20120101/ac885ef5/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: doc-get_current_dir_name.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20120101/ac885ef5/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib-get_current_dir_name.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20120101/ac885ef5/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-get_current_dir_name.c
Type: text/x-csrc
Size: 692 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20120101/ac885ef5/attachment-0003.bin>


More information about the Cygwin-patches mailing list