Re: Unnecessary hard drive spin-ups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Except the system call version doesn't need you to include any header files!
Which is NOT clear from the man page!

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 getcwd
getcwd (2)           - get current working directory
getcwd (3)           - get current working directory
getcwd (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?


The man page explains the differences, so it makes sense that "man 2" and "man 3" give the same text:

 C library/kernel differences
       On Linux, the kernel provides a getcwd() system call, which  the  func‐
       tions  described  in  this  page will use if possible.  The system call
       takes the same arguments as the library function of the same name,  but
       is  limited  to  returning at most PATH_MAX bytes. 

The getcwd() system call saves overhead but should make the same storage accesses as the
library 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
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux