[Midnightbsd-cvs] src [9453] trunk/usr.sbin/newsyslog/newsyslog.c: Revert my previous merge.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Mar 5 14:33:06 EST 2017
Revision: 9453
http://svnweb.midnightbsd.org/src/?rev=9453
Author: laffer1
Date: 2017-03-05 14:33:06 -0500 (Sun, 05 Mar 2017)
Log Message:
-----------
Revert my previous merge. There's a variable name difference between head
and stable (dirfd vs. dir_fd) and I managed to get it wrong again when I
did the MFC, even after I tested.
Modified Paths:
--------------
trunk/usr.sbin/newsyslog/newsyslog.c
Modified: trunk/usr.sbin/newsyslog/newsyslog.c
===================================================================
--- trunk/usr.sbin/newsyslog/newsyslog.c 2017-03-05 19:32:41 UTC (rev 9452)
+++ trunk/usr.sbin/newsyslog/newsyslog.c 2017-03-05 19:33:06 UTC (rev 9453)
@@ -1450,10 +1450,8 @@
* tm if this is the case; otherwise return false.
*/
static int
-validate_old_timelog(int fd, const struct dirent *dp, const char *logfname,
- struct tm *tm)
+validate_old_timelog(const struct dirent *dp, const char *logfname, struct tm *tm)
{
- struct stat sb;
size_t logfname_len;
char *s;
int c;
@@ -1460,17 +1458,8 @@
logfname_len = strlen(logfname);
- if (dp->d_type != DT_REG) {
- /*
- * Some filesystems (e.g. NFS) don't fill out the d_type field
- * and leave it set to DT_UNKNOWN; in this case we must obtain
- * the file type ourselves.
- */
- if (dp->d_type != DT_UNKNOWN ||
- fstatat(fd, dp->d_name, &sb, AT_SYMLINK_NOFOLLOW) != 0 ||
- !S_ISREG(sb.st_mode))
- return (0);
- }
+ if (dp->d_type != DT_REG)
+ return (0);
/* Ignore everything but files with our logfile prefix. */
if (strncmp(dp->d_name, logfname, logfname_len) != 0)
return (0);
@@ -1556,7 +1545,7 @@
err(1, "Cannot open log directory '%s'", dir);
dirfd = dirfd(dirp);
while ((dp = readdir(dirp)) != NULL) {
- if (validate_old_timelog(dir_fd, dp, logfname, &tm) == 0)
+ if (validate_old_timelog(dp, logfname, &tm) == 0)
continue;
/*
@@ -2321,10 +2310,10 @@
dir_fd = dirfd(dirp);
/* Open the archive dir and find the most recent archive of logfname. */
while ((dp = readdir(dirp)) != NULL) {
- if (validate_old_timelog(dir_fd, dp, logfname, &tm) == 0)
+ if (validate_old_timelog(dp, logfname, &tm) == 0)
continue;
- if (fstatat(dir_fd, logfname, &sb, AT_SYMLINK_NOFOLLOW) == -1) {
+ if (fstatat(dir_fd, logfname, &sb, 0) == -1) {
warn("Cannot stat '%s'", file);
continue;
}
More information about the Midnightbsd-cvs
mailing list