On Thu, 13 Feb 2020 at 11:35, Andy Paterson via users <users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Except the system call version doesn't need you to include any header files!Which is NOT clear from the man page!
The man page says "On Linux, the kernel provides a getcwd() system call, which the functions
described in this page will use if possible." so it seems applications are meant to use the
header files and let the library do the system call "if possible".
_______________________________________________On 13 Feb 2020, at 13:53, George N. White III <gnwiii@xxxxxxxxx> wrote:_______________________________________________On Thu, 13 Feb 2020 at 06:40, Andy Paterson via users <users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:[...]
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.3I 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?
The man page explains the differences, so it makes sense that "man 2" and "man 3" give the same text: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.The getcwd() system call saves overhead but should make the same storage accesses as thelibrary version.--George N. White III
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
George N. White III
_______________________________________________ users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx