0

我的 CPU 是armhf32 位的。我Linux Kernel 5.4在它上面运行(所以它支持 32 位系统的 64 位 time_t)。我针对程序编译glibc 2.34(因此 time_t 可以明确设置为 64 位而不是 32 位)。

现在我试图让这段简单的代码工作(test.c)。

#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>

int main()
{
    int ret = 0;
    ret = lchmod ("/tmp/testme.file", 0755);
    printf("ret=%d; errno=%d, strerror=%s\n", ret, errno, strerror(errno));
    return 0;
}

(交叉)像这样编译它:

arm-linux-gnueabihf-gcc -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 test.c -o test

为了测试程序,我将系统日期设置为 2084-01-01(2038 年之后很重要)。然后我通过运行创建一个文件touch /tmp/testme.file。此文件的创建时间戳为 2084-01-01。现在,当我运行上面的代码./test时,它给了我这个错误消息:

ret=-1; errno=75, strerror=Value too large for defined data type

似乎Value too large for defined data type发生错误,因为该函数lchmod(...)无法处理创建时间戳超过 2038 年的文件。

为什么是这样?这是一个 glibc 错误还是必须用额外的 CFLAGS 重新编译glibc 2.34 它本身-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64

当我改变lchmod(...)它的chmod(...)工作。

4

0 回答 0