| 1 |
/* COVERAGE: utimes futimes futimesat utimensat */ |
| 2 |
#define _GNU_SOURCE |
| 3 |
#include <stdio.h> |
| 4 |
#include <sys/time.h> |
| 5 |
#include <fcntl.h> |
| 6 |
#include <unistd.h> |
| 7 |
#include <sys/syscall.h> |
| 8 |
#include <linux/utime.h> |
| 9 |
#include <linux/version.h> |
| 10 |
|
| 11 |
#ifndef UTIME_NOW |
| 12 |
#define UTIME_NOW ((1l << 30) - 1l) |
| 13 |
#define UTIME_OMIT ((1l << 30) - 2l) |
| 14 |
#endif |
| 15 |
|
| 16 |
int main() |
| 17 |
{ |
| 18 |
int fd; |
| 19 |
struct timeval tv[2]; |
| 20 |
struct timespec ts[2]; |
| 21 |
struct utimbuf times; |
| 22 |
|
| 23 |
fd = creat("foobar", 0666); |
| 24 |
|
| 25 |
/* access time */ |
| 26 |
tv[0].tv_sec = 1000000000; |
| 27 |
tv[0].tv_usec = 1234; |
| 28 |
tv[1].tv_sec = 2000000000; |
| 29 |
tv[1].tv_usec = 5678; |
| 30 |
|
| 31 |
|
| 32 |
#ifdef __NR_utime |
| 33 |
times.actime = 1000000000; |
| 34 |
times.modtime = 2000000000; |
| 35 |
syscall(__NR_utime, "foobar", × ); |
| 36 |
//staptest// utime ("foobar", \[Sun Sep 9 01:46:40 2001, Wed May 18 03:33:20 2033]) |
| 37 |
|
| 38 |
syscall(__NR_utime, (char *)-1, × ); |
| 39 |
#ifdef __s390__ |
| 40 |
//staptest// utime (0x[7]?[f]+, \[Sun Sep 9 01:46:40 2001, Wed May 18 03:33:20 2033]) = -NNNN |
| 41 |
#else |
| 42 |
//staptest// utime (0x[f]+, \[Sun Sep 9 01:46:40 2001, Wed May 18 03:33:20 2033]) = -NNNN |
| 43 |
#endif |
| 44 |
|
| 45 |
syscall(__NR_utime, "foobar", (struct utimbuf *)-1 ); |
| 46 |
//staptest// utime ("foobar", \[Thu Jan 1 00:00:00 1970, Thu Jan 1 00:00:00 1970\]) = -NNNN (EFAULT) |
| 47 |
#endif /* __NR_utime */ |
| 48 |
|
| 49 |
#ifdef __NR_utimes |
| 50 |
syscall(__NR_utimes, "foobar", tv); |
| 51 |
//staptest// utimes ("foobar", \[1000000000.001234\]\[2000000000.005678\]) |
| 52 |
|
| 53 |
syscall(__NR_utimes, (char *)-1, tv); |
| 54 |
#ifdef __s390__ |
| 55 |
//staptest// utimes (0x[7]?[f]+, \[1000000000.001234\]\[2000000000.005678\]) |
| 56 |
#else |
| 57 |
//staptest// utimes (0x[f]+, \[1000000000.001234\]\[2000000000.005678\]) |
| 58 |
#endif |
| 59 |
|
| 60 |
syscall(__NR_utimes, "foobar", (struct timeval *)-1); |
| 61 |
#ifdef __s390__ |
| 62 |
//staptest// utimes ("foobar", 0x[7]?[f]+) = -NNNN |
| 63 |
#else |
| 64 |
//staptest// utimes ("foobar", 0x[f]+) = -NNNN |
| 65 |
#endif |
| 66 |
#endif /* __NR_utimes */ |
| 67 |
|
| 68 |
#ifdef __NR_futimesat |
| 69 |
syscall(__NR_futimesat, 7, "foobar", tv); |
| 70 |
//staptest// futimesat (7, "foobar", \[1000000000.001234\]\[2000000000.005678\]) |
| 71 |
|
| 72 |
syscall(__NR_futimesat, AT_FDCWD, "foobar", tv); |
| 73 |
//staptest// futimesat (AT_FDCWD, "foobar", \[1000000000.001234\]\[2000000000.005678\]) |
| 74 |
|
| 75 |
syscall(__NR_futimesat, -1, "foobar", tv); |
| 76 |
//staptest// futimesat (-1, "foobar", \[1000000000.001234\]\[2000000000.005678\]) = -NNNN |
| 77 |
|
| 78 |
syscall(__NR_futimesat, AT_FDCWD, (char *)-1, tv); |
| 79 |
#ifdef __s390__ |
| 80 |
//staptest// futimesat (AT_FDCWD, 0x[7]?[f]+, \[1000000000.001234\]\[2000000000.005678\]) = -NNNN |
| 81 |
#else |
| 82 |
//staptest// futimesat (AT_FDCWD, 0x[f]+, \[1000000000.001234\]\[2000000000.005678\]) = -NNNN |
| 83 |
#endif |
| 84 |
|
| 85 |
syscall(__NR_futimesat, AT_FDCWD, "foobar", (struct timeval *)-1); |
| 86 |
#ifdef __s390__ |
| 87 |
//staptest// futimesat (AT_FDCWD, "foobar", 0x[7]?[f]+) = -NNNN |
| 88 |
#else |
| 89 |
//staptest// futimesat (AT_FDCWD, "foobar", 0x[f]+) = -NNNN |
| 90 |
#endif |
| 91 |
#endif /* __NR_futimesat */ |
| 92 |
|
| 93 |
#if defined(__NR_utimensat) |
| 94 |
ts[0].tv_sec = 1000000000; |
| 95 |
ts[0].tv_nsec = 123456789; |
| 96 |
ts[1].tv_sec = 2000000000; |
| 97 |
ts[1].tv_nsec = 56780000; |
| 98 |
syscall(__NR_utimensat, AT_FDCWD, "foobar", ts, 0); |
| 99 |
//staptest// utimensat (AT_FDCWD, "foobar", \[1000000000.123456789\]\[2000000000.056780000\], 0x0) |
| 100 |
|
| 101 |
ts[0].tv_sec = 0; |
| 102 |
ts[0].tv_nsec = UTIME_NOW; |
| 103 |
ts[1].tv_sec = 0; |
| 104 |
ts[1].tv_nsec = UTIME_OMIT; |
| 105 |
syscall(__NR_utimensat, AT_FDCWD, "foobar", ts, AT_SYMLINK_NOFOLLOW); |
| 106 |
//staptest// utimensat (AT_FDCWD, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], AT_SYMLINK_NOFOLLOW) |
| 107 |
|
| 108 |
syscall(__NR_utimensat, 22, "foobar", ts, 0x42); |
| 109 |
//staptest// utimensat (22, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], 0x42) |
| 110 |
|
| 111 |
syscall(__NR_utimensat, -1, "foobar", ts, AT_SYMLINK_NOFOLLOW); |
| 112 |
//staptest// utimensat (-1, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], AT_SYMLINK_NOFOLLOW) = -NNNN |
| 113 |
|
| 114 |
syscall(__NR_utimensat, AT_FDCWD, (char *)-1, ts, AT_SYMLINK_NOFOLLOW); |
| 115 |
#ifdef __s390__ |
| 116 |
//staptest// utimensat (AT_FDCWD, 0x[7]?[f]+, \[UTIME_NOW\]\[UTIME_OMIT\], AT_SYMLINK_NOFOLLOW) |
| 117 |
#else |
| 118 |
//staptest// utimensat (AT_FDCWD, 0x[f]+, \[UTIME_NOW\]\[UTIME_OMIT\], AT_SYMLINK_NOFOLLOW) |
| 119 |
#endif |
| 120 |
|
| 121 |
syscall(__NR_utimensat, AT_FDCWD, "foobar", (struct timespec *)-1, AT_SYMLINK_NOFOLLOW); |
| 122 |
#ifdef __s390__ |
| 123 |
//staptest// utimensat (AT_FDCWD, "foobar", 0x[7]?[f]+, AT_SYMLINK_NOFOLLOW) |
| 124 |
#else |
| 125 |
//staptest// utimensat (AT_FDCWD, "foobar", 0x[f]+, AT_SYMLINK_NOFOLLOW) |
| 126 |
#endif |
| 127 |
|
| 128 |
syscall(__NR_utimensat, AT_FDCWD, "foobar", ts, -1); |
| 129 |
//staptest// utimensat (AT_FDCWD, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], AT_[^ ]+|XXXX) |
| 130 |
#endif |
| 131 |
|
| 132 |
return 0; |
| 133 |
} |