due to systemd updated, sun8i kernel doesn't compact to new systemd.
after check systemd code, it return -EBADF in below code:
https://github.com/systemd/systemd/blob/master/src/basic/fs-util.c#L804-L815
fstat on path fds (open with O_PATH).
after check sun8i kernel code, in fstat path, fget_light rectly returns
NULL on path fds (file->f_mode & FMODE_PATH).
on mainline kernel, fget_light is wraper function of __fget_light.
on fstat path, it uses __fget_light, doesn't check FMODE_PATH.
so follow mainline kernel, change the behavior of sun8i kernel.
test case:
int main(int argc, char **argv)
{
int fd;
struct stat previous_stat;
fd = open("/", O_CLOEXEC|O_NOFOLLOW|O_PATH);
if (fd < 0) {
printf("%d, %s\n", __LINE__, strerror(errno));
return -errno;
}
if(fstat(fd, &previous_stat) < 0) {
printf("%d, %s\n", __LINE__, strerror(errno));
return -errno;
}
}
expect no error.
Signed-off-by: Zhang Ning <832666+zhangn1985@users.noreply.github.com>