Ubuntu 18.04
Я пытаюсь использовать системный вызов statx
, представленный в ядре Linux 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-generic новее, чем 4.11, я могу использоватьэто.
Что не так?