Replace use of the old BSD st_*timespec members in struct stat with

the POSIX-standard st_*tim members.

ok millert@
This commit is contained in:
guenther 2023-08-11 04:45:05 +00:00
parent 03d5d688c7
commit 79b5458953
6 changed files with 27 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: edit.c,v 1.35 2015/01/16 06:40:06 deraadt Exp $ */
/* $OpenBSD: edit.c,v 1.36 2023/08/11 04:45:05 guenther Exp $ */
/* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */
/*-
@ -58,7 +58,7 @@ edit(char *tempname, struct passwd *pw)
pw_edit(1, tempname);
if (lstat(tempname, &end) == -1 || S_ISLNK(end.st_mode))
return (EDIT_ERROR);
if (!timespeccmp(&begin.st_mtimespec, &end.st_mtimespec, -) &&
if (!timespeccmp(&begin.st_mtim, &end.st_mtim, -) &&
begin.st_size == end.st_size) {
warnx("no changes made");
return (EDIT_NOCHANGE);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.104 2022/10/26 00:40:40 millert Exp $ */
/* $OpenBSD: main.c,v 1.105 2023/08/11 04:45:05 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@ -756,10 +756,8 @@ dodecompress(const char *in, char *out, struct stat *sb)
}
if (storename && !cat) {
if (info.mtime != 0) {
sb->st_mtimespec.tv_sec =
sb->st_atimespec.tv_sec = info.mtime;
sb->st_mtimespec.tv_nsec =
sb->st_atimespec.tv_nsec = 0;
sb->st_mtim.tv_sec = sb->st_atim.tv_sec = info.mtime;
sb->st_mtim.tv_nsec = sb->st_atim.tv_nsec = 0;
}
}
if (error != FAILURE)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: function.c,v 1.54 2023/04/01 05:27:44 tb Exp $ */
/* $OpenBSD: function.c,v 1.55 2023/08/11 04:45:05 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -1205,9 +1205,9 @@ int
f_newer(PLAN *plan, FTSENT *entry)
{
return (entry->fts_statp->st_mtimespec.tv_sec > plan->t_data.tv_sec ||
(entry->fts_statp->st_mtimespec.tv_sec == plan->t_data.tv_sec &&
entry->fts_statp->st_mtimespec.tv_nsec > plan->t_data.tv_nsec));
return (entry->fts_statp->st_mtim.tv_sec > plan->t_data.tv_sec ||
(entry->fts_statp->st_mtim.tv_sec == plan->t_data.tv_sec &&
entry->fts_statp->st_mtim.tv_nsec > plan->t_data.tv_nsec));
}
PLAN *
@ -1221,7 +1221,7 @@ c_newer(char *filename, char ***ignored, int unused)
if (stat(filename, &sb))
err(1, "%s", filename);
new = palloc(N_NEWER, f_newer);
memcpy(&new->t_data, &sb.st_mtimespec, sizeof(struct timespec));
memcpy(&new->t_data, &sb.st_mtim, sizeof(struct timespec));
return (new);
}
@ -1236,9 +1236,9 @@ int
f_anewer(PLAN *plan, FTSENT *entry)
{
return (entry->fts_statp->st_atimespec.tv_sec > plan->t_data.tv_sec ||
(entry->fts_statp->st_atimespec.tv_sec == plan->t_data.tv_sec &&
entry->fts_statp->st_atimespec.tv_nsec > plan->t_data.tv_nsec));
return (entry->fts_statp->st_atim.tv_sec > plan->t_data.tv_sec ||
(entry->fts_statp->st_atim.tv_sec == plan->t_data.tv_sec &&
entry->fts_statp->st_atim.tv_nsec > plan->t_data.tv_nsec));
}
PLAN *
@ -1252,7 +1252,7 @@ c_anewer(char *filename, char ***ignored, int unused)
if (stat(filename, &sb))
err(1, "%s", filename);
new = palloc(N_NEWER, f_anewer);
memcpy(&new->t_data, &sb.st_atimespec, sizeof(struct timespec));
memcpy(&new->t_data, &sb.st_atim, sizeof(struct timespec));
return (new);
}
@ -1267,9 +1267,9 @@ int
f_cnewer(PLAN *plan, FTSENT *entry)
{
return (entry->fts_statp->st_ctimespec.tv_sec > plan->t_data.tv_sec ||
(entry->fts_statp->st_ctimespec.tv_sec == plan->t_data.tv_sec &&
entry->fts_statp->st_ctimespec.tv_nsec > plan->t_data.tv_nsec));
return (entry->fts_statp->st_ctim.tv_sec > plan->t_data.tv_sec ||
(entry->fts_statp->st_ctim.tv_sec == plan->t_data.tv_sec &&
entry->fts_statp->st_ctim.tv_nsec > plan->t_data.tv_nsec));
}
PLAN *
@ -1283,7 +1283,7 @@ c_cnewer(char *filename, char ***ignored, int unused)
if (stat(filename, &sb))
err(1, "%s", filename);
new = palloc(N_NEWER, f_cnewer);
memcpy(&new->t_data, &sb.st_ctimespec, sizeof(struct timespec));
memcpy(&new->t_data, &sb.st_ctim, sizeof(struct timespec));
return (new);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fileio.c,v 1.111 2023/03/30 19:00:02 op Exp $ */
/* $OpenBSD: fileio.c,v 1.112 2023/08/11 04:45:05 guenther Exp $ */
/* This file is in the public domain. */
@ -67,7 +67,7 @@ ffstat(FILE *ffp, struct buffer *bp)
bp->b_fi.fi_mode = sb.st_mode | 0x8000;
bp->b_fi.fi_uid = sb.st_uid;
bp->b_fi.fi_gid = sb.st_gid;
bp->b_fi.fi_mtime = sb.st_mtimespec;
bp->b_fi.fi_mtime = sb.st_mtim;
/* Clear the ignore flag */
bp->b_flag &= ~(BFIGNDIRTY | BFDIRTY);
}
@ -587,8 +587,8 @@ fchecktime(struct buffer *bp)
if (stat(bp->b_fname, &sb) == -1)
return (TRUE);
if (bp->b_fi.fi_mtime.tv_sec != sb.st_mtimespec.tv_sec ||
bp->b_fi.fi_mtime.tv_nsec != sb.st_mtimespec.tv_nsec)
if (bp->b_fi.fi_mtime.tv_sec != sb.st_mtim.tv_sec ||
bp->b_fi.fi_mtime.tv_nsec != sb.st_mtim.tv_nsec)
return (FALSE);
return (TRUE);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: privsep.c,v 1.75 2023/03/08 04:43:15 guenther Exp $ */
/* $OpenBSD: privsep.c,v 1.76 2023/08/11 04:45:06 guenther Exp $ */
/*
* Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
@ -319,8 +319,8 @@ priv_exec(char *conf, int numeric, int child, int argc, char *argv[])
case PRIV_CONFIG_MODIFIED:
log_debug("[priv]: msg PRIV_CONFIG_MODIFIED received");
if (stat(conf, &cf_stat) == -1 ||
timespeccmp(&cf_info.st_mtimespec,
&cf_stat.st_mtimespec, <) ||
timespeccmp(&cf_info.st_mtim,
&cf_stat.st_mtim, <) ||
cf_info.st_size != cf_stat.st_size) {
log_debug("config file modified: restarting");
restart = result = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vipw.c,v 1.26 2021/10/24 21:24:19 deraadt Exp $ */
/* $OpenBSD: vipw.c,v 1.27 2023/08/11 04:45:05 guenther Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
@ -88,7 +88,7 @@ main(int argc, char *argv[])
pw_edit(0, NULL);
if (stat(_PATH_MASTERPASSWD_LOCK, &end))
pw_error(_PATH_MASTERPASSWD_LOCK, 1, 1);
if (timespeccmp(&begin.st_mtimespec, &end.st_mtimespec, ==) &&
if (timespeccmp(&begin.st_mtim, &end.st_mtim, ==) &&
begin.st_size == end.st_size) {
warnx("no changes made");
pw_error((char *)NULL, 0, 0);