glibc源码分析之stat64系列函数

来源:互联网 发布:linux arp表老化时间 编辑:程序博客网 时间:2024/05/18 14:44

前文介绍了stat系列函数的源码实现,本文将向大家介绍stat64系列函数的源码实现。
stat64系列函数包括stat64,fstat64,lstat64。由于stat系列函数只能获取32位长度的文件的属性,所以glibc又提供了stat64系列函数,用于获取64位长度的文件的属性。
stat64的源码如下:

#undef stat64intattribute_hiddenstat64 (const char *file, struct stat64 *buf){  return __xstat64 (_STAT_VER, file, buf);}

stat64调用了__xstat64 函数,完成文件属性的获取。

__xstat64 定义在sysdeps/unix/sysv/linux/xstat64.c文件中。

int___xstat64 (int vers, const char *name, struct stat64 *buf){  int result;  result = INLINE_SYSCALL (stat64, 2, name, buf);  return result;}

调用了stat64系统调用。

fstat64函数源码如下:

#undef fstat64intattribute_hiddenfstat64 (int fd, struct stat64 *buf){  return __fxstat64 (_STAT_VER, fd, buf);}

fstat64 函数调用了__fxstat64 函数。

__fxstat64 函数定义在sysdeps/unix/sysv/linux/fxstat64.c文件中。

int___fxstat64 (int vers, int fd, struct stat64 *buf){  int result;  result = INLINE_SYSCALL (fstat64, 2, fd, buf);  return result;}

lstat64函数源码如下:

#undef lstat64intattribute_hiddenlstat64 (const char *file, struct stat64 *buf){  return __lxstat64 (_STAT_VER, file, buf);}

lstat64 函数调用了__lxstat64 函数。

__lxstat64 函数定义在sysdeps/unix/sysv/linux/lxstat64.c文件中。

int___lxstat64 (int vers, const char *name, struct stat64 *buf){  int result;  result = INLINE_SYSCALL (lstat64, 2, name, buf);  return result;}