Ubuntu 18.04
我想用
statx
Linux内核中引入的SysCall
4.11
. 有一个手动输入:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h> /* Definition of AT_* constants */
int statx(int dirfd, const char *pathname, int flags,
unsigned int mask, struct statx *statxbuf);
所以我试着自己写一个例子:
const char *dir_path = NULL;
const char *file_path = NULL;
//read from command line arguments
int dir_fd = open(dir_path, O_DIRECTORY);
struct statx st; //<--------------------------- compile error
statx(dir_fd, file_path, 0, &statx);
但它根本无法编译。错误是
sizeof(statx)
是未知的。实际上,在
sys/stat.h
但在
linux/stat.h
不包括在
sys/STAT.H
. 但包括之后
Linux/STAT.H
问题是没有定义
int statx(int dirfd, const char *pathname, int flags,
unsigned int mask, struct statx *statxbuf);
我以为从那以后
$ uname -r
4.15.0-39-generic
4.15.0-39-比4.11更新的通用,我可以使用它。
发生了什么?