Replace tv_usec normalization with the return of EINVAL.
This addresses two objections to the previous behavior, and unbreaks the alpha tinderbox build. TODO: update the utimes(2) man page.
This commit is contained in:
parent
8a436e7554
commit
f8ccc6ceb9
@ -2712,25 +2712,6 @@ fchown(td, uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Normalize the tv_usec value of t within the allowed range.
|
||||
*/
|
||||
static struct timeval
|
||||
normalize_timeval(const struct timeval *t)
|
||||
{
|
||||
struct timeval n;
|
||||
|
||||
if (t->tv_usec >= 0 && t->tv_usec < 1000000)
|
||||
return *t;
|
||||
n.tv_sec = t->tv_sec + t->tv_usec / 1000000;
|
||||
n.tv_usec = t->tv_usec % 1000000;
|
||||
if (n.tv_usec < 0) {
|
||||
n.tv_sec--;
|
||||
n.tv_usec += 1000000;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common implementation code for utimes(), lutimes(), and futimes().
|
||||
*/
|
||||
@ -2740,7 +2721,7 @@ getutimes(usrtvp, tvpseg, tsp)
|
||||
enum uio_seg tvpseg;
|
||||
struct timespec *tsp;
|
||||
{
|
||||
struct timeval tv[2], tvn;
|
||||
struct timeval tv[2];
|
||||
const struct timeval *tvp;
|
||||
int error;
|
||||
|
||||
@ -2757,10 +2738,11 @@ getutimes(usrtvp, tvpseg, tsp)
|
||||
tvp = tv;
|
||||
}
|
||||
|
||||
tvn = normalize_timeval(&tvp[0]);
|
||||
TIMEVAL_TO_TIMESPEC(&tvn, &tsp[0]);
|
||||
tvn = normalize_timeval(&tvp[1]);
|
||||
TIMEVAL_TO_TIMESPEC(&tvn, &tsp[1]);
|
||||
if (tvp[0].tv_usec < 0 || tvp[0].tv_usec > 999999 ||
|
||||
tvp[1].tv_usec < 0 || tvp[1].tv_usec > 999999)
|
||||
return (EINVAL);
|
||||
TIMEVAL_TO_TIMESPEC(&tvp[0], &tsp[0]);
|
||||
TIMEVAL_TO_TIMESPEC(&tvp[1], &tsp[1]);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -2712,25 +2712,6 @@ fchown(td, uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Normalize the tv_usec value of t within the allowed range.
|
||||
*/
|
||||
static struct timeval
|
||||
normalize_timeval(const struct timeval *t)
|
||||
{
|
||||
struct timeval n;
|
||||
|
||||
if (t->tv_usec >= 0 && t->tv_usec < 1000000)
|
||||
return *t;
|
||||
n.tv_sec = t->tv_sec + t->tv_usec / 1000000;
|
||||
n.tv_usec = t->tv_usec % 1000000;
|
||||
if (n.tv_usec < 0) {
|
||||
n.tv_sec--;
|
||||
n.tv_usec += 1000000;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common implementation code for utimes(), lutimes(), and futimes().
|
||||
*/
|
||||
@ -2740,7 +2721,7 @@ getutimes(usrtvp, tvpseg, tsp)
|
||||
enum uio_seg tvpseg;
|
||||
struct timespec *tsp;
|
||||
{
|
||||
struct timeval tv[2], tvn;
|
||||
struct timeval tv[2];
|
||||
const struct timeval *tvp;
|
||||
int error;
|
||||
|
||||
@ -2757,10 +2738,11 @@ getutimes(usrtvp, tvpseg, tsp)
|
||||
tvp = tv;
|
||||
}
|
||||
|
||||
tvn = normalize_timeval(&tvp[0]);
|
||||
TIMEVAL_TO_TIMESPEC(&tvn, &tsp[0]);
|
||||
tvn = normalize_timeval(&tvp[1]);
|
||||
TIMEVAL_TO_TIMESPEC(&tvn, &tsp[1]);
|
||||
if (tvp[0].tv_usec < 0 || tvp[0].tv_usec > 999999 ||
|
||||
tvp[1].tv_usec < 0 || tvp[1].tv_usec > 999999)
|
||||
return (EINVAL);
|
||||
TIMEVAL_TO_TIMESPEC(&tvp[0], &tsp[0]);
|
||||
TIMEVAL_TO_TIMESPEC(&tvp[1], &tsp[1]);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user