Question

I'm messing around with FUSE in C and I wanted to create a file that would appear to be created very far into the future. The custom stat() function I'm writing in FUSE writes to a struct stat* stbuf and I want to do something like

stbuf->st_ctime = (1 << 39) - 1;

To get a created date an absurdly long amount of time into the future.

I'm running this on a 64-bit linux system so I would expect my time_t to be a 64 bit value, and indeed, if I just printf("%d\n",(int) sizeof(x)); to test the size of time_t in my program I get 8. However, when I compile my code with warnings turned on, I get

warning: left shift count >= width of type [enabled by default]

and the change time when I stat the file in the mounted filesystem I get

1969-12-31 15:59:59.000000000 -0800

as if the actual value was 0. Does anyone know why this is happening on a 64 bit system that should have a 64 bit time_t?

Was it helpful?

Solution

In 1 << 39 you are shifting an int and not a time_t.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top