• Linux 中 man手册中函数后面括号数字释义


    文章目录

    简介

    Linux手册页项目记录了用户空间程序使用的Linux内核和C库接口。
    用man手册查看系统命令,系统调用,glibc函数时,会发现其后面会有个括号,括号里面是一个数字,比如:

    access(2),  awk(1),  crash(1),  fattach(3C),  ff(1),  fstat(8), fuser(1), gethostname(2), isprint(3), kill(1), localtime(3), lstat(2), modload(8), mount(8), netstat(1), ofiles(8L), perl(1),
    ps(1), readlink(2), setlocale(3), stat(2), strftime(3), time(2), uname(1).
    
    • 1
    • 2

    Linux手册页记录了用户空间程序使用的Linux内核和C库接口(主要是GNU C库(glibc)):

    1: User commands; man-pages includes a small number of Section 1 pages that document programs supplied by the GNU C library.
    2: System calls documents the system calls provided by the Linux kernel.
    3: Library functions documents the functions provided by the standard C library.
    4: Devices documents details of various devices, most of which reside in /dev.
    5: Files describes various file formats and filesystems, and includes proc(5), which documents the /proc file system.
    7: Overviews, conventions, and miscellaneous.
    8: Superuser and system administration commands; man-pages includes a small number of Section 8 pages that document programs supplied by the GNU C library.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    下图表示进程的地址空间。图的左侧是说进程可以通过什么方式来更改进程虚拟地址空间,而中间就是进程虚拟地址空间是如何划分的,右侧则是进程的虚拟地址空间所对应的物理内存或者说物理地址空间。
    其中函数括号中的数字2代表该函数是系统调用,3代表该函数是库函数。
    在这里插入图片描述
    图片来自于 极客时间:Linux内核技术实战

    很多系统调用都有两个手册页:用户命令和系统调用。
    比如 readlink :

    [root@localhost ~]# man 1 readlink
    
    • 1
    READLINK(1)                                                                                User Commands                                                                                READLINK(1)
    
    NAME
           readlink - print resolved symbolic links or canonical file names
    
    SYNOPSIS
           readlink [OPTION]... FILE...
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    [root@localhost ~]# man 2 readlink
    
    • 1
    READLINK(2)                                                                          Linux Programmer's Manual                                                                          READLINK(2)
    
    NAME
           readlink - read value of a symbolic link
    
    SYNOPSIS
           #include 
    
           ssize_t readlink(const char *path, char *buf, size_t bufsiz);
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    还有些库函数也有多个手册页,比如 netlink :

    netlink(3)  //用 man 3 netlink 查看
    netlink(7)	//用 man 7 netlink 查看
    
    • 1
    • 2

    参考资料

    极客时间:Linux内核技术实战

    https://www.kernel.org/doc/man-pages/

  • 相关阅读:
    【K8s】专题五(5):Kubernetes 配置之热更新工具 Reloader
    期货十三篇 第四篇 开仓篇
    定制化图标——Element UI 组件图标替换指南
    网络——ARP、DHCP、ICMP协议
    IDEA安装JAVA_HOME报错、启动界面卡死的解决方案
    Linux安装Anaconda教程
    【Linux】软件安装与软件包管理 RPM&YUM
    西安健身房共享系统开发如何快速回笼资金?
    渲染器——简单Diff算法
    项目接入腾讯云短信服务SMS实现向用户发送手机验证码
  • 原文地址:https://blog.csdn.net/weixin_45030965/article/details/127680398