* Common implementation code for utimes(), lutimes(), and futimes(). */
| 3043 | * Common implementation code for utimes(), lutimes(), and futimes(). |
| 3044 | */ |
| 3045 | static int |
| 3046 | getutimes(const struct timeval *usrtvp, enum uio_seg tvpseg, |
| 3047 | struct timespec *tsp) |
| 3048 | { |
| 3049 | struct timeval tv[2]; |
| 3050 | const struct timeval *tvp; |
| 3051 | int error; |
| 3052 | |
| 3053 | if (usrtvp == NULL) { |
| 3054 | vfs_timestamp(&tsp[0]); |
| 3055 | tsp[1] = tsp[0]; |
| 3056 | } else { |
| 3057 | if (tvpseg == UIO_SYSSPACE) { |
| 3058 | tvp = usrtvp; |
| 3059 | } else { |
| 3060 | if ((error = copyin(usrtvp, tv, sizeof(tv))) != 0) |
| 3061 | return (error); |
| 3062 | tvp = tv; |
| 3063 | } |
| 3064 | |
| 3065 | if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000 || |
| 3066 | tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000) |
| 3067 | return (EINVAL); |
| 3068 | TIMEVAL_TO_TIMESPEC(&tvp[0], &tsp[0]); |
| 3069 | TIMEVAL_TO_TIMESPEC(&tvp[1], &tsp[1]); |
| 3070 | } |
| 3071 | return (0); |
| 3072 | } |
| 3073 | |
| 3074 | /* |
| 3075 | * Common implementation code for futimens(), utimensat(). |
no test coverage detected