mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-25 07:49:18 +00:00
Change all our own code to use st_*tim instead of st_*timespec.
Also remove some local patches to diff(1) which are now unneeded.
This commit is contained in:
parent
510ea843ba
commit
99742a231f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=205793
@ -323,8 +323,8 @@ setfile(struct stat *fs, int fd)
|
||||
fs->st_mode &= S_ISUID | S_ISGID | S_ISVTX |
|
||||
S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atim);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtim);
|
||||
if (islink ? lutimes(to.p_path, tv) : utimes(to.p_path, tv)) {
|
||||
warn("%sutimes: %s", islink ? "l" : "", to.p_path);
|
||||
rval = 1;
|
||||
|
64
bin/ls/cmp.c
64
bin/ls/cmp.c
@ -66,17 +66,17 @@ int
|
||||
modcmp(const FTSENT *a, const FTSENT *b)
|
||||
{
|
||||
|
||||
if (b->fts_statp->st_mtimespec.tv_sec >
|
||||
a->fts_statp->st_mtimespec.tv_sec)
|
||||
if (b->fts_statp->st_mtim.tv_sec >
|
||||
a->fts_statp->st_mtim.tv_sec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_mtimespec.tv_sec <
|
||||
a->fts_statp->st_mtimespec.tv_sec)
|
||||
if (b->fts_statp->st_mtim.tv_sec <
|
||||
a->fts_statp->st_mtim.tv_sec)
|
||||
return (-1);
|
||||
if (b->fts_statp->st_mtimespec.tv_nsec >
|
||||
a->fts_statp->st_mtimespec.tv_nsec)
|
||||
if (b->fts_statp->st_mtim.tv_nsec >
|
||||
a->fts_statp->st_mtim.tv_nsec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_mtimespec.tv_nsec <
|
||||
a->fts_statp->st_mtimespec.tv_nsec)
|
||||
if (b->fts_statp->st_mtim.tv_nsec <
|
||||
a->fts_statp->st_mtim.tv_nsec)
|
||||
return (-1);
|
||||
return (strcoll(a->fts_name, b->fts_name));
|
||||
}
|
||||
@ -92,17 +92,17 @@ int
|
||||
acccmp(const FTSENT *a, const FTSENT *b)
|
||||
{
|
||||
|
||||
if (b->fts_statp->st_atimespec.tv_sec >
|
||||
a->fts_statp->st_atimespec.tv_sec)
|
||||
if (b->fts_statp->st_atim.tv_sec >
|
||||
a->fts_statp->st_atim.tv_sec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_atimespec.tv_sec <
|
||||
a->fts_statp->st_atimespec.tv_sec)
|
||||
if (b->fts_statp->st_atim.tv_sec <
|
||||
a->fts_statp->st_atim.tv_sec)
|
||||
return (-1);
|
||||
if (b->fts_statp->st_atimespec.tv_nsec >
|
||||
a->fts_statp->st_atimespec.tv_nsec)
|
||||
if (b->fts_statp->st_atim.tv_nsec >
|
||||
a->fts_statp->st_atim.tv_nsec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_atimespec.tv_nsec <
|
||||
a->fts_statp->st_atimespec.tv_nsec)
|
||||
if (b->fts_statp->st_atim.tv_nsec <
|
||||
a->fts_statp->st_atim.tv_nsec)
|
||||
return (-1);
|
||||
return (strcoll(a->fts_name, b->fts_name));
|
||||
}
|
||||
@ -118,17 +118,17 @@ int
|
||||
birthcmp(const FTSENT *a, const FTSENT *b)
|
||||
{
|
||||
|
||||
if (b->fts_statp->st_birthtimespec.tv_sec >
|
||||
a->fts_statp->st_birthtimespec.tv_sec)
|
||||
if (b->fts_statp->st_birthtim.tv_sec >
|
||||
a->fts_statp->st_birthtim.tv_sec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_birthtimespec.tv_sec <
|
||||
a->fts_statp->st_birthtimespec.tv_sec)
|
||||
if (b->fts_statp->st_birthtim.tv_sec <
|
||||
a->fts_statp->st_birthtim.tv_sec)
|
||||
return (-1);
|
||||
if (b->fts_statp->st_birthtimespec.tv_nsec >
|
||||
a->fts_statp->st_birthtimespec.tv_nsec)
|
||||
if (b->fts_statp->st_birthtim.tv_nsec >
|
||||
a->fts_statp->st_birthtim.tv_nsec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_birthtimespec.tv_nsec <
|
||||
a->fts_statp->st_birthtimespec.tv_nsec)
|
||||
if (b->fts_statp->st_birthtim.tv_nsec <
|
||||
a->fts_statp->st_birthtim.tv_nsec)
|
||||
return (-1);
|
||||
return (strcoll(a->fts_name, b->fts_name));
|
||||
}
|
||||
@ -144,17 +144,17 @@ int
|
||||
statcmp(const FTSENT *a, const FTSENT *b)
|
||||
{
|
||||
|
||||
if (b->fts_statp->st_ctimespec.tv_sec >
|
||||
a->fts_statp->st_ctimespec.tv_sec)
|
||||
if (b->fts_statp->st_ctim.tv_sec >
|
||||
a->fts_statp->st_ctim.tv_sec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_ctimespec.tv_sec <
|
||||
a->fts_statp->st_ctimespec.tv_sec)
|
||||
if (b->fts_statp->st_ctim.tv_sec <
|
||||
a->fts_statp->st_ctim.tv_sec)
|
||||
return (-1);
|
||||
if (b->fts_statp->st_ctimespec.tv_nsec >
|
||||
a->fts_statp->st_ctimespec.tv_nsec)
|
||||
if (b->fts_statp->st_ctim.tv_nsec >
|
||||
a->fts_statp->st_ctim.tv_nsec)
|
||||
return (1);
|
||||
if (b->fts_statp->st_ctimespec.tv_nsec <
|
||||
a->fts_statp->st_ctimespec.tv_nsec)
|
||||
if (b->fts_statp->st_ctim.tv_nsec <
|
||||
a->fts_statp->st_ctim.tv_nsec)
|
||||
return (-1);
|
||||
return (strcoll(a->fts_name, b->fts_name));
|
||||
}
|
||||
|
@ -390,8 +390,8 @@ syserr: run_err("%s: %s", name, strerror(errno));
|
||||
* versions expecting microseconds.
|
||||
*/
|
||||
(void)snprintf(buf, sizeof(buf), "T%ld 0 %ld 0\n",
|
||||
(long)stb.st_mtimespec.tv_sec,
|
||||
(long)stb.st_atimespec.tv_sec);
|
||||
(long)stb.st_mtim.tv_sec,
|
||||
(long)stb.st_atim.tv_sec);
|
||||
(void)write(rem, buf, strlen(buf));
|
||||
if (response() < 0)
|
||||
goto next;
|
||||
@ -454,8 +454,8 @@ rsource(char *name, struct stat *statp)
|
||||
last++;
|
||||
if (pflag) {
|
||||
(void)snprintf(path, sizeof(path), "T%ld 0 %ld 0\n",
|
||||
(long)statp->st_mtimespec.tv_sec,
|
||||
(long)statp->st_atimespec.tv_sec);
|
||||
(long)statp->st_mtim.tv_sec,
|
||||
(long)statp->st_atim.tv_sec);
|
||||
(void)write(rem, path, strlen(path));
|
||||
if (response() < 0) {
|
||||
closedir(dirp);
|
||||
|
@ -572,12 +572,12 @@ newerf (const char *f1, const char *f2)
|
||||
if (stat(f1, &b1) != 0 || stat(f2, &b2) != 0)
|
||||
return 0;
|
||||
|
||||
if (b1.st_mtimespec.tv_sec > b2.st_mtimespec.tv_sec)
|
||||
if (b1.st_mtim.tv_sec > b2.st_mtim.tv_sec)
|
||||
return 1;
|
||||
if (b1.st_mtimespec.tv_sec < b2.st_mtimespec.tv_sec)
|
||||
if (b1.st_mtim.tv_sec < b2.st_mtim.tv_sec)
|
||||
return 0;
|
||||
|
||||
return (b1.st_mtimespec.tv_nsec > b2.st_mtimespec.tv_nsec);
|
||||
return (b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -15,7 +15,7 @@ $FreeBSD$
|
||||
INT_STRLEN_BOUND (time_t) + 11)];
|
||||
struct tm const *tm = localtime (&inf->stat.st_mtime);
|
||||
- int nsec = TIMESPEC_NS (inf->stat.st_mtim);
|
||||
+ long nsec = TIMESPEC_NS (inf->stat.st_mtimespec);
|
||||
+ long nsec = TIMESPEC_NS (inf->stat.st_mtim);
|
||||
if (! (tm && nstrftime (buf, sizeof buf, time_format, tm, 0, nsec)))
|
||||
{
|
||||
- long int sec = inf->stat.st_mtime;
|
||||
|
@ -49,21 +49,3 @@ $FreeBSD$
|
||||
output_style = style;
|
||||
}
|
||||
}
|
||||
@@ -997,7 +1001,7 @@
|
||||
#ifdef ST_MTIM_NSEC
|
||||
|
||||
# if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
|
||||
- if (clock_gettime (CLOCK_REALTIME, &st->st_mtim) == 0)
|
||||
+ if (clock_gettime (CLOCK_REALTIME, &st->st_mtimespec) == 0)
|
||||
return;
|
||||
# endif
|
||||
|
||||
@@ -1007,7 +1011,7 @@
|
||||
if (gettimeofday (&timeval, 0) == 0)
|
||||
{
|
||||
st->st_mtime = timeval.tv_sec;
|
||||
- st->st_mtim.ST_MTIM_NSEC = timeval.tv_usec * 1000;
|
||||
+ st->st_mtimespec.ST_MTIM_NSEC = timeval.tv_usec * 1000;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -368,8 +368,8 @@ setfile(const char *name, struct stat *fs)
|
||||
|
||||
fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atim);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtim);
|
||||
if (utimes(name, tv))
|
||||
cwarn("utimes: %s", name);
|
||||
|
||||
|
@ -1088,8 +1088,8 @@ copymodes(int fd, const struct stat *sbp, const char *file)
|
||||
if (fchmod(fd, sb.st_mode) < 0)
|
||||
maybe_warn("couldn't fchmod: %s", file);
|
||||
|
||||
TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atim);
|
||||
TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtim);
|
||||
if (futimes(fd, times) < 0)
|
||||
maybe_warn("couldn't utimes: %s", file);
|
||||
|
||||
|
@ -1270,50 +1270,50 @@ ktrstat(struct stat *statp)
|
||||
printf("rdev=%ju, ", (uintmax_t)statp->st_rdev);
|
||||
printf("atime=");
|
||||
if (resolv == 0)
|
||||
printf("%jd", (intmax_t)statp->st_atimespec.tv_sec);
|
||||
printf("%jd", (intmax_t)statp->st_atim.tv_sec);
|
||||
else {
|
||||
tm = localtime(&statp->st_atimespec.tv_sec);
|
||||
tm = localtime(&statp->st_atim.tv_sec);
|
||||
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
|
||||
printf("\"%s\"", timestr);
|
||||
}
|
||||
if (statp->st_atimespec.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_atimespec.tv_nsec);
|
||||
if (statp->st_atim.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_atim.tv_nsec);
|
||||
else
|
||||
printf(", ");
|
||||
printf("stime=");
|
||||
if (resolv == 0)
|
||||
printf("%jd", (intmax_t)statp->st_mtimespec.tv_sec);
|
||||
printf("%jd", (intmax_t)statp->st_mtim.tv_sec);
|
||||
else {
|
||||
tm = localtime(&statp->st_mtimespec.tv_sec);
|
||||
tm = localtime(&statp->st_mtim.tv_sec);
|
||||
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
|
||||
printf("\"%s\"", timestr);
|
||||
}
|
||||
if (statp->st_mtimespec.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_mtimespec.tv_nsec);
|
||||
if (statp->st_mtim.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_mtim.tv_nsec);
|
||||
else
|
||||
printf(", ");
|
||||
printf("ctime=");
|
||||
if (resolv == 0)
|
||||
printf("%jd", (intmax_t)statp->st_ctimespec.tv_sec);
|
||||
printf("%jd", (intmax_t)statp->st_ctim.tv_sec);
|
||||
else {
|
||||
tm = localtime(&statp->st_ctimespec.tv_sec);
|
||||
tm = localtime(&statp->st_ctim.tv_sec);
|
||||
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
|
||||
printf("\"%s\"", timestr);
|
||||
}
|
||||
if (statp->st_ctimespec.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_ctimespec.tv_nsec);
|
||||
if (statp->st_ctim.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_ctim.tv_nsec);
|
||||
else
|
||||
printf(", ");
|
||||
printf("birthtime=");
|
||||
if (resolv == 0)
|
||||
printf("%jd", (intmax_t)statp->st_birthtimespec.tv_sec);
|
||||
printf("%jd", (intmax_t)statp->st_birthtim.tv_sec);
|
||||
else {
|
||||
tm = localtime(&statp->st_birthtimespec.tv_sec);
|
||||
tm = localtime(&statp->st_birthtim.tv_sec);
|
||||
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
|
||||
printf("\"%s\"", timestr);
|
||||
}
|
||||
if (statp->st_birthtimespec.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_birthtimespec.tv_nsec);
|
||||
if (statp->st_birthtim.tv_nsec != 0)
|
||||
printf(".%09ld, ", statp->st_birthtim.tv_nsec);
|
||||
else
|
||||
printf(", ");
|
||||
printf("size=%jd, blksize=%ju, blocks=%jd, flags=0x%x",
|
||||
|
@ -349,7 +349,7 @@ alter(name)
|
||||
return;
|
||||
(void)gettimeofday(&tv[0], (struct timezone *)NULL);
|
||||
tv[0].tv_sec++;
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtim);
|
||||
(void)utimes(name, tv);
|
||||
}
|
||||
|
||||
|
@ -187,9 +187,9 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!aflag)
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atim);
|
||||
if (!mflag)
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtim);
|
||||
|
||||
/*
|
||||
* We're adjusting the times based on the file times, not a
|
||||
@ -197,11 +197,11 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
if (Aflag) {
|
||||
if (aflag) {
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atim);
|
||||
tv[0].tv_sec += Aflag;
|
||||
}
|
||||
if (mflag) {
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtim);
|
||||
tv[1].tv_sec += Aflag;
|
||||
}
|
||||
}
|
||||
@ -368,8 +368,8 @@ stime_file(char *fname, struct timeval *tvp)
|
||||
|
||||
if (stat(fname, &sb))
|
||||
err(1, "%s", fname);
|
||||
TIMESPEC_TO_TIMEVAL(tvp, &sb.st_atimespec);
|
||||
TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtimespec);
|
||||
TIMESPEC_TO_TIMEVAL(tvp, &sb.st_atim);
|
||||
TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtim);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -181,13 +181,13 @@ typeerr: LABEL;
|
||||
* Catches nano-second differences, but doesn't display them.
|
||||
*/
|
||||
if ((s->flags & F_TIME) &&
|
||||
((s->st_mtimespec.tv_sec != p->fts_statp->st_mtimespec.tv_sec) ||
|
||||
(s->st_mtimespec.tv_nsec != p->fts_statp->st_mtimespec.tv_nsec))) {
|
||||
((s->st_mtimespec.tv_sec != p->fts_statp->st_mtim.tv_sec) ||
|
||||
(s->st_mtimespec.tv_nsec != p->fts_statp->st_mtim.tv_nsec))) {
|
||||
LABEL;
|
||||
(void)printf("%smodification time expected %.24s ",
|
||||
tab, ctime(&s->st_mtimespec.tv_sec));
|
||||
(void)printf("found %.24s",
|
||||
ctime(&p->fts_statp->st_mtimespec.tv_sec));
|
||||
ctime(&p->fts_statp->st_mtim.tv_sec));
|
||||
if (uflag) {
|
||||
tv[0].tv_sec = s->st_mtimespec.tv_sec;
|
||||
tv[0].tv_usec = s->st_mtimespec.tv_nsec / 1000;
|
||||
|
@ -213,8 +213,8 @@ statf(int indent, FTSENT *p)
|
||||
(intmax_t)p->fts_statp->st_size);
|
||||
if (keys & F_TIME)
|
||||
output(indent, &offset, "time=%ld.%09ld",
|
||||
(long)p->fts_statp->st_mtimespec.tv_sec,
|
||||
p->fts_statp->st_mtimespec.tv_nsec);
|
||||
(long)p->fts_statp->st_mtim.tv_sec,
|
||||
p->fts_statp->st_mtim.tv_nsec);
|
||||
if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) {
|
||||
if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 ||
|
||||
crc(fd, &val, &len))
|
||||
|
Loading…
Reference in New Issue
Block a user