svn commit: r251113 - stable/9/usr.sbin/newsyslog

Mark Johnston markj at FreeBSD.org
Wed May 29 22:30:30 UTC 2013


Author: markj
Date: Wed May 29 22:30:29 2013
New Revision: 251113
URL: http://svnweb.freebsd.org/changeset/base/251113

Log:
  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:
  stable/9/usr.sbin/newsyslog/newsyslog.c
Directory Properties:
  stable/9/usr.sbin/newsyslog/   (props changed)

Modified: stable/9/usr.sbin/newsyslog/newsyslog.c
==============================================================================
--- stable/9/usr.sbin/newsyslog/newsyslog.c	Wed May 29 22:29:33 2013	(r251112)
+++ stable/9/usr.sbin/newsyslog/newsyslog.c	Wed May 29 22:30:29 2013	(r251113)
@@ -1450,27 +1450,16 @@ oldlog_entry_compare(const void *a, cons
  * 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;
 
 	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 @@ delete_oldest_timelog(const struct conf_
 		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 @@ mtime_old_timelog(const char *file)
 	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 svn-src-all mailing list