If pathname is an empty string and the AT_EMPTY_PATH flag is specified in flags,
statx pathname argument is of type const char *restrict, so it should be ""
instead of 0.
Details
Details
- Reviewers
SixWeining xen0n xry111 MaskRay lixing-star - Group Reviewers
Restricted Project - Commits
- rGdcefbce28109: [Sanitizer] Fix the implementation of internal_fstat on LoongArch
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
int main(int argc, char **argv)
{
int fd, ret;
struct statx bufx;
fd = open(*argv, O_RDONLY);
if (fd < 0)
printf("open %s failed\n", *argv);
ret = syscall(__NR_statx ,fd, 0, AT_EMPTY_PATH, STATX_BASIC_STATS, (void *)&bufx);
if (ret < 0)
printf("statx(%s) failed, ret %d\n", *argv, ret);
printf("statx(%s) successed, ret %d\n", *argv, ret);
close(fd);
return 0;
}
$ gcc test-statx.c
$ ./a.out a.out
statx(./a.out) fail, ret -1#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
int main(int argc, char **argv)
{
int fd, ret;
struct statx bufx;
fd = open(*argv, O_RDONLY);
if (fd < 0)
printf("open %s failed\n", *argv);
ret = syscall(__NR_statx ,fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, (void *)&bufx);
if (ret < 0)
printf("statx(%s) failed, ret %d\n", *argv, ret);
printf("statx(%s) successed, ret %d\n", *argv, ret);
close(fd);
return 0;
}
$ gcc test-statx.c
$ ./a.out
statx(./a.out) successed, ret 0Comment Actions
LGTM, thanks for fixing my stupid error!
Not sure how I wrote "0" here in the first place :(.