From 79b54589534032b04031657a533f519433949b38 Mon Sep 17 00:00:00 2001 From: guenther Date: Fri, 11 Aug 2023 04:45:05 +0000 Subject: [PATCH] Replace use of the old BSD st_*timespec members in struct stat with the POSIX-standard st_*tim members. ok millert@ --- usr.bin/chpass/edit.c | 4 ++-- usr.bin/compress/main.c | 8 +++----- usr.bin/find/function.c | 26 +++++++++++++------------- usr.bin/mg/fileio.c | 8 ++++---- usr.sbin/syslogd/privsep.c | 6 +++--- usr.sbin/vipw/vipw.c | 4 ++-- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index b75a47efa8a..c019f560889 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -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); diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index ec975698ee7..834f3bd90d3 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -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) diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 62569893930..344b259315b 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -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); } diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 7b5bbc574ea..fd44a8bcf32 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -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); diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c index db3131bdc5a..2edbbbca971 100644 --- a/usr.sbin/syslogd/privsep.c +++ b/usr.sbin/syslogd/privsep.c @@ -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 @@ -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; diff --git a/usr.sbin/vipw/vipw.c b/usr.sbin/vipw/vipw.c index 9a944f59d2c..88d0112c00c 100644 --- a/usr.sbin/vipw/vipw.c +++ b/usr.sbin/vipw/vipw.c @@ -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); -- 2.20.1