glibc源码分析之statfs系列函数

glibc中与statfs函数相关的函数有4个,它们分别是:statfs,fstatfs,statfs64,fstatfs64。它们都是系统调用的封装函数。
关于statfs的系统调用有statfs(99),fstatfs(100),statfs64(268),fstatfs64(269)。statfs,fstatfs用于获取文件系统属性,属性是32位的。statfs64,fstatfs64用于获取文件系统属性,属性是64位的。
statfs和fstatfs函数都是脚本生成的。

#define SYSCALL_NAME statfs
#define SYSCALL_NARGS 2
#define SYSCALL_SYMBOL __statfs
#define SYSCALL_CANCELLABLE 0
#define SYSCALL_NOERRNO 0
#define SYSCALL_ERRVAL 0
#include <syscall-template.S>
weak_alias (__statfs, statfs)
hidden_weak (statfs)
#define SYSCALL_NAME fstatfs
#define SYSCALL_NARGS 2
#define SYSCALL_SYMBOL __fstatfs
#define SYSCALL_CANCELLABLE 0
#define SYSCALL_NOERRNO 0
#define SYSCALL_ERRVAL 0
#include <syscall-template.S>
weak_alias (__fstatfs, fstatfs)
hidden_weak (fstatfs)

statfs64和fstatfs64是.c文件构成的。

int
__statfs64 (const char *file, struct statfs64 *buf)
{
    {
      int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
      return result;
    }
}
weak_alias (__statfs64, statfs64)

__statfs64 函数调用了statfs64系统调用。

int
__fstatfs64 (int fd, struct statfs64 *buf)
{
    {
      int result = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
      return result;
    }
}
weak_alias (__fstatfs64, fstatfs64)

__fstatfs64 函数调用了fstatfs64系统调用。

发布了185 篇原创文章 · 获赞 18 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/pk_20140716/article/details/77381578