utimes()
Greg Schafer
gschafer@zip.com.au
Thu Jul 31 12:48:00 GMT 2003
Hi
Consider this:-
----------
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
int main()
{
time_t now;
struct timeval tvp[2];
time(&now);
tvp[1].tv_sec = now + 100;
utimes("foo.dat", tvp);
exit(0);
}
----------
I have glibc cvs compiled against linux-2.6.0-test2 headers with
"--enable-kernel=2.4.21" running on a 2.4.21 kernel.
The above code fails as evidenced by this:-
root:~# touch foo.dat
root:~# ls -l foo.dat
-rw-r--r-- 1 root root 0 Jul 31 22:13 foo.dat
root:~# gcc -Wall testcase.c -o testcase
root:~# ./testcase
root:~# ls -l foo.dat
-rw-r--r-- 1 root root 0 Jan 1 1970 foo.dat
Strace (attached) shows the fallback to utime() as expected but somehow the
time is wrong.
The testcase works as expected when run under a 2.6.0-test2 kernel using the
same glibc.
Bug?
Thanks
Greg
-------------- next part --------------
execve("./testcase", ["./testcase"], [/* 8 vars */]) = 0
uname({sys="Linux", node="tigers-lfs", ...}) = 0
brk(0) = 0x8049614
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=10827, ...}) = 0
mmap2(NULL, 10827, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40014000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\0]\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1476344, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40017000
mmap2(NULL, 1211204, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40018000
mmap2(0x40139000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x120) = 0x40139000
mmap2(0x4013e000, 6980, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4013e000
close(3) = 0
munmap(0x40014000, 10827) = 0
time([1059653782]) = 1059653782
SYS_271(0x80484fc, 0xbffffe30, 0x4013ce48, 0x40013000, 0xbffffea4) = -1 ENOSYS (Function not implemented)
utime("foo.dat", [1970/01/01-10:00:01, 1970/01/01-10:00:01]) = 0
exit_group(0) = ?
More information about the Libc-alpha
mailing list