1 | #include <fcntl.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <sys/stat.h>
|
---|
4 | #include <sys/time.h>
|
---|
5 | #include <unistd.h>
|
---|
6 | #define check(n, str) if (n == -1) { perror(str); return 1; }
|
---|
7 | #define TEST_FNAME "__utest"
|
---|
8 |
|
---|
9 | int main() {
|
---|
10 | struct stat s = {0};
|
---|
11 | const struct timeval tv[] = { {0, 1000}, {0, 1000} };
|
---|
12 | int fd = open(TEST_FNAME, O_CREAT, 0644);
|
---|
13 | check(fd, "open")
|
---|
14 | check(close(fd), "close")
|
---|
15 | check(utimes(TEST_FNAME, tv), "utimes");
|
---|
16 | check(stat(TEST_FNAME, &s), "stat");
|
---|
17 | printf("Modified second: %d\n", s.st_mtim.tv_sec);
|
---|
18 | printf("Modified nanosec: %d\n", s.st_mtim.tv_nsec);
|
---|
19 | return 0;
|
---|
20 | }
|
---|