[...]
I am a little confused by getcwd(), on linux it is supposed to be a system call .. I expect to find a manual page for it in section 2 (man 2 getcwd)
instead it gives me the library function manual page from section 3 (man 3 getcwd)
$ man -k getcwdgetcwd (2) - get current working directorygetcwd (3) - get current working directorygetcwd (3p) - get the pathname of the current working directory$ gzip -dc /usr/share/man/man2/getcwd.2.gz.so man3/getcwd.3
I would fully expect a libc version of getcwd to make many system calls to traverse the current path but here getcwd() is a system call with all work done internally in the kernel, so I wouldnt expect anything to probe the path elements.
When I knock up a simple program to do a getcwd() and strace it I find that getcwd (on FC31 anyway) IS a system call.
Why does "man getcwd" give me a page from section 3?
C library/kernel differencesOn Linux, the kernel provides a getcwd() system call, which the func‐tions described in this page will use if possible. The system calltakes the same arguments as the library function of the same name, butis limited to returning at most PATH_MAX bytes.